-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.go
48 lines (40 loc) · 923 Bytes
/
app.go
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
42
43
44
45
46
47
48
package shared
import (
"github.com/tty2/kubic/pkg/ui/shared/themes"
)
type App struct {
CurrentNamespace string
CurrentTab TabItem
Styles *themes.Styles
KeyMap *KeyMap
GUI GUI
updateNScallbacks []func()
}
type GUI struct {
ScreenHeight int
ScreenWidth int
Areas *uiAreas
}
func NewApp(theme themes.Theme) *App {
keyMap := GetKeyMaps()
styles := themes.GetStyle(theme)
return &App{
Styles: &styles,
KeyMap: &keyMap,
GUI: GUI{
Areas: initAreas(),
},
}
}
func (app *App) ResizeAreas() {
app.GUI.Areas.MainContent.Height = app.GUI.ScreenHeight -
(app.GUI.Areas.TabBar.Height + app.GUI.Areas.HelpBar.Height)
}
func (app *App) AddUpdateNamespaceCallback(fn func()) {
app.updateNScallbacks = append(app.updateNScallbacks, fn)
}
func (app *App) OnUpdateNamespace() {
for i := range app.updateNScallbacks {
app.updateNScallbacks[i]()
}
}