-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconsent-view.go
102 lines (87 loc) · 2.86 KB
/
consent-view.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
package main
import (
"gioui.org/layout"
"gioui.org/unit"
"gioui.org/widget"
"gioui.org/widget/material"
materials "gioui.org/x/component"
"git.sr.ht/~whereswaldon/sprig/core"
)
type ConsentView struct {
manager ViewManager
AgreeButton widget.Clickable
core.App
}
var _ View = &ConsentView{}
func NewConsentView(app core.App) View {
c := &ConsentView{
App: app,
}
return c
}
func (c *ConsentView) HandleIntent(intent Intent) {}
func (c *ConsentView) BecomeVisible() {
}
func (c *ConsentView) NavItem() *materials.NavItem {
return nil
}
func (c *ConsentView) AppBarData() (bool, string, []materials.AppBarAction, []materials.OverflowAction) {
return false, "", nil, nil
}
func (c *ConsentView) Update(gtx layout.Context) {
if c.AgreeButton.Clicked(gtx) {
c.Settings().SetAcknowledgedNoticeVersion(NoticeVersion)
go c.Settings().Persist()
if c.Settings().Address() == "" {
c.manager.RequestViewSwitch(ConnectFormID)
} else {
c.manager.RequestViewSwitch(SettingsID)
}
}
}
const (
UpdateText = "You are seeing this message because the notice text has changed since you last accepted it."
Notice = "This is a chat client for the Arbor Chat Project. Before you send a message, you should know that your messages cannot be edited or deleted once sent, and that they will be publically visible to all other Arbor users."
NoticeVersion = 1
)
func (c *ConsentView) Layout(gtx layout.Context) layout.Dimensions {
theme := c.Theme().Current()
return layout.Center.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 layout.Center.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.UniformInset(unit.Dp(4)).Layout(gtx,
material.H2(theme.Theme, "Notice").Layout,
)
})
}),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return layout.Center.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.UniformInset(unit.Dp(4)).Layout(gtx,
material.Body1(theme.Theme, Notice).Layout,
)
})
}),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
if c.Settings().AcknowledgedNoticeVersion() != 0 {
return layout.Center.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.UniformInset(unit.Dp(4)).Layout(gtx,
material.Body2(theme.Theme, UpdateText).Layout,
)
})
}
return layout.Dimensions{}
}),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return layout.Center.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.UniformInset(unit.Dp(4)).Layout(gtx,
material.Button(theme.Theme, &(c.AgreeButton), "I Understand And Agree").Layout,
)
})
}),
)
})
}
func (c *ConsentView) SetManager(mgr ViewManager) {
c.manager = mgr
}