Skip to content

Commit

Permalink
Update receive page (#354)
Browse files Browse the repository at this point in the history
* correct text size and button dimensions
- change generate address button TextSize to 16 and padding vertical 20 DP
- remove unused minInfo button
- change modal cancel button text size to 16

* Add logo into Qr code

* Update account selector
- reduce params walletAccountsPopupLayout
- add fields to walletAccount to display on each row of wallet accounts modal
- pageBackdropLayout layout of background overlay when the popup button generate new address is show,
click outside of the generate new address button to hide the button

* Retry generate new address when generated address is equal to the old one

* Update account selector
- Move on account selector widget to page.go
- Move account selector layouts methods from receive page to component
  • Loading branch information
song50119 authored Apr 15, 2021
1 parent 2fa41c7 commit 4218410
Show file tree
Hide file tree
Showing 10 changed files with 650 additions and 524 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ require (
github.com/onsi/ginkgo v1.14.0
github.com/onsi/gomega v1.10.1
github.com/planetdecred/dcrlibwallet v1.5.3-0.20210224132742-5d0bc5e13370
github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086
github.com/yeqown/go-qrcode v1.5.1
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3
golang.org/x/image v0.0.0-20200618115811-c13761719519
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/text v0.3.3
)
Expand Down
20 changes: 15 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ github.com/DataDog/zstd v1.4.1 h1:3oxKN3wbHibqx897utPC2LTQU4J+IHWWJO+glkAkpFM=
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Sereal/Sereal v0.0.0-20181211220259-509a78ddbda3 h1:Xu7z47ZiE/J+sKXHZMGxEor/oY2q6dq51fkO0JqdSwY=
github.com/Sereal/Sereal v0.0.0-20181211220259-509a78ddbda3/go.mod h1:D0JMgToj/WdxCgd30Kc1UcA9E+WdZoJqeVOuYW7iTBM=
github.com/Sereal/Sereal v0.0.0-20190618215532-0b8ac451a863 h1:BRrxwOZBolJN4gIwvZMJY1tzqBvQgpaZiQRuIDD40jM=
github.com/Sereal/Sereal v0.0.0-20190618215532-0b8ac451a863/go.mod h1:D0JMgToj/WdxCgd30Kc1UcA9E+WdZoJqeVOuYW7iTBM=
Expand Down Expand Up @@ -327,6 +326,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
Expand All @@ -347,6 +348,8 @@ github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
Expand Down Expand Up @@ -505,8 +508,6 @@ github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfm
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086 h1:RYiqpb2ii2Z6J4x0wxK46kvPBbFuZcdhS+CIztmYgZs=
github.com/skip2/go-qrcode v0.0.0-20191027152451-9434209cb086/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
Expand All @@ -521,8 +522,9 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gozaru v0.0.0-20190625071150-416082cce636/go.mod h1:LIpwO1yApZNrEQZdu5REqRtRrkaU+52ueA7WGT+CvSw=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk=
Expand All @@ -535,6 +537,10 @@ github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElyw
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yeqown/go-qrcode v1.5.1 h1:JVt8nVcaLHgvimGPjRviUJ7VpxB1nz7Yn8hh5mZYwl8=
github.com/yeqown/go-qrcode v1.5.1/go.mod h1:C1eAU4Jure3vqD56kqzeSLaX84MHg3fZAMNID4nXX+Y=
github.com/yeqown/reedsolomon v1.0.0 h1:x1h/Ej/uJnNu8jaX7GLHBWmZKCAWjEJTetkqaabr4B0=
github.com/yeqown/reedsolomon v1.0.0/go.mod h1:P76zpcn2TCuL0ul1Fso373qHRc69LKwAw/Iy6g1WiiM=
go.etcd.io/bbolt v1.3.0/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
Expand Down Expand Up @@ -565,8 +571,10 @@ golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 h1:n9HxLrNxWWtEb1cA950nuEEj3
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200618115811-c13761719519 h1:1e2ufUJNM3lCHEY5jIgac/7UTjd6cgJNdatjPdFWf34=
golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk=
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -700,6 +708,8 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
Binary file added ui/assets/decredicons/qrcodeSymbol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
207 changes: 207 additions & 0 deletions ui/compontents.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
package ui

import (
"image"

"gioui.org/gesture"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/text"
"gioui.org/unit"
"gioui.org/widget"
"github.com/decred/dcrd/dcrutil"
"github.com/planetdecred/dcrlibwallet"
"github.com/planetdecred/godcr/ui/decredmaterial"
"github.com/planetdecred/godcr/ui/values"
Expand Down Expand Up @@ -336,6 +342,184 @@ func endToEndRow(gtx layout.Context, leftWidget, rightWidget func(C) D) layout.D
)
}

func (page *pageCommon) accountSelectorLayout(gtx layout.Context, title string) layout.Dimensions {
border := widget.Border{
Color: page.theme.Color.Gray1,
CornerRadius: values.MarginPadding8,
Width: values.MarginPadding2,
}
page.wallAcctSelector.title = title

return border.Layout(gtx, func(gtx C) D {
return layout.UniformInset(values.MarginPadding12).Layout(gtx, func(gtx C) D {
return decredmaterial.Clickable(gtx, page.wallAcctSelector.fromAccount, func(gtx C) D {
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
layout.Rigid(func(gtx C) D {
accountIcon := page.icons.accountIcon
accountIcon.Scale = 1
inset := layout.Inset{
Right: values.MarginPadding8,
}
return inset.Layout(gtx, func(gtx C) D {
return accountIcon.Layout(gtx)
})
}),
layout.Rigid(func(gtx C) D {
return page.theme.Body1(
page.info.Wallets[*page.selectedWallet].Accounts[*page.selectedAccount].Name).Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
inset := layout.Inset{
Left: values.MarginPadding4,
Top: values.MarginPadding2,
}
return inset.Layout(gtx, func(gtx C) D {
return decredmaterial.Card{
Color: page.theme.Color.LightGray,
}.Layout(gtx, func(gtx C) D {
m2 := values.MarginPadding2
m4 := values.MarginPadding4
inset := layout.Inset{
Left: m4,
Top: m2,
Bottom: m2,
Right: m4,
}
return inset.Layout(gtx, func(gtx C) D {
text := page.theme.Caption(page.info.Wallets[*page.selectedWallet].Name)
text.Color = page.theme.Color.Gray
return text.Layout(gtx)
})
})
})
}),
layout.Flexed(1, func(gtx C) D {
return layout.E.Layout(gtx, func(gtx C) D {
return layout.Flex{}.Layout(gtx,
layout.Rigid(func(gtx C) D {
txt := page.theme.Body1(
page.info.Wallets[*page.selectedWallet].Accounts[*page.selectedAccount].TotalBalance)
txt.Color = page.theme.Color.DeepBlue
return txt.Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
inset := layout.Inset{
Left: values.MarginPadding15,
}
return inset.Layout(gtx, func(gtx C) D {
return page.icons.dropDownIcon.Layout(gtx, values.MarginPadding20)
})
}),
)
})
}),
)
})
})
})
}

func (page *pageCommon) walletAccountModalLayout(gtx layout.Context) layout.Dimensions {
wallAcctGroup := func(gtx layout.Context, title string, body layout.Widget) layout.Dimensions {
return layout.Inset{
Bottom: values.MarginPadding10,
}.Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
txt := page.theme.Body2(title)
txt.Color = page.theme.Color.Text
inset := layout.Inset{
Bottom: values.MarginPadding15,
}
return inset.Layout(gtx, txt.Layout)
}),
layout.Rigid(body),
)
})
}
wallAcctSelector := page.wallAcctSelector
w := []func(gtx C) D{
func(gtx C) D {
tit := page.theme.Label(values.TextSize24, wallAcctSelector.title)
tit.Color = page.theme.Color.Text
return tit.Layout(gtx)
},
func(gtx C) D {
return wallAcctSelector.walletsList.Layout(gtx, len(page.info.Wallets), func(gtx C, windex int) D {
return wallAcctGroup(gtx, page.info.Wallets[windex].Name, func(gtx C) D {
return wallAcctSelector.accountsList.Layout(gtx, len(page.info.Wallets[windex].Accounts), func(gtx C, aindex int) D {
click := wallAcctSelector.walletAccounts[windex][aindex].evt
pointer.Rect(image.Rectangle{Max: gtx.Constraints.Max}).Add(gtx.Ops)
click.Add(gtx.Ops)
page.walletAccountsHandler(gtx, wallAcctSelector.walletAccounts[windex][aindex])
return page.walletAccountLayout(gtx, wallAcctSelector.walletAccounts[windex][aindex])
})
})
})
},
}

return wallAcctSelector.walletAccount.Layout(gtx, w, 850)
}

func (page *pageCommon) walletAccountsHandler(gtx layout.Context, wallAcct walletAccount) {
for _, e := range wallAcct.evt.Events(gtx) {
if e.Type == gesture.TypeClick {
*page.selectedWallet = wallAcct.walletIndex
*page.selectedAccount = wallAcct.accountIndex
page.wallAcctSelector.isWalletAccountModalOpen = false
}
}
}

func (page *pageCommon) walletAccountLayout(gtx layout.Context, wallAcct walletAccount) layout.Dimensions {
accountIcon := page.icons.accountIcon
accountIcon.Scale = 1
return layout.Inset{
Bottom: values.MarginPadding20,
}.Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Flexed(0.1, func(gtx C) D {
return layout.Inset{
Right: values.MarginPadding18,
}.Layout(gtx, func(gtx C) D {
return accountIcon.Layout(gtx)
})
}),
layout.Flexed(0.8, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
acct := page.theme.Label(values.TextSize18, wallAcct.accountName)
acct.Color = page.theme.Color.Text
return endToEndRow(gtx, acct.Layout, func(gtx C) D {
return page.layoutBalance(gtx, wallAcct.totalBalance)
})
}),
layout.Rigid(func(gtx C) D {
spendable := page.theme.Label(values.TextSize14, "Spendable")
spendable.Color = page.theme.Color.Gray
spendableBal := page.theme.Label(values.TextSize14, wallAcct.spendable)
spendableBal.Color = page.theme.Color.Gray
return endToEndRow(gtx, spendable.Layout, spendableBal.Layout)
}),
)
}),
layout.Flexed(0.1, func(gtx C) D {
if *page.selectedWallet == wallAcct.walletIndex && *page.selectedAccount == wallAcct.accountIndex {
return layout.E.Layout(gtx, func(gtx C) D {
return page.icons.navigationCheck.Layout(gtx, values.MarginPadding20)
})
}
return layout.Dimensions{}
}),
)
}),
)
})
}

func (page pageCommon) handleNavEvents() {
for page.minimizeNavDrawerButton.Button.Clicked() {
*page.isNavDrawerMinimized = true
Expand All @@ -356,4 +540,27 @@ func (page pageCommon) handleNavEvents() {
page.changePage(page.drawerNavItems[i].page)
}
}

for windex := 0; windex < page.info.LoadedWallets; windex++ {
if _, ok := page.wallAcctSelector.walletAccounts[windex]; !ok {
accounts := page.info.Wallets[windex].Accounts
if len(accounts) != len(page.wallAcctSelector.walletAccounts[windex]) {
page.wallAcctSelector.walletAccounts[windex] = make([]walletAccount, len(accounts))
for aindex := range accounts {
page.wallAcctSelector.walletAccounts[windex][aindex] = walletAccount{
walletIndex: windex,
accountIndex: aindex,
evt: &gesture.Click{},
accountName: accounts[aindex].Name,
totalBalance: accounts[aindex].TotalBalance,
spendable: dcrutil.Amount(accounts[aindex].SpendableBalance).String(),
}
}
}
}
}

if page.wallAcctSelector.fromAccount.Clicked() {
page.wallAcctSelector.isWalletAccountModalOpen = true
}
}
26 changes: 24 additions & 2 deletions ui/modal_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ui

import (
"gioui.org/layout"
"gioui.org/text"
"gioui.org/unit"
"gioui.org/widget"

Expand Down Expand Up @@ -35,6 +36,7 @@ const SecurityToolsInfoTemplate = "SecurityToolsInfo"
const ImportWatchOnlyWalletTemplate = "ImportWatchOnlyWallet"
const UnlockWalletRestoreTemplate = "UnlockWalletRestoreTemplate"
const SendInfoTemplate = "SendInfo"
const ReceiveInfoTemplate = "ReceiveInfo"

type ModalTemplate struct {
th *decredmaterial.Theme
Expand All @@ -60,10 +62,12 @@ type modalLoad struct {
}

func (win *Window) LoadModalTemplates() *ModalTemplate {
cancel := win.theme.Button(new(widget.Clickable), "Cancel")
cancel.TextSize = values.TextSize16
return &ModalTemplate{
th: win.theme,
confirm: win.theme.Button(new(widget.Clickable), "Confirm"),
cancel: win.theme.Button(new(widget.Clickable), "Cancel"),
cancel: cancel,
walletName: win.theme.Editor(new(widget.Editor), ""),
oldSpendingPassword: win.theme.EditorPassword(new(widget.Editor), "Old spending password"),
spendingPassword: win.theme.EditorPassword(new(widget.Editor), "Spending password"),
Expand Down Expand Up @@ -264,6 +268,16 @@ func (m *ModalTemplate) sendInfo() []func(gtx C) D {
}
}

func (m *ModalTemplate) receiveInfo() []func(gtx C) D {
return []func(gtx C) D{
func(gtx C) D {
text := m.th.Label(values.TextSize20, "Each time you receive a payment, a new address is generated to protect your privacy.")
text.Color = m.th.Color.Gray
return text.Layout(gtx)
},
}
}

func (m *ModalTemplate) privacyInfo() []func(gtx C) D {
return []func(gtx C) D{
func(gtx C) D {
Expand Down Expand Up @@ -371,7 +385,9 @@ func (m *ModalTemplate) Layout(th *decredmaterial.Theme, load *modalLoad) []func

title := []func(gtx C) D{
func(gtx C) D {
return th.H5(load.title).Layout(gtx)
t := th.H5(load.title)
t.Font.Weight = text.Bold
return t.Layout(gtx)
},
}

Expand Down Expand Up @@ -596,6 +612,12 @@ func (m *ModalTemplate) handle(th *decredmaterial.Theme, load *modalLoad) (templ
}
template = m.sendInfo()
return
case ReceiveInfoTemplate:
if m.cancel.Button.Clicked() {
load.cancel.(func())()
}
template = m.receiveInfo()
return
default:
return
}
Expand Down
Loading

0 comments on commit 4218410

Please sign in to comment.