Skip to content

Commit

Permalink
change method change page in security tool
Browse files Browse the repository at this point in the history
refactor code in security tool

fix conflict
  • Loading branch information
JustinBeBoy committed Feb 26, 2021
1 parent 5426962 commit 3409bd0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
23 changes: 5 additions & 18 deletions ui/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ type pageIcons struct {
pendingIcon, logo, redirectIcon, confirmIcon, newWalletIcon, walletAlertIcon,
importedAccountIcon, accountIcon, editIcon, expandIcon, collapseIcon, copyIcon, mixer,
arrowFowardIcon, transactionFingerPrintIcon, settingsIcon, securityIcon, helpIcon,
<<<<<<< HEAD
aboutIcon, debugIcon, alert, verifyMessageIcon, locationPinIcon, alertGray, arrowDownIcon *widget.Image
=======
aboutIcon, debugIcon, alert, verifyMessageIcon, locationPinIcon, checkMarkGreenIcon, crossMarkRed *widget.Image
>>>>>>> Create layout and logic for validate address page
aboutIcon, debugIcon, alert, verifyMessageIcon, locationPinIcon, alertGray, arrowDownIcon,
checkMarkGreenIcon, crossMarkRed *widget.Image

walletIcon, syncingIcon image.Image
}
Expand Down Expand Up @@ -83,8 +80,8 @@ type pageCommon struct {
subPageBackButton decredmaterial.IconButton
subPageInfoButton decredmaterial.IconButton

changePage func(string)
pushNavigationPage func(string)
changePage func(string)
setReturnPage func(string)
}

type (
Expand Down Expand Up @@ -250,7 +247,7 @@ func (win *Window) addPages(decredIcons map[string]image.Image) {
subPageBackButton: win.theme.PlainIconButton(new(widget.Clickable), ic.navigationArrowBack),
subPageInfoButton: win.theme.PlainIconButton(new(widget.Clickable), ic.actionInfo),
changePage: win.changePage,
pushNavigationPage: win.pushNavigationPage,
setReturnPage: win.setReturnPage,
}

common.testButton = win.theme.Button(new(widget.Clickable), "test button")
Expand Down Expand Up @@ -296,16 +293,6 @@ func (page pageCommon) ChangePage(pg string) {
page.changePage(pg)
}

func (page pageCommon) PushNavigationPage(from, to string) {
page.returnPage = &from
page.pushNavigationPage(from)
page.changePage(to)
}

func (page pageCommon) PopNavigationPage() {
page.changePage(*page.returnPage)
}

func (page pageCommon) Notify(text string, success bool) {
go func() {
page.toast <- &toast{
Expand Down
8 changes: 6 additions & 2 deletions ui/security_tools_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ func (pg *securityToolsPage) pageSections(gtx layout.Context, icon *widget.Image

func (pg *securityToolsPage) handle(common pageCommon) {
if pg.verifyMessage.Clicked() {
common.PushNavigationPage(PageSecurityTools, PageVerifyMessage)
*common.returnPage = PageSecurityTools
common.setReturnPage(PageSecurityTools)
common.changePage(PageVerifyMessage)
}

if pg.validateAddress.Clicked() {
common.PushNavigationPage(PageSecurityTools, ValidateAddress)
*common.returnPage = PageSecurityTools
common.setReturnPage(PageSecurityTools)
common.changePage(ValidateAddress)
}
}
12 changes: 6 additions & 6 deletions ui/validate_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
"github.com/planetdecred/godcr/wallet"
)

const ValidateAddress = "Validate Address"
const ValidateAddress = "ValidateAddress"

const (
none = 0
valid = 1
invalid = 2
notOwned = 3
none = iota
valid
invalid
notOwned
)

type validateAddressPage struct {
Expand Down Expand Up @@ -68,7 +68,7 @@ func (pg *validateAddressPage) Layout(gtx layout.Context, common pageCommon) lay
page := SubPage{
title: ValidateAddress,
back: func() {
common.PopNavigationPage()
common.changePage(*common.returnPage)
},
body: func(gtx C) D {
return layout.Inset{Top: values.MarginPadding5}.Layout(gtx, func(gtx C) D {
Expand Down
8 changes: 6 additions & 2 deletions ui/verify_message_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ func (win *Window) VerifyMessagePage(c pageCommon) layout.Widget {
}

func (pg *verifyMessagePage) Layout(gtx layout.Context, c pageCommon) layout.Dimensions {
var walletName = c.info.Wallets[*c.selectedWallet].Name
if *c.returnPage == PageSecurityTools {
walletName = ""
}
body := func(gtx C) D {
load := SubPage{
title: "Verify message",
walletName: c.info.Wallets[*c.selectedWallet].Name,
walletName: walletName,
back: func() {
pg.clearInputs(&c)
c.PopNavigationPage()
c.changePage(*c.returnPage)
},
body: func(gtx layout.Context) layout.Dimensions {
return pg.theme.Card().Layout(gtx, func(gtx C) D {
Expand Down
4 changes: 3 additions & 1 deletion ui/wallet_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,9 @@ func (pg *walletPage) Handle(common pageCommon) {
if pg.optionsMenuItems[index].button.Clicked() {
pg.openPopupIndex = -1
if index == 1 {
common.PushNavigationPage(PageWallet, PageVerifyMessage)
*common.returnPage = PageWallet
common.setReturnPage(PageWallet)
common.changePage(PageVerifyMessage)
}
common.ChangePage(pg.optionsMenuItems[index].page)
}
Expand Down
2 changes: 1 addition & 1 deletion ui/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (win *Window) changePage(page string) {
win.window.Invalidate()
}

func (win *Window) pushNavigationPage(from string) {
func (win *Window) setReturnPage(from string) {
win.previous = from
win.window.Invalidate()
}
Expand Down

0 comments on commit 3409bd0

Please sign in to comment.