@@ -1,4 +1,4 @@
1−package ui
1+package model
22
33import (
44 "image"
@@ -6,6 +6,8 @@ import (
66 "github.com/charmbracelet/bubbles/v2/key"
77 tea "github.com/charmbracelet/bubbletea/v2"
88 "github.com/charmbracelet/crush/internal/app"
9+ "github.com/charmbracelet/crush/internal/ui/common"
10+ "github.com/charmbracelet/crush/internal/ui/dialog"
911 "github.com/charmbracelet/lipgloss/v2"
1012 uv "github.com/charmbracelet/ultraviolet"
1113)
@@ -18,22 +20,21 @@ const (
1820
1921type UI struct {
2022 app *app.App
21− com *Common
23+ com *common.Common
2224
2325 width, height int
2426 state uiState
2527
2628 keyMap KeyMap
27− styles Styles
2829
29− dialog *Overlay
30+ dialog *dialog.Overlay
3031}
3132
32−func New(com *Common, app *app.App) *UI {
33+func New(com *common.Common, app *app.App) *UI {
3334 return &UI{
3435 app: app,
3536 com: com,
36− dialog: NewDialogOverlay(),
37+ dialog: dialog.NewOverlay(),
3738 keyMap: DefaultKeyMap(),
3839 }
3940}
@@ -53,7 +54,7 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
5354 case uiStateMain:
5455 switch {
5556 case key.Matches(msg, m.keyMap.Quit):
56− quitDialog := NewQuitDialog(m.com)
57+ quitDialog := dialog.NewQuit(m.com)
5758 if !m.dialog.ContainsDialog(quitDialog.ID()) {
5859 m.dialog.AddDialog(quitDialog)
5960 return m, nil
@@ -73,6 +74,7 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
7374
7475func (m *UI) View() tea.View {
7576 var v tea.View
77+ v.AltScreen = true
7678
7779 // The screen area we're working with
7880 area := image.Rect(0, 0, m.width, m.height)
@@ -88,6 +90,29 @@ func (m *UI) View() tea.View {
8890 )
8991 }
9092
93+ mainRect, sideRect := uv.SplitHorizontal(area, uv.Fixed(area.Dx()-40))
94+ mainRect, footRect := uv.SplitVertical(mainRect, uv.Fixed(area.Dy()-7))
95+
96+ layers = append(layers, lipgloss.NewLayer(
97+ lipgloss.NewStyle().Width(mainRect.Dx()).
98+ Height(mainRect.Dy()).
99+ Border(lipgloss.NormalBorder()).
100+ Render(" Main View "),
101+ ).X(mainRect.Min.X).Y(mainRect.Min.Y),
102+ lipgloss.NewLayer(
103+ lipgloss.NewStyle().Width(sideRect.Dx()).
104+ Height(sideRect.Dy()).
105+ Border(lipgloss.NormalBorder()).
106+ Render(" Side View "),
107+ ).X(sideRect.Min.X).Y(sideRect.Min.Y),
108+ lipgloss.NewLayer(
109+ lipgloss.NewStyle().Width(footRect.Dx()).
110+ Height(footRect.Dy()).
111+ Border(lipgloss.NormalBorder()).
112+ Render(" Footer View "),
113+ ).X(footRect.Min.X).Y(footRect.Min.Y),
114+ )
115+
91116 v.Layer = lipgloss.NewCanvas(layers...)
92117
93118 return v