Skip to content

Commit

Permalink
refactor: use arrow keys and remove hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Nov 5, 2024
1 parent 10b0354 commit da64fee
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 39 deletions.
2 changes: 1 addition & 1 deletion ui/pages/accounts/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func New(state *internal.StateModel) ViewModel {
Height: 0,
Data: state.Accounts,
controls: "( (g)enerate )",
navigation: "| " + style.Green.Render("(a)ccounts") + " | (k)eys | (t)xn |",
navigation: "| " + style.Green.Render("accounts") + " | keys | txn |",
}

m.table = table.New(
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/keys/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func New(address string, keys *[]api.ParticipationKey) ViewModel {
Width: 80,
Height: 24,

controls: "( (g)enerate | (d)elete )",
navigation: "| (a)ccounts | " + style.Green.Render("(k)eys") + " | (t)xn |",
controls: "( (g)enerate )",
navigation: "| accounts | " + style.Green.Render("keys") + " | txn |",

table: table.New(),
}
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/transaction/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func New(state *internal.StateModel) ViewModel {
return ViewModel{
State: state,
IsOnline: false,
navigation: "| (a)ccounts | (k)eys | " + style.Green.Render("(t)xn") + " |",
controls: "( shift+tab: back )",
navigation: "| accounts | keys | " + style.Green.Render("txn") + " |",
controls: "( <- back )",
}
}
36 changes: 2 additions & 34 deletions ui/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (m ViewportViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.KeyMsg:
switch msg.String() {
// Tab Backwards
case "shift+tab":
case "left":
if m.page == AccountsPage {
return m, nil
}
Expand All @@ -112,7 +112,7 @@ func (m ViewportViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
}
// Tab Forwards
case "tab":
case "right":
if m.page == AccountsPage {
selAcc := m.accountsPage.SelectedAccount()
if selAcc != (internal.Account{}) {
Expand All @@ -129,38 +129,6 @@ func (m ViewportViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
return m, nil
case "a":
m.page = AccountsPage
case "g":
m.generatePage.Inputs[0].SetValue(m.accountsPage.SelectedAccount().Address)
m.page = GeneratePage
return m, nil
case "k":
selAcc := m.accountsPage.SelectedAccount()
if selAcc != (internal.Account{}) {
m.page = KeysPage
return m, accounts.EmitAccountSelected(selAcc)
}
return m, nil
case "t":
if m.page == AccountsPage {
acct := m.accountsPage.SelectedAccount()
data := *m.Data.ParticipationKeys
for i, key := range data {
if key.Address == acct.Address {
m.page = TransactionPage
return m, keys.EmitKeySelected(&data[i])
}
}
}
if m.page == KeysPage {
selKey := m.keysPage.SelectedKey()
if selKey != nil {
m.page = TransactionPage
return m, keys.EmitKeySelected(selKey)
}
}
return m, nil
case "ctrl+c":
if m.page != GeneratePage {
return m, tea.Quit
Expand Down

0 comments on commit da64fee

Please sign in to comment.