forked from planetdecred/godcr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
about_page.go
122 lines (106 loc) · 3.11 KB
/
about_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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package ui
import (
"gioui.org/layout"
"gioui.org/widget"
"github.com/planetdecred/godcr/ui/decredmaterial"
"github.com/planetdecred/godcr/ui/values"
)
const PageAbout = "About"
type aboutPage struct {
common *pageCommon
theme *decredmaterial.Theme
card decredmaterial.Card
container *layout.List
version decredmaterial.Label
versionValue decredmaterial.Label
buildDate decredmaterial.Label
buildDateValue decredmaterial.Label
network decredmaterial.Label
networkValue decredmaterial.Label
license decredmaterial.Label
chevronRightIcon *widget.Icon
}
func AboutPage(common *pageCommon) Page {
pg := &aboutPage{
common: common,
theme: common.theme,
card: common.theme.Card(),
container: &layout.List{Axis: layout.Vertical},
version: common.theme.Body1("Version"),
versionValue: common.theme.Body1("v1.5.2"),
buildDate: common.theme.Body1("Build date"),
buildDateValue: common.theme.Body1("2020-09-10"),
network: common.theme.Body1("Network"),
networkValue: common.theme.Body1(common.wallet.Net),
license: common.theme.Body1("License"),
chevronRightIcon: common.icons.chevronRight,
}
pg.versionValue.Color = pg.theme.Color.Gray
pg.buildDateValue.Color = pg.theme.Color.Gray
pg.networkValue.Color = pg.theme.Color.Gray
pg.chevronRightIcon.Color = pg.theme.Color.Gray
return pg
}
func (pg *aboutPage) OnResume() {
}
func (pg *aboutPage) Layout(gtx layout.Context) layout.Dimensions {
body := func(gtx C) D {
page := SubPage{
title: "About",
back: func() {
pg.common.changePage(PageMore)
},
body: func(gtx C) D {
return pg.card.Layout(gtx, func(gtx C) D {
return pg.layoutRows(gtx)
})
},
}
return pg.common.SubPageLayout(gtx, page)
}
return pg.common.UniformPadding(gtx, body)
}
func (pg *aboutPage) layoutRows(gtx layout.Context) layout.Dimensions {
w := []func(gtx C) D{
func(gtx C) D {
return endToEndRow(gtx, pg.version.Layout, pg.versionValue.Layout)
},
func(gtx C) D {
return endToEndRow(gtx, pg.buildDate.Layout, pg.buildDateValue.Layout)
},
func(gtx C) D {
return endToEndRow(gtx, pg.network.Layout, pg.networkValue.Layout)
},
func(gtx C) D {
return endToEndRow(gtx, pg.license.Layout, func(gtx C) D {
return pg.chevronRightIcon.Layout(gtx, values.MarginPadding20)
})
},
}
return pg.container.Layout(gtx, len(w), func(gtx C, i int) D {
return layout.Inset{}.Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return Container{
layout.Inset{
Top: values.MarginPadding20,
Bottom: values.MarginPadding20,
Left: values.MarginPadding16,
Right: values.MarginPadding16,
},
}.Layout(gtx, w[i])
}),
layout.Rigid(func(gtx C) D {
if i == len(w)-1 {
return layout.Dimensions{}
}
return layout.Inset{
Left: values.MarginPadding16,
}.Layout(gtx, pg.theme.Separator().Layout)
}),
)
})
})
}
func (pg *aboutPage) handle() {}
func (pg *aboutPage) onClose() {}