-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnav.go
65 lines (60 loc) · 1.65 KB
/
nav.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
package ux
import (
"image"
"image/color"
"gioui.org/layout"
"gioui.org/op/clip"
"gioui.org/op/paint"
"gioui.org/unit"
"gioui.org/widget/material"
"gioui.org/x/component"
)
func Nav(gtx layout.Context) layout.Dimensions {
var visibilityAnimation component.VisibilityAnimation
nav := component.NewNav("Hello", "--subtitle")
nav.AddNavItem(component.NavItem{
Name: "aaaaaaaaa",
Icon: PlusIcon,
})
nav.AddNavItem(component.NavItem{
Name: "bbbb",
Icon: PlusIcon,
})
nav.AddNavItem(component.NavItem{
Name: "cccc",
Icon: PlusIcon,
})
resize := component.Resize{
Axis: layout.Horizontal,
Ratio: 0.2,
}
return resize.Layout(gtx,
func(gtx layout.Context) layout.Dimensions {
// return nav.Layout(gtx, th.Material(), &visibilityAnimation)
return nav.LayoutContents(gtx, th.Theme, &visibilityAnimation)
},
func(gtx layout.Context) layout.Dimensions {
return layout.UniformInset(unit.Dp(20)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return material.H6(th.Theme, "Hello").Layout(gtx)
}),
layout.Rigid(layout.Spacer{Height: unit.Dp(10)}.Layout),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return material.Body1(th.Theme, "Subtitle").Layout(gtx)
}),
)
})
},
func(gtx layout.Context) layout.Dimensions {
rect := image.Rectangle{
Max: image.Point{
X: gtx.Dp(unit.Dp(4)),
Y: gtx.Constraints.Max.Y,
},
}
paint.FillShape(gtx.Ops, color.NRGBA{A: 200}, clip.Rect(rect).Op())
return layout.Dimensions{Size: rect.Max}
},
)
}