-
Notifications
You must be signed in to change notification settings - Fork 5
/
identity-form.go
93 lines (79 loc) · 2.59 KB
/
identity-form.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
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"
sprigWidget "git.sr.ht/~whereswaldon/sprig/widget"
)
type IdentityFormView struct {
manager ViewManager
sprigWidget.TextForm
CreateButton widget.Clickable
core.App
}
var _ View = &IdentityFormView{}
func NewIdentityFormView(app core.App) View {
c := &IdentityFormView{
App: app,
}
c.TextForm.TextField.Editor.SingleLine = true
return c
}
func (c *IdentityFormView) HandleIntent(intent Intent) {}
func (c *IdentityFormView) BecomeVisible() {
}
func (c *IdentityFormView) NavItem() *materials.NavItem {
return nil
}
func (c *IdentityFormView) AppBarData() (bool, string, []materials.AppBarAction, []materials.OverflowAction) {
return false, "", nil, nil
}
func (c *IdentityFormView) HandleClipboard(contents string) {
}
func (c *IdentityFormView) Update(gtx layout.Context) {
if c.CreateButton.Clicked(gtx) {
c.Settings().CreateIdentity(c.TextField.Text())
c.manager.RequestViewSwitch(SubscriptionSetupFormViewID)
}
}
func (c *IdentityFormView) Layout(gtx layout.Context) layout.Dimensions {
theme := c.Theme().Current().Theme
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.Body1(theme, "Your Arbor Username:").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, func(gtx C) D {
return c.TextField.Layout(gtx, theme, "Username")
})
})
}),
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.Body2(theme, "Your username is public, and cannot currently be changed once it is chosen.").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.Button(theme, &(c.CreateButton), "Create").Layout,
)
})
}),
)
})
}
func (c *IdentityFormView) SetManager(mgr ViewManager) {
c.manager = mgr
}