-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (50 loc) · 1001 Bytes
/
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
package main
import (
"flag"
"log"
"os"
page "blazerproxy.org/pages"
"blazerproxy.org/pages/about"
"blazerproxy.org/pages/appbar"
"blazerproxy.org/pages/navdrawer"
"gioui.org/app"
"gioui.org/font/gofont"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/text"
"gioui.org/widget/material"
)
type (
C = layout.Context
D = layout.Dimensions
)
func main() {
flag.Parse()
go func() {
w := new(app.Window)
if err := loop(w); err != nil {
log.Fatal(err)
}
os.Exit(0)
}()
app.Main()
}
func loop(w *app.Window) error {
th := material.NewTheme()
th.Shaper = text.NewShaper(text.WithCollection(gofont.Collection()))
var ops op.Ops
router := page.NewRouter()
router.Register(0, appbar.New(&router))
router.Register(1, navdrawer.New(&router))
router.Register(2, about.New(&router))
for {
switch e := w.Event().(type) {
case app.DestroyEvent:
return e.Err
case app.FrameEvent:
gtx := app.NewContext(&ops, e)
router.Layout(gtx, th)
e.Frame(gtx.Ops)
}
}
}