-
Notifications
You must be signed in to change notification settings - Fork 0
/
discloser.go
78 lines (72 loc) · 1.67 KB
/
discloser.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
package main
import (
"image"
"os"
"gioui.org/app"
"gioui.org/font/gofont"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/unit"
"gioui.org/widget/material"
"gioui.org/x/component"
)
// App Bar looks not so powerfull at present
type App struct {
theme *material.Theme
anim *component.VisibilityAnimation
item1 *int
}
func main() {
th := material.NewTheme(gofont.Collection())
item1 := 1
giomApp := App{
theme: th,
anim: &component.VisibilityAnimation{},
item1: &item1,
}
go func() {
window := app.NewWindow(app.Title("Protonet"))
window.Option(
func(m unit.Metric, c *app.Config) {
c.MaxSize = image.Point{
X: m.Dp(320),
Y: m.Dp(640),
}
},
)
if err := Loop(window, &giomApp); err != nil {
panic(err)
}
os.Exit(0)
}()
app.Main()
}
func Loop(w *app.Window, app *App) error {
// theme := material.NewTheme(gofont.Collection())
// backClickTag is meant for tracking user's backClick action, specially on mobile
var ops op.Ops
for e := range w.Events() {
switch e := e.(type) {
case system.DestroyEvent:
return e.Err
case system.FrameEvent:
gtx := layout.NewContext(&ops, e)
draw(gtx, app)
e.Frame(gtx.Ops)
}
}
return nil
}
func draw(gtx layout.Context, app *App) {
layout.Flex{}.Layout(gtx, layout.Flexed(1, func(gtx layout.Context) layout.Dimensions {
theme := app.theme
ds := component.Discloser(theme, &component.DiscloserState{})
dim := ds.Layout(gtx,
component.DiscloserArrow(theme, ds).Layout,
material.H2(theme, "h2").Layout,
material.Body1(theme, "detail").Layout,
)
return dim
}))
}