refactor: edit existing tui elements to add new gh add tui component

This commit is contained in:
Slug-Boi
2025-04-10 22:31:34 +02:00
parent 4dd972c355
commit 53fef652b1
2 changed files with 36 additions and 0 deletions
+27
View File
@@ -137,6 +137,33 @@ func intitialErrorModel() *errorModel {
}
}
func createGHTempAuthorModel(old_m *model, user utils.User) model_ca {
parent_m = old_m
m := model_ca{
inputs: make([]textinput.Model, 2),
errorModel: intitialErrorModel(),
}
var t textinput.Model
for i := range m.inputs {
t = textinput.New()
t.Cursor.Style = cursorStyle
switch i {
case 0:
t.Placeholder = "Username (e.g. JohnDoe-gh)"
t.SetValue(user.Username)
t.Focus()
t.PromptStyle = focusedStyle
t.TextStyle = focusedStyle
case 1:
t.Placeholder = "Email (e.g. JohnDoe@domain.do)"
t.SetValue(user.Email)
}
m.inputs[i] = t
}
tempAuthorToggle = true
return m
}
func createGHAuthorModel(old_m *model, user utils.User) model_ca {
parent_m = old_m
+9
View File
@@ -47,6 +47,7 @@ type listKeyMap struct {
createAuthor key.Binding
deleteAuthor key.Binding
tempAdd key.Binding
ghAdd key.Binding
}
func newListKeyMap() *listKeyMap {
@@ -79,6 +80,10 @@ func newListKeyMap() *listKeyMap {
key.WithKeys("T"),
key.WithHelp("T", "Add temporary author"),
),
ghAdd: key.NewBinding(
key.WithKeys("c"),
key.WithHelp("c", "Add GitHub author"),
),
}
}
@@ -180,6 +185,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
// Handle keys from keyList (help menu)
switch {
case key.Matches(msg, m.keys.ghAdd):
sub_model = NewGitHubUserForm(&m)
return m, tea.ClearScreen
case key.Matches(msg, m.keys.negation):
i, ok := m.list.SelectedItem().(item)
if ok {