gemlog-cli/internal/ui/entry.go
Travis Shears 360fedbebe restructure project following best practices
https://go.dev/doc/modules/layout
This also enables us to later import just the db interaction part
say to the gemini capsule backend go project.
2025-10-04 19:42:18 +02:00

44 lines
831 B
Go

package ui
import (
gemlog "git.travisshears.com/travisshears/gemlog-cli/gemlog"
tea "github.com/charmbracelet/bubbletea"
)
type EntryPageModel struct {
entry gemlog.GemlogEntry
}
func initialEntryPageModel() EntryPageModel {
return EntryPageModel{}
}
func (m EntryPageModel) Update(msg tea.Msg, active bool, ctx *context) (EntryPageModel, tea.Cmd) {
switch msg := msg.(type) {
case GemLogLoaded:
m.entry = msg.Log
case tea.KeyMsg:
if !active {
return m, nil
}
switch msg.String() {
case "left", "h":
cmd := func() tea.Msg {
return SwitchPages{Page: EntryList}
}
return m, cmd
}
}
return m, nil
}
func (m EntryPageModel) View() string {
s := m.entry.Slug
s += "\n\n"
s += m.entry.Gemtxt
s += "\n\n-------------------------\n"
s += "\n\nPress h or left arrow to go back"
return s
}