mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
refactor: edit existing tui elements to add new gh add tui component
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user