add page for reading a single gemlog entry

This commit is contained in:
Travis Shears 2025-10-03 12:07:48 +02:00
parent 8414414f98
commit 02ed95a612
5 changed files with 78 additions and 17 deletions

18
main.go
View file

@ -25,6 +25,7 @@ type uiState struct {
page Page
entryListPage EntryListPageModel
entryPage EntryPageModel
actionListPage ActionListPageModel
}
@ -43,7 +44,7 @@ func initialModel(config *gemlog.Config) model {
page: ActionList,
actionListPage: initialActionListPageModel(),
entryListPage: initialEntryListPageModel(),
// entryPage: initialEntryPageModel(),
entryPage: initialEntryPageModel(),
},
context: &context{
config: config,
@ -59,7 +60,7 @@ func (m model) Init() tea.Cmd {
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
cmds := make([]tea.Cmd, 0)
cmds := make([]tea.Cmd, 3)
switch msg := msg.(type) {
case SwitchPages:
m.ui.page = msg.Page
@ -74,7 +75,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
actionListM, cmd := m.ui.actionListPage.Update(msg, m.context)
actionListM, cmd := m.ui.actionListPage.Update(msg, m.ui.page == ActionList, m.context)
m.ui.actionListPage = actionListM
cmds = append(cmds, cmd)
@ -82,6 +83,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.ui.entryListPage = entryListM
cmds = append(cmds, cmd)
entrytM, cmd := m.ui.entryPage.Update(msg, m.ui.page == Entry, m.context)
m.ui.entryPage = entrytM
cmds = append(cmds, cmd)
return m, tea.Batch(cmds...)
}
@ -94,10 +99,13 @@ func (m model) View() string {
s += m.ui.notification
}
if m.ui.page == ActionList {
switch m.ui.page {
case ActionList:
s += m.ui.actionListPage.View()
} else if m.ui.page == EntryList {
case EntryList:
s += m.ui.entryListPage.View()
case Entry:
s += m.ui.entryPage.View()
}
s += "\nPress q to quit.\n"