mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 01:32:33 +02:00
ui/home is now in the same app
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -142,6 +142,11 @@ type Project struct {
|
||||
ModTime time.Time
|
||||
}
|
||||
|
||||
// ProjectSelectedMsg is emitted when the user picks a project from the home screen.
|
||||
type ProjectSelectedMsg struct {
|
||||
Project *Project
|
||||
}
|
||||
|
||||
type inputMode int
|
||||
|
||||
const (
|
||||
@@ -161,15 +166,11 @@ type Model struct {
|
||||
list list.Model
|
||||
projectDir string
|
||||
nameInput textinput.Model
|
||||
selected *Project
|
||||
width int
|
||||
height int
|
||||
teapotFrame int
|
||||
}
|
||||
|
||||
// Selected returns the project chosen by the user, or nil if the program was
|
||||
// quit without making a selection.
|
||||
func (m Model) Selected() *Project { return m.selected }
|
||||
|
||||
func New(projectDir string) Model {
|
||||
projects := loadProjects(projectDir)
|
||||
|
||||
@@ -76,11 +76,11 @@ func (m Model) handleSelection() (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
}
|
||||
initProjectFiles(dir)
|
||||
m.selected = &Project{Name: "temporary", Path: filepath.Join(dir, "data.db")}
|
||||
return m, tea.Quit
|
||||
p := &Project{Name: "temporary", Path: filepath.Join(dir, "data.db")}
|
||||
return m, func() tea.Msg { return ProjectSelectedMsg{Project: p} }
|
||||
default:
|
||||
m.selected = &Project{Name: item.name, Path: item.path}
|
||||
return m, tea.Quit
|
||||
p := &Project{Name: item.name, Path: item.path}
|
||||
return m, func() tea.Msg { return ProjectSelectedMsg{Project: p} }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ func (m Model) updateNaming(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
|
||||
return m, nil
|
||||
}
|
||||
initProjectFiles(dir)
|
||||
m.selected = &Project{Name: name, Path: filepath.Join(dir, "data.db")}
|
||||
return m, tea.Quit
|
||||
p := &Project{Name: name, Path: filepath.Join(dir, "data.db")}
|
||||
return m, func() tea.Msg { return ProjectSelectedMsg{Project: p} }
|
||||
default:
|
||||
var cmd tea.Cmd
|
||||
m.nameInput, cmd = m.nameInput.Update(msg)
|
||||
|
||||
Reference in New Issue
Block a user