blob: e88a647167e49239b32a01a33267dab7449260f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package root
import (
"nectar/types"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
type MainAreaModel struct {
connectionForm ConnectionFormModel
}
func NewMainArea() MainAreaModel {
return MainAreaModel{
connectionForm: NewConnectionForm(),
}
}
func (m MainAreaModel) Init() tea.Cmd {
return m.connectionForm.Init()
}
func (m MainAreaModel) Update(msg tea.Msg) (MainAreaModel, tea.Cmd) {
var cmd tea.Cmd
formModel, cmd := m.connectionForm.Update(msg)
m.connectionForm = formModel.(ConnectionFormModel)
return m, cmd
}
func MainArea(globals *types.Globals, mainArea MainAreaModel) string {
formContent := mainArea.connectionForm.View()
return lipgloss.Place(
globals.Width-30,
globals.Height-1,
lipgloss.Center,
lipgloss.Center,
formContent,
)
}
|