diff --git a/ui/cryptomaterial/segmented_control.go b/ui/cryptomaterial/segmented_control.go index 1101eb2a2..1fec8bfdb 100644 --- a/ui/cryptomaterial/segmented_control.go +++ b/ui/cryptomaterial/segmented_control.go @@ -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 @@ -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) +} diff --git a/ui/page/privacy/manual_mixer_setup_page.go b/ui/page/privacy/manual_mixer_setup_page.go index 5801d4bd8..a8225e1fe 100644 --- a/ui/page/privacy/manual_mixer_setup_page.go +++ b/ui/page/privacy/manual_mixer_setup_page.go @@ -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" @@ -32,6 +33,8 @@ type ManualMixerSetupPage struct { toPrivacySetup cryptomaterial.Button backIcon *cryptomaterial.Icon + pageContainer *widget.List + dcrWallet *dcr.Asset } @@ -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) @@ -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), ) }) }) diff --git a/ui/page/security/sign_message_page.go b/ui/page/security/sign_message_page.go index 77750c3aa..a482712f1 100644 --- a/ui/page/security/sign_message_page.go +++ b/ui/page/security/sign_message_page.go @@ -50,6 +50,8 @@ type SignMessagePage struct { clearButton, signButton, copyButton cryptomaterial.Button copySignature *cryptomaterial.Clickable + pageContainer *widget.List + backButton cryptomaterial.IconButton infoButton cryptomaterial.IconButton } @@ -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 @@ -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()), + ) + }) }) }) }, diff --git a/ui/page/security/validate_address.go b/ui/page/security/validate_address.go index 1466a2150..6ac2429be 100644 --- a/ui/page/security/validate_address.go +++ b/ui/page/security/validate_address.go @@ -37,6 +37,7 @@ type ValidateAddressPage struct { clearBtn, validateBtn cryptomaterial.Button stateValidate int backButton cryptomaterial.IconButton + pageContainer *widget.List } func NewValidateAddressPage(l *load.Load, wallet sharedW.Asset) *ValidateAddressPage { @@ -44,6 +45,9 @@ func NewValidateAddressPage(l *load.Load, wallet sharedW.Asset) *ValidateAddress Load: l, GenericPageModal: app.NewGenericPageModal(ValidateAddressPageID), wallet: wallet, + pageContainer: &widget.List{ + List: layout.List{Axis: layout.Vertical}, + }, } pg.backButton = components.GetBackButton(l) @@ -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()), + ) + }) }) }, } diff --git a/ui/page/security/verify_message_page.go b/ui/page/security/verify_message_page.go index 9c522df25..0f94e2e3e 100644 --- a/ui/page/security/verify_message_page.go +++ b/ui/page/security/verify_message_page.go @@ -34,6 +34,7 @@ type VerifyMessagePage struct { clearBtn, verifyButton cryptomaterial.Button backButton cryptomaterial.IconButton infoButton cryptomaterial.IconButton + pageContainer *widget.List addressIsValid bool } @@ -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)) @@ -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()), + ) + }) }) }) }, diff --git a/ui/page/wallet/single_wallet_main_page.go b/ui/page/wallet/single_wallet_main_page.go index 1f8b1b821..7590c7a4f 100644 --- a/ui/page/wallet/single_wallet_main_page.go +++ b/ui/page/wallet/single_wallet_main_page.go @@ -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, } @@ -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 @@ -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) } } @@ -425,6 +426,7 @@ func (swmp *SingleWalletMasterPage) navigateToSelectedTab() { } swmp.activeTab[swmp.PageNavigationTab.SelectedSegment()] = pg.ID() + swmp.PageNavigationTab.ScrollTo(swmp.PageNavigationTab.SelectedIndex()) displayPage(pg) } diff --git a/ui/values/localizable/en.go b/ui/values/localizable/en.go index 5ae4634c7..ead0604ae 100644 --- a/ui/values/localizable/en.go +++ b/ui/values/localizable/en.go @@ -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" ` diff --git a/ui/values/strings.go b/ui/values/strings.go index bd61269ce..f15dd81f0 100644 --- a/ui/values/strings.go +++ b/ui/values/strings.go @@ -1059,4 +1059,5 @@ const ( StrRateKucoinWarning = "rateKucoinWarning" StrRestrictedDetail = "restrictDetail" StrRateUnavailable = "rateUnavailable" + StrPrivacy = "privacy" )