Skip to content

Commit

Permalink
fixed a bug where some pages were not scrollable (#677)
Browse files Browse the repository at this point in the history
* make security tools page scrollable

* make manual mixer page scrollable

* scroll to selected tab on the single wallet main page

* rename stakeshuffle to privacy

* fix hide button in the wallets page
  • Loading branch information
dreacot authored Oct 1, 2024
1 parent 8f9e5f5 commit db5dc54
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 58 deletions.
7 changes: 7 additions & 0 deletions ui/cryptomaterial/segmented_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (t *Theme) SegmentedControl(segmentTitles []string, segmentType SegmentType
sc.slideActionTitle.Draged(func(dragDirection SwipeDirection) {
isNext := dragDirection == SwipeRight
sc.handleActionEvent(isNext)
sc.list.ScrollTo(sc.selectedIndex)
})

return sc
Expand Down Expand Up @@ -452,3 +453,9 @@ func (sc *SegmentedControl) handleActionEvent(isNext bool) {
}
sc.changed = true
}

func (sc *SegmentedControl) ScrollTo(index int) {
sc.mu.Lock()
defer sc.mu.Unlock()
sc.list.ScrollTo(index)
}
80 changes: 46 additions & 34 deletions ui/page/privacy/manual_mixer_setup_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package privacy

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

"github.com/crypto-power/cryptopower/app"
"github.com/crypto-power/cryptopower/libwallet/assets/dcr"
Expand Down Expand Up @@ -32,6 +33,8 @@ type ManualMixerSetupPage struct {
toPrivacySetup cryptomaterial.Button
backIcon *cryptomaterial.Icon

pageContainer *widget.List

dcrWallet *dcr.Asset
}

Expand All @@ -41,6 +44,9 @@ func NewManualMixerSetupPage(l *load.Load, dcrWallet *dcr.Asset) *ManualMixerSet
GenericPageModal: app.NewGenericPageModal(ManualMixerSetupPageID),
toPrivacySetup: l.Theme.Button(values.String(values.StrSetUp)),
dcrWallet: dcrWallet,
pageContainer: &widget.List{
List: layout.List{Axis: layout.Vertical},
},
}
pg.backClickable = pg.Theme.NewClickable(true)
pg.backIcon = cryptomaterial.NewIcon(pg.Theme.Icons.NavigationArrowBack)
Expand Down Expand Up @@ -132,42 +138,48 @@ func (pg *ManualMixerSetupPage) Layout(gtx C) D {
layout.Rigid(pg.backButtonAndPageHeading),
// 24px/16px space (mobile/desktop)
layout.Rigid(func(gtx C) D {
if pg.IsMobileView() {
return layout.Spacer{Height: values.MarginPadding24}.Layout(gtx)
}
return layout.Spacer{Height: values.MarginPadding16}.Layout(gtx)
}),
// "Mixed account" label, 4px space, mixed account dropdown
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: values.MarginPadding16}.Layout(gtx, func(gtx C) D {
return pg.mixedAccountSelector.Layout(gtx, values.String(values.StrMixedAccount))
return pg.Theme.List(pg.pageContainer).Layout(gtx, 1, func(gtx C, _ int) D {
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Start}.Layout(gtx,
layout.Rigid(func(gtx C) D {
if pg.IsMobileView() {
return layout.Spacer{Height: values.MarginPadding24}.Layout(gtx)
}
return layout.Spacer{Height: values.MarginPadding16}.Layout(gtx)
}),
// "Mixed account" label, 4px space, mixed account dropdown
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: values.MarginPadding16}.Layout(gtx, func(gtx C) D {
return pg.mixedAccountSelector.Layout(gtx, values.String(values.StrMixedAccount))
})
}),

// 16px/12px space (mobile/desktop)
layout.Rigid(func(gtx C) D {
if pg.IsMobileView() {
return layout.Spacer{Height: values.MarginPadding16}.Layout(gtx)
}
return layout.Spacer{Height: values.MarginPadding12}.Layout(gtx)
}),
// "Unmixed account" label, 4px space, unmixed account dropdown
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: values.MarginPadding16}.Layout(gtx, func(gtx C) D {
return pg.unmixedAccountSelector.Layout(gtx, values.String(values.StrUnmixedAccount))
})
}),
// 24px space, then warning/caution text
layout.Rigid(layout.Spacer{Height: values.MarginPadding24}.Layout),
layout.Rigid(pg.cautionCard),
// 40px/60px space (mobile/desktop), then "Set up" button.
layout.Rigid(func(gtx C) D {
if pg.IsMobileView() {
return layout.Spacer{Height: values.MarginPadding40}.Layout(gtx)
}
return layout.Spacer{Height: values.MarginPadding60}.Layout(gtx)
}),
layout.Rigid(pg.toPrivacySetup.Layout),
)
})
}),

// 16px/12px space (mobile/desktop)
layout.Rigid(func(gtx C) D {
if pg.IsMobileView() {
return layout.Spacer{Height: values.MarginPadding16}.Layout(gtx)
}
return layout.Spacer{Height: values.MarginPadding12}.Layout(gtx)
}),
// "Unmixed account" label, 4px space, unmixed account dropdown
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: values.MarginPadding16}.Layout(gtx, func(gtx C) D {
return pg.unmixedAccountSelector.Layout(gtx, values.String(values.StrUnmixedAccount))
})
}),
// 24px space, then warning/caution text
layout.Rigid(layout.Spacer{Height: values.MarginPadding24}.Layout),
layout.Rigid(pg.cautionCard),
// 40px/60px space (mobile/desktop), then "Set up" button.
layout.Rigid(func(gtx C) D {
if pg.IsMobileView() {
return layout.Spacer{Height: values.MarginPadding40}.Layout(gtx)
}
return layout.Spacer{Height: values.MarginPadding60}.Layout(gtx)
}),
layout.Rigid(pg.toPrivacySetup.Layout),
)
})
})
Expand Down
25 changes: 16 additions & 9 deletions ui/page/security/sign_message_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type SignMessagePage struct {
clearButton, signButton, copyButton cryptomaterial.Button
copySignature *cryptomaterial.Clickable

pageContainer *widget.List

backButton cryptomaterial.IconButton
infoButton cryptomaterial.IconButton
}
Expand Down Expand Up @@ -86,6 +88,9 @@ func NewSignMessagePage(l *load.Load, wallet sharedW.Asset) *SignMessagePage {
signButton: signButton,
copyButton: l.Theme.Button(values.String(values.StrCopy)),
copySignature: l.Theme.NewClickable(false),
pageContainer: &widget.List{
List: layout.List{Axis: layout.Vertical},
},
}

pg.signedMessageLabel.Color = l.Theme.Color.GrayText2
Expand Down Expand Up @@ -118,15 +123,17 @@ func (pg *SignMessagePage) Layout(gtx C) D {
pg.ParentNavigator().CloseCurrentPage()
},
Body: func(gtx C) D {
return pg.Theme.Card().Layout(gtx, func(gtx C) D {
return layout.UniformInset(values.MarginPadding15).Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(pg.description()),
layout.Rigid(pg.editors(pg.addressEditor)),
layout.Rigid(pg.editors(pg.messageEditor)),
layout.Rigid(pg.drawButtonsRow()),
layout.Rigid(pg.drawResult()),
)
return pg.Theme.List(pg.pageContainer).Layout(gtx, 1, func(gtx C, _ int) D {
return pg.Theme.Card().Layout(gtx, func(gtx C) D {
return layout.UniformInset(values.MarginPadding15).Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(pg.description()),
layout.Rigid(pg.editors(pg.addressEditor)),
layout.Rigid(pg.editors(pg.messageEditor)),
layout.Rigid(pg.drawButtonsRow()),
layout.Rigid(pg.drawResult()),
)
})
})
})
},
Expand Down
14 changes: 10 additions & 4 deletions ui/page/security/validate_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ type ValidateAddressPage struct {
clearBtn, validateBtn cryptomaterial.Button
stateValidate int
backButton cryptomaterial.IconButton
pageContainer *widget.List
}

func NewValidateAddressPage(l *load.Load, wallet sharedW.Asset) *ValidateAddressPage {
pg := &ValidateAddressPage{
Load: l,
GenericPageModal: app.NewGenericPageModal(ValidateAddressPageID),
wallet: wallet,
pageContainer: &widget.List{
List: layout.List{Axis: layout.Vertical},
},
}

pg.backButton = components.GetBackButton(l)
Expand Down Expand Up @@ -86,10 +90,12 @@ func (pg *ValidateAddressPage) Layout(gtx C) D {
pg.ParentNavigator().CloseCurrentPage()
},
Body: func(gtx C) D {
return layout.Inset{Top: values.MarginPadding5}.Layout(gtx, func(gtx C) D {
return layout.Flex{Spacing: layout.SpaceBetween}.Layout(gtx,
layout.Rigid(pg.addressSection()),
)
return pg.Theme.List(pg.pageContainer).Layout(gtx, 1, func(gtx C, _ int) D {
return layout.Inset{Top: values.MarginPadding5}.Layout(gtx, func(gtx C) D {
return layout.Flex{Spacing: layout.SpaceBetween}.Layout(gtx,
layout.Rigid(pg.addressSection()),
)
})
})
},
}
Expand Down
24 changes: 15 additions & 9 deletions ui/page/security/verify_message_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type VerifyMessagePage struct {
clearBtn, verifyButton cryptomaterial.Button
backButton cryptomaterial.IconButton
infoButton cryptomaterial.IconButton
pageContainer *widget.List

addressIsValid bool
}
Expand All @@ -43,6 +44,9 @@ func NewVerifyMessagePage(l *load.Load, wallet sharedW.Asset) *VerifyMessagePage
Load: l,
GenericPageModal: app.NewGenericPageModal(VerifyMessagePageID),
wallet: wallet,
pageContainer: &widget.List{
List: layout.List{Axis: layout.Vertical},
},
}

addressEditor := l.Theme.Editor(new(widget.Editor), values.String(values.StrAddress))
Expand Down Expand Up @@ -96,15 +100,17 @@ func (pg *VerifyMessagePage) Layout(gtx C) D {
pg.ParentNavigator().CloseCurrentPage()
},
Body: func(gtx C) D {
return pg.Theme.Card().Layout(gtx, func(gtx C) D {
return layout.UniformInset(values.MarginPadding15).Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(pg.description()),
layout.Rigid(pg.inputRow(pg.addressEditor)),
layout.Rigid(pg.inputRow(pg.signatureEditor)),
layout.Rigid(pg.inputRow(pg.messageEditor)),
layout.Rigid(pg.verifyAndClearButtons()),
)
return pg.Theme.List(pg.pageContainer).Layout(gtx, 1, func(gtx C, _ int) D {
return pg.Theme.Card().Layout(gtx, func(gtx C) D {
return layout.UniformInset(values.MarginPadding15).Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(pg.description()),
layout.Rigid(pg.inputRow(pg.addressEditor)),
layout.Rigid(pg.inputRow(pg.signatureEditor)),
layout.Rigid(pg.inputRow(pg.messageEditor)),
layout.Rigid(pg.verifyAndClearButtons()),
)
})
})
})
},
Expand Down
6 changes: 4 additions & 2 deletions ui/page/wallet/single_wallet_main_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var PageNavigationMap = map[string]string{
values.String(values.StrReceive): receive.ReceivePageID,
values.String(values.StrTransactions): transaction.TransactionsPageID,
values.String(values.StrSettings): WalletSettingsPageID,
values.String(values.StrStakeShuffle): privacy.AccountMixerPageID,
values.String(values.StrPrivacy): privacy.AccountMixerPageID,
values.String(values.StrStaking): staking.OverviewPageID,
}

Expand Down Expand Up @@ -158,6 +158,7 @@ func (swmp *SingleWalletMasterPage) OnNavigatedTo() {
// load wallet account balance first before rendering page contents.
// It loads balance for the current selected wallet.
swmp.updateBalance()
swmp.isBalanceHidden = swmp.AssetsManager.IsTotalBalanceVisible()
// updateExchangeSetting also calls updateBalance() but because of the API
// call it may take a while before the balance and USD conversion is updated.
// updateBalance() is called above first to prevent crash when balance value
Expand Down Expand Up @@ -379,7 +380,7 @@ func (swmp *SingleWalletMasterPage) HandleUserInteractions(gtx C) {

if swmp.hideBalanceButton.Clicked(gtx) {
swmp.isBalanceHidden = !swmp.isBalanceHidden
swmp.selectedWallet.SetBoolConfigValueForKey(sharedW.HideBalanceConfigKey, swmp.isBalanceHidden)
swmp.AssetsManager.SetTotalBalanceVisibility(swmp.isBalanceHidden)
}
}

Expand Down Expand Up @@ -425,6 +426,7 @@ func (swmp *SingleWalletMasterPage) navigateToSelectedTab() {
}

swmp.activeTab[swmp.PageNavigationTab.SelectedSegment()] = pg.ID()
swmp.PageNavigationTab.ScrollTo(swmp.PageNavigationTab.SelectedIndex())

displayPage(pg)
}
Expand Down
1 change: 1 addition & 0 deletions ui/values/localizable/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,4 +950,5 @@ const EN = `
"rateKucoinWarning" = "*Some countries are restricted on Kucoin and may not be able to fetch rate."
"restrictDetail" = "Restriction Detail"
"rateUnavailable" = "The rate unavailable this time, please reset it later in settings."
"privacy" = "Privacy"
`
1 change: 1 addition & 0 deletions ui/values/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -1059,4 +1059,5 @@ const (
StrRateKucoinWarning = "rateKucoinWarning"
StrRestrictedDetail = "restrictDetail"
StrRateUnavailable = "rateUnavailable"
StrPrivacy = "privacy"
)

0 comments on commit db5dc54

Please sign in to comment.