get seprate file for entry list working
This commit is contained in:
parent
4d1f3f2f3e
commit
b680a2f5d7
4 changed files with 102 additions and 32 deletions
41
main.go
41
main.go
|
|
@ -13,22 +13,18 @@ type Page string
|
|||
|
||||
const (
|
||||
ActionList Page = "actionList"
|
||||
// EntryList Page = "entryList"
|
||||
EntryList Page = "entryList"
|
||||
// Entry Page = "entry"
|
||||
)
|
||||
|
||||
// type entryListPageModel struct {
|
||||
// entries []gemlog.GemlogListEntry
|
||||
// actionToTake Action
|
||||
// cursor int
|
||||
// }
|
||||
type SwitchPages struct{ Page Page }
|
||||
|
||||
type uiState struct {
|
||||
notification string
|
||||
errorTxt string
|
||||
|
||||
page Page
|
||||
// entryListPage entryListPageModel
|
||||
page Page
|
||||
entryListPage EntryListPageModel
|
||||
actionListPage ActionListPageModel
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +63,8 @@ func (m model) Init() tea.Cmd {
|
|||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
cmds := make([]tea.Cmd, 0)
|
||||
switch msg := msg.(type) {
|
||||
case SwitchPages:
|
||||
m.ui.page = msg.Page
|
||||
case gemlog.ErrorMsg:
|
||||
m.ui.errorTxt = fmt.Sprintf("%s\n\n", fmt.Errorf("%s", msg))
|
||||
case gemlog.Notification:
|
||||
|
|
@ -78,13 +76,13 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
// Delegate to the active page
|
||||
switch m.ui.page {
|
||||
case ActionList:
|
||||
m2, cmd := m.ui.actionListPage.Update(msg, m.context)
|
||||
m.ui.actionListPage = m2
|
||||
cmds = append(cmds, cmd)
|
||||
}
|
||||
actionListM, cmd := m.ui.actionListPage.Update(msg, m.context)
|
||||
m.ui.actionListPage = actionListM
|
||||
cmds = append(cmds, cmd)
|
||||
|
||||
entryListM, cmd := m.ui.entryListPage.Update(msg, m.context)
|
||||
m.ui.entryListPage = entryListM
|
||||
cmds = append(cmds, cmd)
|
||||
|
||||
return m, tea.Batch(cmds...)
|
||||
}
|
||||
|
|
@ -100,19 +98,10 @@ func (m model) View() string {
|
|||
|
||||
if m.ui.page == ActionList {
|
||||
s += m.ui.actionListPage.View()
|
||||
} else if m.ui.page == EntryList {
|
||||
s += m.ui.entryListPage.View()
|
||||
}
|
||||
|
||||
// if m.ui.page == EntryList {
|
||||
// s += fmt.Sprintf("Which entry would you like to %s\n\n", m.ui.entryListPage.actionToTake)
|
||||
// for i, entry := range m.ui.entryListPage.entries {
|
||||
// cursor := " "
|
||||
// if m.ui.entryListPage.cursor == i {
|
||||
// cursor = ">"
|
||||
// }
|
||||
// s += fmt.Sprintf("%s %s : %s\n", cursor, entry.Date, entry.Slug)
|
||||
// }
|
||||
// }
|
||||
|
||||
s += "\nPress q to quit.\n"
|
||||
|
||||
return s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue