Skip to content

Commit

Permalink
update text size for mobile and desktop version, update error text on…
Browse files Browse the repository at this point in the history
… Editor layout
  • Loading branch information
JustinBeBoy committed Mar 21, 2024
1 parent 9bd6529 commit 4de75ac
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 33 deletions.
4 changes: 4 additions & 0 deletions ui/cryptomaterial/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ func (e *Editor) SetError(text string) {
e.errorLabel.Text = text
}

func (e *Editor) HasError() bool {
return e.errorLabel.Text != ""
}

func (e *Editor) ClearError() {
e.errorLabel.Text = ""
}
Expand Down
12 changes: 6 additions & 6 deletions ui/cryptomaterial/linearlayout.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (ll LinearLayout) Layout(gtx C, children ...layout.FlexChild) D {
return fill(gtx, background)
}

if ll.Clickable.Hoverable && ll.Clickable.button.Hovered() {
if ll.Clickable.Hoverable && ll.Clickable.IsHovered() {
background = ll.Clickable.style.HoverColor
}
fill(gtx, background)
Expand All @@ -73,9 +73,9 @@ func (ll LinearLayout) Layout(gtx C, children ...layout.FlexChild) D {
drawInk(gtx, c, ll.Clickable.style.Color)
}

return ll.Clickable.button.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return ll.Clickable.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 Down Expand Up @@ -159,7 +159,7 @@ func (ll LinearLayout) GradientLayout(gtx C, assetType utils.AssetType, children
paint.PaintOp{}.Add(gtx.Ops)

if ll.Clickable == nil {
return layout.Dimensions{
return D{
Size: gtx.Constraints.Min,
}
}
Expand All @@ -172,10 +172,10 @@ func (ll LinearLayout) GradientLayout(gtx C, assetType utils.AssetType, children
drawInk(gtx, c, ll.Clickable.style.Color)
}

return ll.Clickable.button.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return ll.Clickable.button.Layout(gtx, func(gtx C) D {
semantic.Button.Add(gtx.Ops)

return layout.Dimensions{
return D{
Size: gtx.Constraints.Min,
}
})
Expand Down
6 changes: 3 additions & 3 deletions ui/load/appinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ func (app *AppInfo) ConvertTextSize(size unit.Sp) unit.Sp {
case values.TextSize60:
return values.TextSize36
case values.TextSize20, values.TextSize24:
return values.TextSize16
return values.TextSize18
case values.TextSize18:
return values.TextSize16
case values.TextSize16:
return values.TextSize14
case values.TextSize16, values.TextSize14:
return values.TextSize12
default:
return size
}
Expand Down
2 changes: 1 addition & 1 deletion ui/page/components/bottom_nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (bottomNavigationbar *BottomNavigationBar) LayoutSendReceive(gtx layout.Con

func (bottomNavigationbar *BottomNavigationBar) OnViewCreated() {
bottomNavigationbar.axis = layout.Vertical
bottomNavigationbar.textSize = values.TextSize12
bottomNavigationbar.textSize = values.TextSize13
bottomNavigationbar.bottomInset = values.MarginPadding0
bottomNavigationbar.height = bottomNavigationBarHeight
bottomNavigationbar.alignment = layout.Middle
Expand Down
22 changes: 12 additions & 10 deletions ui/page/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func TransactionTitleIcon(l *load.Load, wal sharedW.Asset, tx *sharedW.Transacti
// determines if the transaction should display additional information about the tx
// such as the wallet the tx belong to etc. This is useful on pages where
// the tx is displayed from multi wallets.
func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Transaction, hideTxAssetInfo bool) D {
func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Transaction, hideTxAssetInfo bool, isTruncateWalletName ...bool) D {

Check warning on line 262 in ui/page/components/components.go

View workflow job for this annotation

GitHub Actions / Build

unused-parameter: parameter 'isTruncateWalletName' seems to be unused, consider removing or renaming it as _ (revive)
gtx.Constraints.Min.X = gtx.Constraints.Max.X
if wal == nil {
return D{}
Expand All @@ -269,7 +269,7 @@ func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Tr
txStatus := TransactionTitleIcon(l, wal, tx)
amount := wal.ToAmount(tx.Amount).String()
assetIcon := CoinImageBySymbol(l, wal.GetAssetType(), wal.IsWatchingOnlyWallet())
walName := l.Theme.Label(values.TextSize12, wal.GetWalletName())
walName := l.Theme.Label(values.TextSize14, wal.GetWalletName())
grayText := l.Theme.Color.GrayText2
insetLeft := values.MarginPadding16

Expand Down Expand Up @@ -326,7 +326,7 @@ func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Tr
return txMixedTitle(gtx, l, wal, tx)
}

walBalTxt := l.Theme.Label(values.TextSize12, amount)
walBalTxt := l.Theme.Label(values.TextSize14, amount)
walBalTxt.Color = grayText
return walBalTxt.Layout(gtx)
}),
Expand Down Expand Up @@ -358,17 +358,17 @@ func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Tr
if amnt > 0 {
txt = fmt.Sprintf("+%.2f", amnt)
}
return layout.Inset{Left: values.MarginPadding4}.Layout(gtx, l.Theme.Label(values.TextSize12, txt).Layout)
return layout.Inset{Left: values.MarginPadding4}.Layout(gtx, l.Theme.Label(values.TextSize14, txt).Layout)
}),
)
}),
)
}),
layout.Flexed(1, func(gtx C) D {
txSize := l.ConvertTextSize(values.TextSize16)
if !hideTxAssetInfo {
txSize = values.TextSize12
}
// if !hideTxAssetInfo {
// txSize = values.TextSize14
// }
status := l.Theme.Label(l.ConvertTextSize(txSize), values.String(values.StrUnknown))
var dateTimeLbl cryptomaterial.Label
txConfirmations := TxConfirmations(wal, tx)
Expand Down Expand Up @@ -449,6 +449,8 @@ func walletIconAndName(gtx C, icon *cryptomaterial.Image, name cryptomaterial.La
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(icon.Layout12dp),
layout.Rigid(func(gtx C) D {
gtx.Constraints.Max.X = gtx.Constraints.Max.X / 2
name.MaxLines = 1
return layout.Inset{Left: values.MarginPadding4}.Layout(gtx, name.Layout)
}),
)
Expand Down Expand Up @@ -494,7 +496,7 @@ func txStakingStatus(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Transac

durationTxt := TimeAgo(tx.Timestamp)
durationTxt = fmt.Sprintf("%s %s", durationPrefix, durationTxt)
lbl := l.Theme.Label(values.TextSize12, durationTxt)
lbl := l.Theme.Label(values.TextSize14, durationTxt)
lbl.Color = l.Theme.Color.GrayText2
return lbl.Layout(gtx)
}
Expand All @@ -509,14 +511,14 @@ func txMixedTitle(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Transactio
layout.Rigid(func(gtx C) D {
// mix denomination
mixedDenom := wal.ToAmount(tx.MixDenomination).String()
txt := l.Theme.Label(values.TextSize12, mixedDenom)
txt := l.Theme.Label(values.TextSize14, mixedDenom)
txt.Color = l.Theme.Color.GrayText2
return txt.Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
// Mixed outputs count
if tx.MixCount > 1 {
label := l.Theme.Label(values.TextSize12, fmt.Sprintf("x%d", tx.MixCount))
label := l.Theme.Label(values.TextSize14, fmt.Sprintf("x%d", tx.MixCount))
label.Color = l.Theme.Color.GrayText2
return layout.Inset{Left: values.MarginPadding4}.Layout(gtx, label.Layout)
}
Expand Down
2 changes: 1 addition & 1 deletion ui/page/components/consensus_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func layoutAgendaVoteAction(gtx C, l *load.Load, item *ConsensusItem, hasVotingW
func LayoutNoAgendasFound(gtx C, l *load.Load, syncing bool) D {
gtx.Constraints.Min.X = gtx.Constraints.Max.X
lb := l.Theme.Body1(values.String(values.StrNoAgendaYet))
lb.TextSize = l.ConvertTextSize(values.TextSize16)
lb.TextSize = values.TextSize16
lb.Color = l.Theme.Color.GrayText3
if syncing {
lb.Text = values.String(values.StrFetchingAgenda)
Expand Down
1 change: 1 addition & 0 deletions ui/page/receive/receive_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ func (pg *Page) contentLayout(gtx C) D {
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(func(gtx C) D {
txt := pg.Theme.Body2(values.String(values.StrMyAddress))
txt.TextSize = values.TextSize16
txt.Color = pg.Theme.Color.GrayText2
return txt.Layout(gtx)
}),
Expand Down
5 changes: 4 additions & 1 deletion ui/page/root/home_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func (hp *HomePage) HandleUserInteractions() {
hp.navigationTab.SetSelectedTab(values.String(values.StrTrade))
}

for _, item := range hp.sendReceiveNavItems {
for i, item := range hp.sendReceiveNavItems {
for item.Clickable.Clicked() {
switch strings.ToLower(item.PageID) {
case values.StrReceive:
Expand All @@ -386,6 +386,9 @@ func (hp *HomePage) HandleUserInteractions() {
}
hp.ParentWindow().ShowModal(send.NewSendPage(hp.Load, nil))
}

// This line fix hover send and receive button
hp.sendReceiveNavItems[i].Clickable = hp.Theme.NewClickable(true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/page/root/overview_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ func (pg *OverviewPage) ratesRefreshComponent() func(gtx C) D {
lastUpdatedTimestamp := pg.AssetsManager.RateSource.LastUpdate().Unix()
text = values.String(values.StrUpdated) + " " + components.TimeAgo(lastUpdatedTimestamp)
}
lastUpdatedInfo := pg.Theme.Label(values.TextSize12, text)
lastUpdatedInfo := pg.Theme.Label(values.TextSize14, text)
lastUpdatedInfo.Color = pg.Theme.Color.GrayText2
return layout.Inset{Bottom: values.MarginPadding2}.Layout(gtx, lastUpdatedInfo.Layout)
}),
Expand Down
30 changes: 24 additions & 6 deletions ui/page/send/recipient.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,33 @@ func (rp *recipient) addressAndAmountlayout(gtx C) D {
widget = func(gtx C) D {
icon := cryptomaterial.NewIcon(rp.Theme.Icons.ActionSwapHoriz)
axis := layout.Horizontal
var flexChilds []layout.FlexChild
flexChilds = []layout.FlexChild{
layout.Flexed(0.45, rp.amount.amountEditor.Layout),
amountHeight := 0
align := layout.Middle
if !rp.IsMobileView() {
align = layout.Start
}
flexChilds := []layout.FlexChild{
layout.Flexed(0.45, func(gtx C) D {
dims := rp.amount.amountEditor.Layout(gtx)
amountHeight = dims.Size.Y
return dims
}),
layout.Flexed(0.1, func(gtx C) D {
return layout.Center.Layout(gtx, func(gtx C) D {
if rp.IsMobileView() {
return layout.Center.Layout(gtx, func(gtx C) D {
return icon.Layout(gtx, values.MarginPadding16)
})
}
return layout.Inset{Top: values.MarginPadding13}.Layout(gtx, func(gtx C) D {
return icon.Layout(gtx, values.MarginPadding16)
})
}),
layout.Flexed(0.45, rp.amount.usdAmountEditor.Layout),
layout.Flexed(0.45, func(gtx layout.Context) layout.Dimensions {
if rp.amount.amountEditor.HasError() {
gtx.Constraints.Min.Y = amountHeight
}
return rp.amount.usdAmountEditor.Layout(gtx)
}),
}
if rp.IsMobileView() {
axis = layout.Vertical
Expand All @@ -331,7 +349,7 @@ func (rp *recipient) addressAndAmountlayout(gtx C) D {
}
return layout.Flex{
Axis: axis,
Alignment: layout.Middle,
Alignment: align,
}.Layout(gtx, flexChilds...)
}

Expand Down
7 changes: 3 additions & 4 deletions ui/values/dimensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ var (

TextSize10 = unit.Sp(10)
TextSize12 = unit.Sp(12)
TextSize13 = unit.Sp(13)
TextSize13_6 = unit.Sp(13.6)
TextSize14 = unit.Sp(14)
TextSize16 = unit.Sp(16)
Expand Down Expand Up @@ -174,11 +175,9 @@ var (

switch size {
case TextSize16, TextSize18:
return TextSize14
case TextSize14:
return TextSize12
case TextSize20:
return TextSize16
case TextSize20:
return TextSize18
case TextSize22:
return TextSize18
case TextSize24:
Expand Down

0 comments on commit 4de75ac

Please sign in to comment.