diff --git a/main.go b/main.go index cb94f1c1d6f3878650de34c6cb91c41e0e420f9c..55775a201c8672fabdaf47e27d861f2c875d4f24 100644 --- a/main.go +++ b/main.go @@ -66,7 +66,7 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case *tui.EmailView: m.current = m.inbox // Go back to the cached inbox return m, nil - case *tui.Inbox, *tui.Composer: + case *tui.Inbox, *tui.Composer, *tui.Login: m.current = tui.NewChoice() // Go back to the main menu return m, m.current.Init() } @@ -106,6 +106,11 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.current = tui.NewComposer(m.config.Email) m.current, _ = m.current.Update(tea.WindowSizeMsg{Width: m.width, Height: m.height}) cmds = append(cmds, m.current.Init()) + + case tui.GoToSettingsMsg: + m.current = tui.NewLogin() + m.current, _ = m.current.Update(tea.WindowSizeMsg{Width: m.width, Height: m.height}) + cmds = append(cmds, m.current.Init()) case tui.ViewEmailMsg: emailView := tui.NewEmailView(m.emails[msg.Index], m.width, m.height) diff --git a/tui/choice.go b/tui/choice.go index b431f01f331eafda4bfebc5a91b7106d34d35d9b..83bb378962ef19b06137dd0b6c9f4478963b2f3e 100644 --- a/tui/choice.go +++ b/tui/choice.go @@ -51,14 +51,17 @@ func (m Choice) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.cursor-- } case "down", "j": - if m.cursor < 1 { // We have two choices + if m.cursor < 2 { // We have three choices now m.cursor++ } case "enter": - if m.cursor == 0 { + switch m.cursor { + case 0: return m, func() tea.Msg { return GoToInboxMsg{} } - } else if m.cursor == 1 { + case 1: return m, func() tea.Msg { return GoToSendMsg{} } + case 2: + return m, func() tea.Msg { return GoToSettingsMsg{} } } } } @@ -76,7 +79,7 @@ func (m Choice) View() string { b.WriteString("\n\n") // Choices - choices := []string{"View Inbox", "Compose Email"} + choices := []string{"View Inbox", "Compose Email", "Settings"} for i, choice := range choices { if m.cursor == i { b.WriteString(selectedItemStyle.Render(fmt.Sprintf("> %s", choice))) diff --git a/tui/composer.go b/tui/composer.go index b9b1810abcd1081ce58b26a016dfa53903275744..34d006562bfb48ecaac72f5f2c35ed3fb12a3cef 100644 --- a/tui/composer.go +++ b/tui/composer.go @@ -145,6 +145,6 @@ func (m *Composer) View() string { m.subjectInput.View(), m.bodyInput.View(), *button, - helpStyle.Render("tab: next field • esc: back to menu"), + helpStyle.Render("tab: next field • esc: back to menu • enter: send"), ) } \ No newline at end of file diff --git a/tui/login.go b/tui/login.go index ec7b67fafd17263dd5d6211e5bcc9a8f8d3150ff..b19f099859bb790d1fac9f036887313eaf73ae26 100644 --- a/tui/login.go +++ b/tui/login.go @@ -107,12 +107,12 @@ func (m Login) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // View renders the login form. func (m Login) View() string { return lipgloss.JoinVertical(lipgloss.Left, - titleStyle.Render("Welcome to Email CLI"), - "Please enter your credentials.", + titleStyle.Render("Account Settings"), + "Update your credentials.", m.inputs[0].View(), m.inputs[1].View(), m.inputs[2].View(), m.inputs[3].View(), - helpStyle.Render("\nenter: submit • tab: next field • esc: quit"), + helpStyle.Render("\nenter: save • tab: next field • esc: back to menu"), ) } \ No newline at end of file diff --git a/tui/messages.go b/tui/messages.go index 4662a525b5cf8b3aa8014a42df0c70a2e19e7eb2..91004e28b0eb2913ec75dc5a5a80f485943e4f60 100644 --- a/tui/messages.go +++ b/tui/messages.go @@ -48,4 +48,7 @@ type FetchErr error type GoToInboxMsg struct{} // A message to navigate to the composer view. -type GoToSendMsg struct{} \ No newline at end of file +type GoToSendMsg struct{} + +// A message to navigate to the settings view. +type GoToSettingsMsg struct{} \ No newline at end of file