-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
89 lines (76 loc) · 2.13 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/flowline-io/flowkit/internal/pkg/constant"
"github.com/flowline-io/flowkit/internal/pkg/flog"
"github.com/flowline-io/flowkit/internal/pkg/server"
"github.com/flowline-io/flowkit/internal/pkg/setting"
"github.com/flowline-io/flowkit/internal/pkg/util"
"github.com/flowline-io/flowkit/internal/ruleset/agent"
"github.com/flowline-io/flowkit/internal/ruleset/instruct"
"github.com/flowline-io/flowkit/internal/ui/info"
)
type appInfo struct {
name string
icon fyne.Resource
canv bool
run func(fyne.Window) fyne.CanvasObject
}
var apps = []appInfo{
{"Dashboard", theme.DocumentIcon(), false, info.Show},
{"Bots", theme.AccountIcon(), false, info.Show},
{"Settings", theme.SettingsIcon(), false, info.Show},
{"Info", theme.InfoIcon(), false, info.Show},
}
func main() {
// load preferences
err := setting.Init()
if err != nil {
flog.Panic(err.Error())
}
// logger
flog.Init()
// check singleton
util.CheckSingleton()
// embed server
server.EmbedServer(constant.EmbedServerPort)
// cron
instruct.Cron()
agent.Cron()
a := app.New()
a.SetIcon(resourceIconPng)
content := container.NewMax()
w := a.NewWindow("flowkit")
appList := widget.NewList(
func() int {
return len(apps)
},
func() fyne.CanvasObject {
icon := &canvas.Image{}
label := widget.NewLabel("Text Editor")
labelHeight := label.MinSize().Height
icon.SetMinSize(fyne.NewSize(labelHeight, labelHeight))
return container.NewBorder(nil, nil, icon, nil,
label)
},
func(id widget.ListItemID, obj fyne.CanvasObject) {
img := obj.(*fyne.Container).Objects[1].(*canvas.Image)
text := obj.(*fyne.Container).Objects[0].(*widget.Label)
img.Resource = apps[id].icon
img.Refresh()
text.SetText(apps[id].name)
})
appList.OnSelected = func(id widget.ListItemID) {
content.Objects = []fyne.CanvasObject{apps[id].run(w)}
}
split := container.NewHSplit(appList, content)
split.Offset = 0.1
w.SetContent(split)
w.Resize(fyne.NewSize(640, 720))
w.ShowAndRun()
}