/
select_asset_editor.go
65 lines (60 loc) · 1.78 KB
/
select_asset_editor.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 components
import (
"image/color"
"gioui.org/layout"
"gioui.org/unit"
"gioui.org/widget"
"github.com/crypto-power/cryptopower/app"
"github.com/crypto-power/cryptopower/ui/cryptomaterial"
"github.com/crypto-power/cryptopower/ui/load"
"github.com/crypto-power/cryptopower/ui/values"
)
type SelectAssetEditor struct {
*load.Load
Edit cryptomaterial.Editor
AssetTypeSelector *AssetTypeSelector
}
func NewSelectAssetEditor(l *load.Load) *SelectAssetEditor {
sae := &SelectAssetEditor{
Edit: l.Theme.Editor(new(widget.Editor), ""),
Load: l,
AssetTypeSelector: NewAssetTypeSelector(l),
}
sae.Edit.Bordered = false
sae.Edit.SelectionColor = color.NRGBA{}
sae.AssetTypeSelector.DisableBorder()
sae.AssetTypeSelector.SetHint("--")
return sae
}
func (sae SelectAssetEditor) Layout(window app.WindowNavigator, gtx C) D {
width := int(gtx.Metric.PxPerDp * 2.0)
height := int(gtx.Metric.PxPerDp * 31.0)
l := sae.Theme.SeparatorVertical(height, width)
l.Color = sae.Theme.Color.Gray3
bg := sae.Theme.Color.White
if sae.AssetsManager.IsDarkModeOn() {
bg = sae.Theme.Color.Background
}
return cryptomaterial.LinearLayout{
Width: cryptomaterial.MatchParent,
Height: cryptomaterial.WrapContent,
Background: bg,
Alignment: layout.Middle,
Border: cryptomaterial.Border{
Width: values.MarginPadding2,
Color: sae.Theme.Color.Gray2,
Radius: cryptomaterial.Radius(8),
},
}.Layout(gtx,
layout.Rigid(func(gtx C) D {
gtx.Constraints.Max.X = gtx.Dp(values.MarginPadding100)
return sae.AssetTypeSelector.Layout(window, gtx)
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Left: unit.Dp(-3), Right: unit.Dp(5)}.Layout(gtx, l.Layout)
}),
layout.Rigid(func(gtx C) D {
return sae.Edit.Layout(gtx)
}),
)
}