diff --git a/ui/cryptomaterial/modal.go b/ui/cryptomaterial/modal.go index 128586102..c9a38c23b 100644 --- a/ui/cryptomaterial/modal.go +++ b/ui/cryptomaterial/modal.go @@ -35,19 +35,18 @@ type Modal struct { isDisabled bool showScrollBar bool isMobileView bool - isFirstDisplay bool firstLoadWithContext func(gtx C) } // The firstLoad() parameter is used to perform actions // that require Context before Layout() is called. -func (t *Theme) ModalFloatTitle(id string, isMobileView bool, firstLoad ...func(gtx C)) *Modal { - mod := t.Modal(id, isMobileView, firstLoad...) +func (t *Theme) ModalFloatTitle(id string, isMobileView bool, firstLoad func(gtx C)) *Modal { + mod := t.Modal(id, isMobileView, firstLoad) mod.isFloatTitle = true return mod } -func (t *Theme) Modal(id string, isMobileView bool, firstLoad ...func(gtx C)) *Modal { +func (t *Theme) Modal(id string, isMobileView bool, firstLoad func(gtx C)) *Modal { overlayColor := t.Color.Black overlayColor.A = 200 @@ -64,11 +63,8 @@ func (t *Theme) Modal(id string, isMobileView bool, firstLoad ...func(gtx C)) *M card: t.Card(), padding: values.MarginPadding24, isMobileView: isMobileView, - isFirstDisplay: true, - } - if len(firstLoad) > 0 { - m.firstLoadWithContext = firstLoad[0] } + m.firstLoadWithContext = firstLoad m.scroll = t.List(m.list) @@ -100,9 +96,9 @@ func (m *Modal) IsShown() bool { // Layout renders the modal widget to screen. The modal assumes the size of // its content plus padding. func (m *Modal) Layout(gtx C, widgets []layout.Widget, width ...float32) D { - if m.firstLoadWithContext != nil && m.isFirstDisplay { + if m.firstLoadWithContext != nil { m.firstLoadWithContext(gtx) - m.isFirstDisplay = false + m.firstLoadWithContext = nil } mGtx := gtx if m.isDisabled { diff --git a/ui/cryptomaterial/theme.go b/ui/cryptomaterial/theme.go index 904425db4..e877ec260 100644 --- a/ui/cryptomaterial/theme.go +++ b/ui/cryptomaterial/theme.go @@ -27,7 +27,6 @@ type ( ) type Theme struct { - Shaper text.Shaper Base *material.Theme Color *values.Color Styles *values.WidgetStyles @@ -55,9 +54,11 @@ type Theme struct { } func NewTheme(fontCollection []text.FontFace, decredIcons map[string]image.Image, isDarkModeOn bool) *Theme { + base := material.NewTheme() + base.Shaper = text.NewShaper(text.WithCollection(fontCollection)) + t := &Theme{ - Shaper: *text.NewShaper(text.WithCollection(fontCollection)), - Base: material.NewTheme(), + Base: base, Color: &values.Color{}, Icons: &Icons{}, Styles: values.DefaultWidgetStyles(), diff --git a/ui/load/appinfo.go b/ui/load/appinfo.go index 2aec5b34e..2972fdc29 100644 --- a/ui/load/appinfo.go +++ b/ui/load/appinfo.go @@ -8,11 +8,13 @@ import ( giouiApp "gioui.org/app" "gioui.org/layout" + "gioui.org/text" "gioui.org/unit" "gioui.org/widget/material" "github.com/crypto-power/cryptopower/app" "github.com/crypto-power/cryptopower/libwallet" "github.com/crypto-power/cryptopower/libwallet/utils" + "github.com/crypto-power/cryptopower/ui/assets" "github.com/crypto-power/cryptopower/ui/values" ) @@ -280,6 +282,7 @@ func (app *AppInfo) ConvertIconSize(size unit.Dp) unit.Dp { func networkSwitchTempPage(currentNetType, newNetType utils.NetworkType) app.Page { theme := material.NewTheme() + theme.Shaper = text.NewShaper(text.WithCollection(assets.FontCollection())) text := fmt.Sprintf("Switching from %s to %s, please wait...", currentNetType, newNetType) lbl := material.Body1(theme, text) return app.NewWidgetDisplayPage(func(gtx layout.Context) layout.Dimensions { diff --git a/ui/modal/info_modal.go b/ui/modal/info_modal.go index 18d141eef..68008af25 100644 --- a/ui/modal/info_modal.go +++ b/ui/modal/info_modal.go @@ -66,7 +66,7 @@ const ( // NewCustomModal returns a modal that can be customized. func NewCustomModal(l *load.Load) *InfoModal { - return newInfoModalWithKey(l, "info_modal", InfoBtn) + return newInfoModalWithKey(l, "info_modal", InfoBtn, nil) } // NewSuccessModal returns the default success modal UI component. @@ -94,7 +94,7 @@ func DefaultClickFunc() ClickFunc { } func newModal(l *load.Load, title string, icon *cryptomaterial.Image, clicked ClickFunc) *InfoModal { - info := newInfoModalWithKey(l, "info_modal", InfoBtn) + info := newInfoModalWithKey(l, "info_modal", InfoBtn, nil) info.positiveButtonClicked = clicked info.btnPositiveWidth = values.MarginPadding100 info.dialogIcon = icon @@ -104,10 +104,10 @@ func newModal(l *load.Load, title string, icon *cryptomaterial.Image, clicked Cl return info } -func newInfoModalWithKey(l *load.Load, key string, btnPositiveType ButtonType, firstLoad ...func(gtx C)) *InfoModal { +func newInfoModalWithKey(l *load.Load, key string, btnPositiveType ButtonType, firstLoad func(gtx C)) *InfoModal { in := &InfoModal{ Load: l, - Modal: l.Theme.ModalFloatTitle(key, l.IsMobileView(), firstLoad...), + Modal: l.Theme.ModalFloatTitle(key, l.IsMobileView(), firstLoad), btnNegative: l.Theme.OutlineButton(""), isCancelable: true, isLoading: false, diff --git a/ui/page/components/asset_selector.go b/ui/page/components/asset_selector.go index 5c4dd075d..d98be003a 100644 --- a/ui/page/components/asset_selector.go +++ b/ui/page/components/asset_selector.go @@ -43,7 +43,7 @@ type assetTypeModal struct { onAssetTypeClicked func(*AssetTypeItem) assetTypeList layout.List assetTypeItems []*AssetTypeItem - eventSoruce input.Source + eventSoruce input.Source // Interface between the interface state and widgets isCancelable bool } @@ -204,7 +204,7 @@ func (ats *AssetTypeSelector) Layout(window app.WindowNavigator, gtx C) D { func newAssetTypeModal(l *load.Load) *assetTypeModal { atm := &assetTypeModal{ Load: l, - Modal: l.Theme.ModalFloatTitle(values.String(values.StrSelectAServer), l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle(values.String(values.StrSelectAServer), l.IsMobileView(), nil), assetTypeList: layout.List{Axis: layout.Vertical}, isCancelable: true, dialogTitle: values.String(values.StrSelectAssetType), diff --git a/ui/page/components/vsp_selector.go b/ui/page/components/vsp_selector.go index 7de29419d..0d1f302b1 100644 --- a/ui/page/components/vsp_selector.go +++ b/ui/page/components/vsp_selector.go @@ -149,7 +149,7 @@ type vspSelectorModal struct { func newVSPSelectorModal(l *load.Load, dcrWallet *dcr.Asset) *vspSelectorModal { v := &vspSelectorModal{ Load: l, - Modal: l.Theme.ModalFloatTitle("VSPSelectorModal", l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle("VSPSelectorModal", l.IsMobileView(), nil), inputVSP: l.Theme.Editor(new(widget.Editor), values.String(values.StrAddVSP)), addVSP: l.Theme.Button(values.String(values.StrSave)), diff --git a/ui/page/components/wallet_account_selector.go b/ui/page/components/wallet_account_selector.go index 0650b5678..18533719b 100644 --- a/ui/page/components/wallet_account_selector.go +++ b/ui/page/components/wallet_account_selector.go @@ -428,7 +428,7 @@ type SelectorItem struct { func newSelectorModal(l *load.Load, assetType ...utils.AssetType) *selectorModal { sm := &selectorModal{ Load: l, - Modal: l.Theme.ModalFloatTitle("SelectorModal", l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle("SelectorModal", l.IsMobileView(), nil), walletsList: layout.List{Axis: layout.Vertical}, isCancelable: true, infoBackdrop: new(widget.Clickable), diff --git a/ui/page/components/wallet_setup_page.go b/ui/page/components/wallet_setup_page.go index 6602936bd..40945b9b2 100644 --- a/ui/page/components/wallet_setup_page.go +++ b/ui/page/components/wallet_setup_page.go @@ -107,7 +107,6 @@ func NewCreateWallet(l *load.Load, walletCreationSuccessCallback func(), assetTy pg.walletName = l.Theme.Editor(new(widget.Editor), values.String(values.StrEnterWalletName)) pg.walletName.Editor.SingleLine, pg.walletName.Editor.Submit = true, true - pg.confirmPasswordEditor.Hint = values.String(values.StrWalletName) pg.watchOnlyWalletHex = l.Theme.Editor(new(widget.Editor), values.String(values.StrExtendedPubKey)) pg.watchOnlyWalletHex.Editor.SingleLine, pg.watchOnlyWalletHex.Editor.Submit, pg.watchOnlyWalletHex.IsTitleLabel = false, true, false diff --git a/ui/page/exchange/exchange_selector.go b/ui/page/exchange/exchange_selector.go index a8f43c0ae..91c38eb9f 100644 --- a/ui/page/exchange/exchange_selector.go +++ b/ui/page/exchange/exchange_selector.go @@ -202,7 +202,7 @@ func (es *ExSelector) Layout(window app.WindowNavigator, gtx C) D { func newExchangeModal(l *load.Load) *exchangeModal { em := &exchangeModal{ Load: l, - Modal: l.Theme.ModalFloatTitle(values.String(values.StrSelectAServer), l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle(values.String(values.StrSelectAServer), l.IsMobileView(), nil), exchangeList: layout.List{Axis: layout.Vertical}, isCancelable: true, dialogTitle: values.String(values.StrSelectAServer), diff --git a/ui/page/exchange/frequency_selector.go b/ui/page/exchange/frequency_selector.go index fe9c4b075..9629117a0 100644 --- a/ui/page/exchange/frequency_selector.go +++ b/ui/page/exchange/frequency_selector.go @@ -120,7 +120,7 @@ func (fs *FrequencySelector) Layout(window app.WindowNavigator, gtx C) D { func newFrequencyModal(l *load.Load) *frequencyModal { fm := &frequencyModal{ Load: l, - Modal: l.Theme.ModalFloatTitle(values.String(values.StrSelectFrequency), l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle(values.String(values.StrSelectFrequency), l.IsMobileView(), nil), frequencyList: layout.List{Axis: layout.Vertical}, isCancelable: true, dialogTitle: values.String(values.StrSelectFrequency), diff --git a/ui/page/exchange/order_scheduler_modal.go b/ui/page/exchange/order_scheduler_modal.go index 4eba9c32e..387f9033e 100644 --- a/ui/page/exchange/order_scheduler_modal.go +++ b/ui/page/exchange/order_scheduler_modal.go @@ -61,7 +61,7 @@ type orderSchedulerModal struct { func newOrderSchedulerModalModal(l *load.Load, data *orderData) *orderSchedulerModal { osm := &orderSchedulerModal{ Load: l, - Modal: l.Theme.ModalFloatTitle(values.String(values.StrOrderScheduler), l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle(values.String(values.StrOrderScheduler), l.IsMobileView(), nil), exchangeSelector: NewExSelector(l, instantswap.FlypMe), frequencySelector: NewFrequencySelector(l), orderData: data, diff --git a/ui/page/exchange/order_settings_modal.go b/ui/page/exchange/order_settings_modal.go index 12a1b0147..7c51ebe3c 100644 --- a/ui/page/exchange/order_settings_modal.go +++ b/ui/page/exchange/order_settings_modal.go @@ -61,7 +61,7 @@ type orderSettingsModal struct { func newOrderSettingsModalModal(l *load.Load, data *orderData) *orderSettingsModal { osm := &orderSettingsModal{ Load: l, - Modal: l.Theme.ModalFloatTitle(values.String(values.StrSettings), l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle(values.String(values.StrSettings), l.IsMobileView(), nil), orderData: data, copyRedirect: l.Theme.NewClickable(false), } diff --git a/ui/page/governance/consensus_page.go b/ui/page/governance/consensus_page.go index 7047275b6..d6815e2eb 100644 --- a/ui/page/governance/consensus_page.go +++ b/ui/page/governance/consensus_page.go @@ -248,7 +248,6 @@ func (pg *ConsensusPage) HandleUserInteractions(gtx C) { layout.Flexed(0.1, func(gtx C) D { return layout.E.Layout(gtx, func(gtx C) D { if pg.copyRedirectURL.Clicked(gtx) { - // clipboard.WriteOp{Text: host}.Add(gtx.Ops) gtx.Execute(clipboard.WriteCmd{Data: io.NopCloser(strings.NewReader(host))}) pg.Toast.Notify(values.String(values.StrCopied)) } diff --git a/ui/page/governance/governance_page.go b/ui/page/governance/governance_page.go index 34ef116d0..0cba40025 100644 --- a/ui/page/governance/governance_page.go +++ b/ui/page/governance/governance_page.go @@ -37,7 +37,7 @@ func NewGovernancePage(l *load.Load) *Page { pg := &Page{ Load: l, MasterPage: app.NewMasterPage(GovernancePageID), - modal: l.Theme.ModalFloatTitle(values.String(values.StrSettings), l.IsMobileView()), + modal: l.Theme.ModalFloatTitle(values.String(values.StrSettings), l.IsMobileView(), nil), tabCategoryList: l.Theme.NewClickableList(layout.Horizontal), } diff --git a/ui/page/governance/proposal_details_page.go b/ui/page/governance/proposal_details_page.go index 20a4f9f5f..5adeb2cd7 100644 --- a/ui/page/governance/proposal_details_page.go +++ b/ui/page/governance/proposal_details_page.go @@ -248,7 +248,6 @@ func (pg *ProposalDetails) HandleUserInteractions(gtx C) { return layout.E.Layout(gtx, func(gtx C) D { return layout.Inset{Top: values.MarginPadding7}.Layout(gtx, func(gtx C) D { if pg.copyRedirectURL.Clicked(gtx) { - // clipboard.WriteOp{Text: host}.Add(gtx.Ops) gtx.Execute(clipboard.WriteCmd{Data: io.NopCloser(strings.NewReader(host))}) pg.Toast.Notify(values.String(values.StrCopied)) } diff --git a/ui/page/governance/proposal_vote_modal.go b/ui/page/governance/proposal_vote_modal.go index 50b424878..a85bfd03f 100644 --- a/ui/page/governance/proposal_vote_modal.go +++ b/ui/page/governance/proposal_vote_modal.go @@ -45,7 +45,7 @@ type voteModal struct { func newVoteModal(l *load.Load, proposal *libwallet.Proposal) *voteModal { vm := &voteModal{ Load: l, - Modal: l.Theme.ModalFloatTitle("input_vote_modal", l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle("input_vote_modal", l.IsMobileView(), nil), proposal: proposal, materialLoader: material.Loader(l.Theme.Base), voteBtn: l.Theme.Button(values.String(values.StrVote)), diff --git a/ui/page/governance/wallet_selector.go b/ui/page/governance/wallet_selector.go index 75010ad2f..8a387561a 100644 --- a/ui/page/governance/wallet_selector.go +++ b/ui/page/governance/wallet_selector.go @@ -168,7 +168,7 @@ type WalletSelectorModal struct { func newWalletSelectorModal(l *load.Load, currentSelectedWallet sharedW.Asset) *WalletSelectorModal { asm := &WalletSelectorModal{ Load: l, - Modal: l.Theme.ModalFloatTitle("WalletSelectorModal", l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle("WalletSelectorModal", l.IsMobileView(), nil), walletsList: l.Theme.NewClickableList(layout.Vertical), currentSelectedWallet: currentSelectedWallet, diff --git a/ui/page/receive/receive_page.go b/ui/page/receive/receive_page.go index f7e537b8b..342bb9852 100644 --- a/ui/page/receive/receive_page.go +++ b/ui/page/receive/receive_page.go @@ -83,7 +83,7 @@ func NewReceivePage(l *load.Load, wallet sharedW.Asset) *Page { _, pg.infoButton = components.SubpageHeaderButtons(l) if wallet == nil { - pg.modalLayout = l.Theme.ModalFloatTitle(values.String(values.StrReceive), pg.IsMobileView()) + pg.modalLayout = l.Theme.ModalFloatTitle(values.String(values.StrReceive), pg.IsMobileView(), nil) pg.GenericPageModal = pg.modalLayout.GenericPageModal pg.initWalletSelectors() // will auto select the first wallet in the dropdown as pg.selectedWallet } else { diff --git a/ui/page/send/manual_coin_selection.go b/ui/page/send/manual_coin_selection.go index a44477f22..2ab0516cf 100644 --- a/ui/page/send/manual_coin_selection.go +++ b/ui/page/send/manual_coin_selection.go @@ -127,7 +127,7 @@ func NewManualCoinSelectionPage(l *load.Load, sendPage *Page) *ManualCoinSelecti } if sendPage.modalLayout != nil { - pg.modalLayout = l.Theme.ModalFloatTitle(values.String(values.StrCoinSelection), pg.IsMobileView()) + pg.modalLayout = l.Theme.ModalFloatTitle(values.String(values.StrCoinSelection), pg.IsMobileView(), nil) pg.GenericPageModal = pg.modalLayout.GenericPageModal } else { pg.GenericPageModal = app.NewGenericPageModal(ManualCoinSelectionPageID) diff --git a/ui/page/send/page.go b/ui/page/send/page.go index 51f18bff1..25f867784 100644 --- a/ui/page/send/page.go +++ b/ui/page/send/page.go @@ -117,7 +117,7 @@ func NewSendPage(l *load.Load, wallet sharedW.Asset) *Page { // When this page is opened from the home page, the wallet to use is not // specified. This page will be opened as a modal and a wallet selector // will be displayed. - pg.modalLayout = l.Theme.ModalFloatTitle(values.String(values.StrSend), pg.IsMobileView()) + pg.modalLayout = l.Theme.ModalFloatTitle(values.String(values.StrSend), pg.IsMobileView(), nil) pg.GenericPageModal = pg.modalLayout.GenericPageModal pg.initModalWalletSelector() // will auto select the first wallet in the dropdown as pg.selectedWallet } else { diff --git a/ui/page/staking/stake_modal.go b/ui/page/staking/stake_modal.go index dcef0ee17..4ab51e2e3 100644 --- a/ui/page/staking/stake_modal.go +++ b/ui/page/staking/stake_modal.go @@ -38,7 +38,7 @@ type ticketBuyerModal struct { func newTicketBuyerModal(l *load.Load, wallet *dcr.Asset) *ticketBuyerModal { tb := &ticketBuyerModal{ Load: l, - Modal: l.Theme.ModalFloatTitle("staking_modal", l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle("staking_modal", l.IsMobileView(), nil), cancel: l.Theme.OutlineButton(values.String(values.StrCancel)), saveSettingsBtn: l.Theme.Button(values.String(values.StrSave)), diff --git a/ui/preference/list_preference.go b/ui/preference/list_preference.go index a2b36e9e4..3ef6b9716 100644 --- a/ui/preference/list_preference.go +++ b/ui/preference/list_preference.go @@ -112,7 +112,7 @@ func NewListPreference(l *load.Load, preferenceKey, defaultValue string, items [ preferenceItems: items, optionsRadioGroup: new(widget.Enum), - Modal: l.Theme.ModalFloatTitle("list_preference", l.IsMobileView()), + Modal: l.Theme.ModalFloatTitle("list_preference", l.IsMobileView(), nil), redirectIcon: l.Theme.Icons.RedirectIcon, viewWarningAction: l.Theme.NewClickable(true), copyRedirectURL: l.Theme.NewClickable(false), @@ -265,7 +265,6 @@ func (lp *ListPreferenceModal) Layout(gtx C) D { layout.Flexed(0.1, func(gtx C) D { return layout.E.Layout(gtx, func(gtx C) D { if lp.copyRedirectURL.Clicked(gtx) { - // clipboard.WriteOp{Text: host}.Add(gtx.Ops) gtx.Execute(clipboard.WriteCmd{Data: io.NopCloser(strings.NewReader(host))}) lp.Toast.Notify(values.String(values.StrCopied)) }