Skip to content

Commit

Permalink
update display wallet's name on wallet and account selector
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeBoy committed Mar 14, 2024
1 parent b2a4abe commit 68c013d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 42 deletions.
12 changes: 6 additions & 6 deletions ui/cryptomaterial/modal.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ 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 layout.Context, widgets []layout.Widget, width ...float32) layout.Dimensions {
func (m *Modal) Layout(gtx C, widgets []layout.Widget, width ...float32) D {
mGtx := gtx
if m.isDisabled {
mGtx = gtx.Disabled()
Expand All @@ -101,9 +101,9 @@ func (m *Modal) Layout(gtx layout.Context, widgets []layout.Widget, width ...flo
gtx.Constraints.Min.X = gtx.Constraints.Max.X
fillMax(gtx, m.overlayColor, CornerRadius{})

return m.button.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return m.button.Layout(gtx, func(gtx C) D {
semantic.Button.Add(gtx.Ops)
return layout.Dimensions{Size: gtx.Constraints.Min}
return D{Size: gtx.Constraints.Min}
})
}),
layout.Stacked(func(gtx C) D {
Expand All @@ -118,7 +118,7 @@ func (m *Modal) Layout(gtx layout.Context, widgets []layout.Widget, width ...flo
widgetFuncs = append(widgetFuncs, widgets...)
}

maxWidth := float32(360)
maxWidth := float32(450)
if len(width) > 0 && width[0] > 0 {
maxWidth = width[0]
} else if currentAppWidth := gtx.Metric.PxToDp(gtx.Constraints.Max.X); currentAppWidth <= values.StartMobileView {
Expand All @@ -138,8 +138,8 @@ func (m *Modal) Layout(gtx layout.Context, widgets []layout.Widget, width ...flo
return inset.Layout(gtx, func(gtx C) D {
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
layout.Expanded(func(gtx C) D {
return m.overlayBlinder.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.Dimensions{Size: gtx.Constraints.Min}
return m.overlayBlinder.Layout(gtx, func(gtx C) D {
return D{Size: gtx.Constraints.Min}
})
}),
layout.Stacked(func(gtx C) D {
Expand Down
6 changes: 3 additions & 3 deletions ui/page/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
sharedW "github.com/crypto-power/cryptopower/libwallet/assets/wallet"
"github.com/crypto-power/cryptopower/libwallet/instantswap"
"github.com/crypto-power/cryptopower/libwallet/txhelper"
"github.com/crypto-power/cryptopower/libwallet/utils"

libutils "github.com/crypto-power/cryptopower/libwallet/utils"
"github.com/crypto-power/cryptopower/ui/cryptomaterial"
"github.com/crypto-power/cryptopower/ui/load"
Expand Down Expand Up @@ -997,13 +997,13 @@ func GetServerIcon(theme *cryptomaterial.Theme, serverName string) *cryptomateri
// by comparing the current version with the latest release version
// available on GitHub.
func CheckForUpdate(l *load.Load) *ReleaseResponse {
req := &utils.ReqConfig{
req := &libutils.ReqConfig{
Method: http.MethodGet,
HTTPURL: releaseURL,
}

releaseResponse := new(ReleaseResponse)
if _, err := utils.HTTPRequest(req, &releaseResponse); err != nil {
if _, err := libutils.HTTPRequest(req, &releaseResponse); err != nil {
log.Error("checking for update failed:", err)
return nil
}
Expand Down
65 changes: 32 additions & 33 deletions ui/page/components/wallet_account_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,19 @@ func (ws *WalletAndAccountSelector) Layout(window app.WindowNavigator, gtx C) D
}.Layout(gtx,
layout.Rigid(ws.setWalletLogo),
layout.Rigid(func(gtx C) D {
gtx.Constraints.Max.X = gtx.Constraints.Max.X * 3 / 5
if ws.accountSelector {
if ws.selectedAccount == nil {
return ws.Theme.Body1("").Layout(gtx)
}
lbl := ws.Theme.Body1(ws.SelectedAccount().Name)
lbl.MaxLines = 1
lbl.TextSize = textSize16
return lbl.Layout(gtx)
}

lbl := ws.Theme.SemiBoldLabel(ws.SelectedWallet().GetWalletName())
lbl.MaxLines = 1
lbl.TextSize = textSize16
return lbl.Layout(gtx)
}),
Expand Down Expand Up @@ -583,38 +586,30 @@ func (sm *selectorModal) Layout(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
if sm.accountSelector {
inset := layout.Inset{
Top: values.MarginPadding0,
}
return inset.Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
if sm.infoModalOpen {
m := op.Record(gtx.Ops)
layout.Inset{Top: values.MarginPadding30}.Layout(gtx, func(gtx C) D {
card := sm.Theme.Card()
card.Color = sm.Theme.Color.Surface
return card.Layout(gtx, func(gtx C) D {
return layout.UniformInset(values.MarginPadding12).Layout(gtx, renderers.RenderHTML(sm.infoActionText, sm.Theme).Layout)
})
})
op.Defer(gtx.Ops, m.Stop())
}
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
if !sm.infoModalOpen {
return D{}
}

return D{}
}),
layout.Rigid(func(gtx C) D {
if sm.infoActionText != "" {
return sm.infoButton.Layout(gtx)
}
return D{}
}),
)
}),
)
})
m := op.Record(gtx.Ops)
dims := layout.Inset{Top: values.MarginPadding30}.Layout(gtx, func(gtx C) D {
card := sm.Theme.Card()
card.Color = sm.Theme.Color.Surface
return card.Layout(gtx, func(gtx C) D {
return layout.UniformInset(values.MarginPadding12).Layout(gtx, renderers.RenderHTML(sm.infoActionText, sm.Theme).Layout)
})
})
op.Defer(gtx.Ops, m.Stop())
return dims
}),
layout.Rigid(func(gtx C) D {
if sm.infoActionText == "" {
return D{}
}
return sm.infoButton.Layout(gtx)
}),
)
}
return D{}
}),
Expand Down Expand Up @@ -679,7 +674,7 @@ func (sm *selectorModal) modalListItemLayout(gtx C, selectorItem *SelectorItem)
Width: cryptomaterial.MatchParent,
Height: cryptomaterial.WrapContent,
Margin: layout.Inset{Bottom: values.MarginPadding4},
Padding: layout.Inset{Top: values.MarginPadding8, Bottom: values.MarginPadding8},
Padding: VerticalInset(values.MarginPadding8),
Clickable: selectorItem.clickable,
Alignment: layout.Middle,
}.Layout(gtx,
Expand All @@ -700,9 +695,13 @@ func (sm *selectorModal) modalListItemLayout(gtx C, selectorItem *SelectorItem)
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
acct := sm.Theme.Label(values.TextSize18, name)
acct.MaxLines = 1
acct.Color = sm.Theme.Color.Text
acct.Font.Weight = font.Normal
return EndToEndRow(gtx, acct.Layout, func(gtx C) D {
return EndToEndRow(gtx, func(gtx C) D {
gtx.Constraints.Max.X = gtx.Constraints.Max.X * 3 / 5
return acct.Layout(gtx)
}, func(gtx C) D {
return LayoutBalance(gtx, sm.Load, totalBal)
})
}),
Expand Down

0 comments on commit 68c013d

Please sign in to comment.