-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.go
58 lines (47 loc) · 858 Bytes
/
ui.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
package dotui
import (
"flag"
"log"
"gioui.org/app"
"gioui.org/font/gofont"
"gioui.org/unit"
"gioui.org/widget"
"github.com/kreativka/dot-ui/theme"
)
func newApp(w *app.Window) *App {
a := &App{
w: w,
profiling: false,
}
a.env.editor = &widget.Editor{
SingleLine: true,
Submit: true,
}
a.env.localized = parseFlag()
a.env.theme = theme.NewTheme()
return a
}
func parseFlag() bool {
flagL := flag.Bool("l", false, "use localized applications' names")
flag.Parse()
return *flagL
}
// RunUI runs ui
func RunUI() {
const (
height = float32(20*30 + 28)
width = float32(1600 / 3)
name = "dot-ui"
)
gofont.Register()
go func() {
w := app.NewWindow(
app.Size(unit.Dp(width), unit.Dp(height)),
app.Title(name),
)
if err := newApp(w).run(); err != nil {
log.Fatal(err)
}
}()
app.Main()
}