Удаление ненужных сообщений, удаление дублирования кода update viewport final, исправление приведени типов, работа над viewport form, исправление динамических секций

This commit is contained in:
XeRo 2026-01-16 17:44:03 +05:00
parent 300afb5d26
commit ecc89e34c5
11 changed files with 168 additions and 142 deletions

View file

@ -2,7 +2,6 @@ package fields
import (
"bubble/setup/ui"
"bubble/types"
"fmt"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
@ -82,14 +81,8 @@ func (m *DirSelectModel) Update(msg tea.Msg) (FieldModel, tea.Cmd) {
m.dir = newValue
m.input.CursorEnd()
m.open = false
selected := types.SelectedDirMsg{
DirectoryName: fileName,
Index: m.focus,
}
m.focus = 0
return m, func() tea.Msg {
return selected
}
return m, nil
}
}
} else {

View file

@ -2,6 +2,8 @@ package fields
import tea "github.com/charmbracelet/bubbletea"
// todo комментарии к полям
// todo описание поля выводить
type FieldModel interface {
Init() tea.Cmd
Update(msg tea.Msg) (FieldModel, tea.Cmd)

View file

@ -2,7 +2,6 @@ package fields
import (
"bubble/setup/ui"
"bubble/types"
"fmt"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
@ -92,15 +91,9 @@ func (m *FileSelectModel) Update(msg tea.Msg) (FieldModel, tea.Cmd) {
m.file = fullPath
m.input.SetValue(fullPath)
m.open = false
selected := types.SelectedFileMsg{
Filename: fileName,
Index: m.focus,
}
m.input.CursorEnd()
m.focus = 0
return m, func() tea.Msg {
return selected
}
return m, nil
}
}
} else {

View file

@ -1,7 +1,6 @@
package fields
import (
"bubble/types"
"fmt"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
@ -60,15 +59,9 @@ func (m *SelectModel) Update(msg tea.Msg) (FieldModel, tea.Cmd) {
return m, nil
}
m.chosen = m.options[m.focus]
selected := types.SelectedOptionMsg{
FieldIndex: m.focus,
Value: m.chosen,
}
m.open = false
m.focus = len(m.options)
return m, func() tea.Msg {
return selected
}
return m, nil
}
} else {
switch msg.String() {