forked from planetdecred/godcr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
help_page.go
91 lines (78 loc) · 2.38 KB
/
help_page.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
90
91
package ui
import (
"image"
"gioui.org/layout"
"gioui.org/widget"
"github.com/planetdecred/godcr/ui/decredmaterial"
"github.com/planetdecred/godcr/ui/values"
)
const PageHelp = "Help"
type helpPage struct {
theme *decredmaterial.Theme
documentation *widget.Clickable
common *pageCommon
}
func HelpPage(common *pageCommon) Page {
pg := &helpPage{
theme: common.theme,
documentation: new(widget.Clickable),
common: common,
}
return pg
}
func (pg *helpPage) OnResume() {
}
// main settings layout
func (pg *helpPage) Layout(gtx layout.Context) layout.Dimensions {
body := func(gtx C) D {
page := SubPage{
title: "Help",
subTitle: "For more information, please visit the Decred documentation.",
back: func() {
pg.common.changePage(PageMore)
},
body: func(gtx C) D {
return layout.Inset{Top: values.MarginPadding5}.Layout(gtx, func(gtx C) D {
return layout.Flex{Spacing: layout.SpaceBetween, WeightSum: 2}.Layout(gtx,
layout.Flexed(1, pg.document(pg.common)),
)
})
},
}
return pg.common.SubPageLayout(gtx, page)
}
return pg.common.UniformPadding(gtx, body)
}
func (pg *helpPage) document(common *pageCommon) layout.Widget {
return func(gtx C) D {
return pg.pageSections(gtx, common.icons.documentationIcon, pg.documentation, func(gtx C) D {
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
layout.Rigid(common.theme.Body1("Documentation").Layout),
)
})
}
}
func (pg *helpPage) pageSections(gtx layout.Context, icon *widget.Image, action *widget.Clickable, body layout.Widget) layout.Dimensions {
return layout.Inset{Bottom: values.MarginPadding10}.Layout(gtx, func(gtx C) D {
return pg.theme.Card().Layout(gtx, func(gtx C) D {
return decredmaterial.Clickable(gtx, action, func(gtx C) D {
return layout.UniformInset(values.MarginPadding15).Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle, Spacing: layout.SpaceAround}.Layout(gtx,
layout.Rigid(func(gtx C) D {
icon := icon
icon.Scale = 1
return icon.Layout(gtx)
}),
layout.Rigid(body),
layout.Rigid(func(gtx C) D {
size := image.Point{X: gtx.Constraints.Max.X, Y: gtx.Constraints.Min.Y}
return layout.Dimensions{Size: size}
}),
)
})
})
})
})
}
func (pg *helpPage) handle() {}
func (pg *helpPage) onClose() {}