Skip to content

Commit

Permalink
ui: fix seed backup page display (#185)
Browse files Browse the repository at this point in the history
* fix seed backup page display

Signed-off-by: Philemon Ukane <[email protected]>

* go fmt

Signed-off-by: Philemon Ukane <[email protected]>

* prevent seed backup modal minimize

Signed-off-by: Philemon Ukane <[email protected]>

* rework fix

Signed-off-by: Philemon Ukane <[email protected]>

* go fmt

---------

Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon authored Oct 19, 2023
1 parent 7403c3d commit 380712f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
22 changes: 11 additions & 11 deletions ui/page/info/info_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ type WalletInfo struct {
checkBox cryptomaterial.CheckBoxStyle

isStatusConnected bool
redirectfunc seedbackup.Redirectfunc
}

type progressInfo struct {
Expand All @@ -69,7 +68,7 @@ type progressInfo struct {
// status progress percentage.
var syncProgressInfo = map[sharedW.Asset]progressInfo{}

func NewInfoPage(l *load.Load, redirect seedbackup.Redirectfunc) *WalletInfo {
func NewInfoPage(l *load.Load) *WalletInfo {
pg := &WalletInfo{
Load: l,
GenericPageModal: app.NewGenericPageModal(InfoID),
Expand All @@ -83,8 +82,6 @@ func NewInfoPage(l *load.Load, redirect seedbackup.Redirectfunc) *WalletInfo {
pg.toBackup.Font.Weight = font.Medium
pg.toBackup.TextSize = values.TextSize14

pg.redirectfunc = redirect

go func() {
pg.isStatusConnected = libutils.IsOnline()
}()
Expand Down Expand Up @@ -186,16 +183,19 @@ func (pg *WalletInfo) HandleUserInteractions() {
}

if pg.toBackup.Button.Clicked() {
pg.ParentWindow().Display(seedbackup.NewBackupInstructionsPage(pg.Load, pg.WL.SelectedWallet.Wallet, pg.redirectfunc))
currentPage := pg.ParentWindow().CurrentPageID()
pg.ParentWindow().Display(seedbackup.NewBackupInstructionsPage(pg.Load, pg.WL.SelectedWallet.Wallet, func(load *load.Load, navigator app.WindowNavigator) {
navigator.ClosePagesAfter(currentPage)
}))
}
}

// listenForNotifications starts a goroutine to watch for sync updates
// and update the UI accordingly. To prevent UI lags, this method does not
// refresh the window display everytime a sync update is received. During
// active blocks sync, rescan or proposals sync, the Layout method auto
// refreshes the display every set interval. Other sync updates that affect
// the UI but occur outside of an active sync requires a display refresh.
// listenForNotifications starts a goroutine to watch for sync updates and
// update the UI accordingly. To prevent UI lags, this method does not refresh
// the window display every time a sync update is received. During active blocks
// sync, rescan or proposals sync, the Layout method auto refreshes the display
// every set interval. Other sync updates that affect the UI but occur outside
// of an active sync requires a display refresh.
func (pg *WalletInfo) listenForNotifications() {
switch {
case pg.SyncProgressListener != nil:
Expand Down
17 changes: 8 additions & 9 deletions ui/page/root/main_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (mp *MainPage) OnNavigatedTo() {
}

if mp.CurrentPage() == nil {
mp.Display(info.NewInfoPage(mp.Load, redirect)) // TODO: Should pagestack have a start page?
mp.Display(info.NewInfoPage(mp.Load)) // TODO: Should pagestack have a start page?
}

mp.listenForNotifications() // start sync notifications listening.
Expand Down Expand Up @@ -445,7 +445,7 @@ func (mp *MainPage) HandleUserInteractions() {
case ReceivePageID:
pg = NewReceivePage(mp.Load)
case info.InfoID:
pg = info.NewInfoPage(mp.Load, redirect)
pg = info.NewInfoPage(mp.Load)
case transaction.TransactionsPageID:
pg = transaction.NewTransactionsPage(mp.Load)
case privacy.AccountMixerPageID:
Expand Down Expand Up @@ -486,7 +486,7 @@ func (mp *MainPage) HandleUserInteractions() {
case transaction.TransactionsPageID:
pg = transaction.NewTransactionsPage(mp.Load)
case info.InfoID:
pg = info.NewInfoPage(mp.Load, redirect)
pg = info.NewInfoPage(mp.Load)
}

if pg == nil || mp.ID() == mp.CurrentPageID() {
Expand All @@ -505,7 +505,7 @@ func (mp *MainPage) HandleUserInteractions() {
case staking.OverviewPageID:
pg = staking.NewStakingPage(mp.Load)
case info.InfoID:
pg = info.NewInfoPage(mp.Load, redirect)
pg = info.NewInfoPage(mp.Load)
case WalletSettingsPageID:
pg = NewWalletSettingsPage(mp.Load)
}
Expand Down Expand Up @@ -1024,7 +1024,10 @@ func (mp *MainPage) showBackupInfo() {
SetPositiveButtonText(values.String(values.StrBackupNow)).
SetPositiveButtonCallback(func(_ bool, _ *modal.InfoModal) bool {
mp.WL.SelectedWallet.Wallet.SaveUserConfigValue(sharedW.SeedBackupNotificationConfigKey, true)
mp.ParentNavigator().Display(seedbackup.NewBackupInstructionsPage(mp.Load, mp.WL.SelectedWallet.Wallet, redirect))
currentPage := mp.ParentWindow().CurrentPageID()
mp.ParentWindow().Display(seedbackup.NewBackupInstructionsPage(mp.Load, mp.WL.SelectedWallet.Wallet, func(load *load.Load, navigator app.WindowNavigator) {
navigator.ClosePagesAfter(currentPage)
}))
return true
})
mp.ParentWindow().ShowModal(backupNowOrLaterModal)
Expand All @@ -1043,7 +1046,3 @@ func walletHightlighLabel(theme *cryptomaterial.Theme, gtx C, content string) D
Border: cryptomaterial.Border{Radius: cryptomaterial.Radius(9), Color: theme.Color.Gray3, Width: values.MarginPadding1},
}.Layout2(gtx, indexLabel.Layout)
}

func redirect(l *load.Load, pg app.WindowNavigator) {
pg.Display(NewWalletSelectorPage(l))
}
6 changes: 3 additions & 3 deletions ui/page/seedbackup/backup_instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ func (pg *BackupInstructionsPage) HandleUserInteractions() {
}
}

func promptToExit(load *load.Load, pageNavigator app.PageNavigator, window app.WindowNavigator) {
func promptToExit(load *load.Load, window app.WindowNavigator, redirect Redirectfunc) {
infoModal := modal.NewCustomModal(load).
Title(values.String(values.StrExit) + "?").
Body(values.String(values.StrSureToExitBackup)).
SetNegativeButtonText(values.String(values.StrNo)).
SetPositiveButtonText(values.String(values.StrYes)).
SetPositiveButtonCallback(func(_ bool, _ *modal.InfoModal) bool {
pageNavigator.ClosePagesAfter("Main")
redirect(load, window)
return true
})
window.ShowModal(infoModal)
Expand All @@ -126,7 +126,7 @@ func (pg *BackupInstructionsPage) Layout(gtx layout.Context) layout.Dimensions {
Title: values.String(values.StrKeepInMind),
BackButton: pg.backButton,
Back: func() {
promptToExit(pg.Load, pg.ParentNavigator(), pg.ParentWindow())
promptToExit(pg.Load, pg.ParentWindow(), pg.redirectCallback)
},
Body: func(gtx C) D {
return pg.infoList.Layout(gtx, len(pg.checkBoxes), func(gtx C, i int) D {
Expand Down
9 changes: 5 additions & 4 deletions ui/page/seedbackup/save_seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ func (pg *SaveSeedPage) OnNavigatedTo() {
return true
}).
SetNegativeButtonCallback(func() {
pg.ParentNavigator().ClosePagesAfter("Main")
})
pg.redirectCallback(pg.Load, pg.ParentWindow())
}).
SetCancelable(false)
pg.ParentWindow().ShowModal(passwordModal)
}

Expand Down Expand Up @@ -194,7 +195,7 @@ func (pg *SaveSeedPage) layoutDesktop(gtx C) D {
SubTitle: values.String(values.StrStep1),
BackButton: pg.backButton,
Back: func() {
promptToExit(pg.Load, pg.ParentNavigator(), pg.ParentWindow())
promptToExit(pg.Load, pg.ParentWindow(), pg.redirectCallback)
},
Body: func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
Expand Down Expand Up @@ -242,7 +243,7 @@ func (pg *SaveSeedPage) layoutMobile(gtx C) D {
SubTitle: values.String(values.StrStep1),
BackButton: pg.backButton,
Back: func() {
promptToExit(pg.Load, pg.ParentNavigator(), pg.ParentWindow())
promptToExit(pg.Load, pg.ParentWindow(), pg.redirectCallback)
},
Body: func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
Expand Down
4 changes: 2 additions & 2 deletions ui/page/seedbackup/verify_seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (pg *VerifySeedPage) layoutDesktop(gtx layout.Context) layout.Dimensions {
SubTitle: values.String(values.StrStep2of2),
BackButton: pg.backButton,
Back: func() {
promptToExit(pg.Load, pg.ParentNavigator(), pg.ParentWindow())
promptToExit(pg.Load, pg.ParentWindow(), pg.redirectCallback)
},
Body: func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
Expand Down Expand Up @@ -360,7 +360,7 @@ func (pg *VerifySeedPage) layoutMobile(gtx layout.Context) layout.Dimensions {
SubTitle: values.String(values.StrStep2of2),
BackButton: pg.backButton,
Back: func() {
promptToExit(pg.Load, pg.ParentNavigator(), pg.ParentWindow())
promptToExit(pg.Load, pg.ParentWindow(), pg.redirectCallback)
},
Body: func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
Expand Down

0 comments on commit 380712f

Please sign in to comment.