Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeBoy committed Dec 20, 2023
2 parents e716271 + fad8a8e commit b6cad20
Show file tree
Hide file tree
Showing 30 changed files with 761 additions and 692 deletions.
5 changes: 5 additions & 0 deletions ui/cryptomaterial/dropdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,8 @@ func DisplayOneDropdown(dropdowns ...*DropDown) {
}
}
}

// Items returns the items of the dropdown.
func (d *DropDown) Items() []DropDownItem {
return d.items
}
4 changes: 2 additions & 2 deletions ui/cryptomaterial/icon_gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type Icons struct {
ContentAdd, NavigationCheck, NavigationMore, ActionCheckCircle, ActionInfo, NavigationArrowBack,
NavigationArrowForward, ActionCheck, NavigationCancel, NavMoreIcon,
ImageBrightness1, ContentClear, DropDownIcon, Cached, ContentRemove, SearchIcon, PlayIcon,
DotIcon, ContentClear, DropDownIcon, Cached, ContentRemove, SearchIcon, PlayIcon,
ActionSettings, ActionSwapHoriz, ActionSwapVertical, NavigationRefresh, ContentCopy *widget.Icon

OverviewIcon, OverviewIconInactive, WalletIcon, WalletIconInactive, TradeIconActive, TradeIconInactive, MixerInactive, RedAlert, Alert,
Expand Down Expand Up @@ -54,7 +54,7 @@ func (i *Icons) StandardMaterialIcons() *Icons {
i.ActionInfo = MustIcon(widget.NewIcon(icons.ActionInfo))
i.ActionCheck = MustIcon(widget.NewIcon(icons.ActionCheckCircle))
i.NavigationCancel = MustIcon(widget.NewIcon(icons.NavigationCancel))
i.ImageBrightness1 = MustIcon(widget.NewIcon(icons.ImageBrightness1))
i.DotIcon = MustIcon(widget.NewIcon(icons.ImageBrightness1))
i.ContentClear = MustIcon(widget.NewIcon(icons.ContentClear))
i.DropDownIcon = MustIcon(widget.NewIcon(icons.NavigationArrowDropDown))
i.Cached = MustIcon(widget.NewIcon(icons.ActionCached))
Expand Down
2 changes: 1 addition & 1 deletion ui/cryptomaterial/progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (mp *MultiLayerProgressBar) Layout(gtx C, isMobileView bool, additionalWidg
return layout.Flex{Axis: layout.Vertical}.Layout(gtx, flexWidgets...)
}

func (t *Theme) ProgressBarCirle(progress int) ProgressCircleStyle {
func (t *Theme) ProgressBarCircle(progress int) ProgressCircleStyle {
return ProgressCircleStyle{ProgressCircleStyle: material.ProgressCircle(t.Base, float32(progress)/100)}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/cryptomaterial/slider.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (s *Slider) selectedItemIndicatorLayout(gtx C) D {
}.Layout(gtx, func(gtx C) D {
list := &layout.List{Axis: layout.Horizontal}
return list.Layout(gtx, len(s.slideItems), func(gtx C, i int) D {
ic := NewIcon(s.t.Icons.ImageBrightness1)
ic := NewIcon(s.t.Icons.DotIcon)
ic.Color = values.TransparentColor(values.TransparentBlack, 0.2)
if i == s.selected {
ic.Color = s.SelectedIndicatorColor
Expand Down
6 changes: 3 additions & 3 deletions ui/load/appinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ func (app *AppInfo) ConvertTextSize(size unit.Sp) unit.Sp {
return size
}
switch size {
case values.TextSize60:
return values.TextSize36
case values.TextSize20, values.TextSize24:
return values.TextSize16
case values.TextSize18:
return values.TextSize14
case values.TextSize16:
return values.TextSize12
case values.TextSize14:
case values.TextSize16, values.TextSize14:
return values.TextSize12
default:
return size
Expand Down
102 changes: 12 additions & 90 deletions ui/page/accounts/accounts_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func NewAccountPage(l *load.Load, wallet sharedW.Asset) *Page {
accountsList: l.Theme.NewClickableList(layout.Vertical),
wallet: wallet,
}
pg.accountsList.Radius = cryptomaterial.Radius(8)
pg.accountsList.CompleteRadius = true
pg.accountsList.ClickableInset = cryptomaterial.ClickableInset{Bottom: values.MarginPadding20}

return pg
}
Expand Down Expand Up @@ -139,33 +142,12 @@ func (pg *Page) Layout(gtx C) D {
}

func (pg *Page) bodyLayout(gtx C) D {
inset := layout.Inset{Top: values.MarginPadding24, Bottom: values.MarginPadding24}
if pg.IsMobileView() {
inset = layout.Inset{Top: values.MarginPadding16, Bottom: values.MarginPadding16}
pg.accountsList.Radius = cryptomaterial.Radius(8)
pg.accountsList.CompleteRadius = true
pg.accountsList.ClickableInset = cryptomaterial.ClickableInset{Bottom: values.MarginPadding20}
}
return inset.Layout(gtx, func(gtx C) D {
dp24 := values.MarginPaddingTransform(pg.IsMobileView(), values.MarginPadding24)
return layout.Inset{Top: dp24, Bottom: dp24}.Layout(gtx, func(gtx C) D {
return pg.accountsList.Layout(gtx, len(pg.accounts), func(gtx C, i int) D {
if pg.IsMobileView() {
return layout.Inset{Bottom: values.MarginPadding20}.Layout(gtx, func(gtx C) D {
return pg.mobileAccountItemLayout(gtx, pg.accounts[i])
})
}

return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return pg.accountItemLayout(gtx, pg.accounts[i])
}),
layout.Rigid(func(gtx C) D {
isLastItem := i == len(pg.accounts)-1
if isLastItem {
return D{}
}
return pg.itemLine(gtx)
}),
)
return layout.Inset{Bottom: values.MarginPadding20}.Layout(gtx, func(gtx C) D {
return pg.accountItemLayout(gtx, pg.accounts[i])
})
})
})
}
Expand Down Expand Up @@ -207,15 +189,7 @@ func (pg *Page) addAccountBtnLayout(gtx C) D {
)
}

func (pg *Page) itemLine(gtx C) D {
return layout.Inset{Top: values.MarginPadding12, Bottom: values.MarginPadding12}.Layout(gtx, func(gtx C) D {
line := pg.Theme.Line(1, 0)
line.Color = pg.Theme.Color.Gray9
return line.Layout(gtx)
})
}

func (pg *Page) mobileAccountItemLayout(gtx C, account *sharedW.Account) D {
func (pg *Page) accountItemLayout(gtx C, account *sharedW.Account) D {
dp10 := values.MarginPadding10
return cryptomaterial.LinearLayout{
Width: cryptomaterial.MatchParent,
Expand All @@ -229,18 +203,18 @@ func (pg *Page) mobileAccountItemLayout(gtx C, account *sharedW.Account) D {
},
}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return pg.mobileAccountBalanceLayout(gtx, false, account)
return pg.accountBalanceLayout(gtx, false, account)
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Top: dp10, Bottom: dp10}.Layout(gtx, pg.Theme.Separator().Layout)
}),
layout.Rigid(func(gtx C) D {
return pg.mobileAccountBalanceLayout(gtx, true, account)
return pg.accountBalanceLayout(gtx, true, account)
}),
)
}

func (pg *Page) mobileAccountBalanceLayout(gtx C, spendableLayout bool, account *sharedW.Account) D {
func (pg *Page) accountBalanceLayout(gtx C, spendableLayout bool, account *sharedW.Account) D {
var label, balanceTxt cryptomaterial.Label
var balanceAmt float64
if !spendableLayout {
Expand Down Expand Up @@ -285,58 +259,6 @@ func (pg *Page) mobileAccountBalanceLayout(gtx C, spendableLayout bool, account
)
}

func (pg *Page) accountItemLayout(gtx C, account *sharedW.Account) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Inset{Top: values.MarginPadding24}.Layout(gtx, func(gtx C) D {
return layout.Flex{}.Layout(gtx,
layout.Rigid(func(gtx C) D {
txt := pg.Theme.Label(values.TextSize18, account.AccountName)
txt.Font.Weight = font.SemiBold
return txt.Layout(gtx)
}),
layout.Flexed(1, func(gtx C) D {
balance := account.Balance.Total.String()
totalBalance := pg.wallet.ToAmount(account.Balance.Total.ToInt()).ToCoin()
if pg.exchangeRate != -1 && pg.usdExchangeSet {
balanceUSD := utils.FormatAsUSDString(pg.Printer, utils.CryptoToUSD(pg.exchangeRate, totalBalance))
balance = fmt.Sprintf("%s (%s)", balance, balanceUSD)
}
txt := pg.Theme.Label(values.TextSize18, balance)
txt.Font.Weight = font.SemiBold
return layout.E.Layout(gtx, txt.Layout)
}),
)
})
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Top: values.MarginPadding16, Bottom: values.MarginPadding16}.Layout(gtx, func(gtx C) D {
return layout.Flex{Spacing: layout.SpaceBetween}.Layout(gtx,
layout.Rigid(func(gtx C) D {
txt := pg.Theme.Label(values.TextSize16, values.String(values.StrAmountSpendable))
txt.Font.Weight = font.SemiBold
txt.Color = pg.Theme.Color.GrayText3
return txt.Layout(gtx)
}),

layout.Flexed(1, func(gtx C) D {
spendable := account.Balance.Spendable.String()
spendableCoin := pg.wallet.ToAmount(account.Balance.Spendable.ToInt()).ToCoin()
if pg.exchangeRate != -1 && pg.usdExchangeSet {
balanceUSD := utils.FormatAsUSDString(pg.Printer, utils.CryptoToUSD(pg.exchangeRate, spendableCoin))
spendable = fmt.Sprintf("%s (%s)", spendable, balanceUSD)
}
txt := pg.Theme.Label(values.TextSize16, spendable)
txt.Color = pg.Theme.Color.GrayText3
txt.Font.Weight = font.SemiBold
return layout.E.Layout(gtx, txt.Layout)
}),
)
})
}),
)
}

// HandleUserInteractions is called just before Layout() to determine
// if any user interaction recently occurred on the page and may be
// used to update the page's UI components shortly before they are
Expand Down
41 changes: 22 additions & 19 deletions ui/page/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,22 @@ func TransactionTitleIcon(l *load.Load, wal sharedW.Asset, tx *sharedW.Transacti
// LayoutTransactionRow is a single transaction row on the transactions and overview
// page. It lays out a transaction's direction, balance, status. hideTxAssetInfo
// determines if the transaction should display additional information about the tx
// such as the wallet the tx belong to etc. This is usefil on pages where
// 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 {
gtx.Constraints.Min.X = gtx.Constraints.Max.X
if wal == nil {
return D{}
}

dp16 := values.MarginPaddingTransform(l.IsMobileView(), values.MarginPadding16)
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())
grayText := l.Theme.Color.GrayText2
insetLeft := values.MarginPadding16

if !hideTxAssetInfo {
insetLeft = values.MarginPadding8
}
Expand All @@ -273,7 +275,7 @@ func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Tr
Height: cryptomaterial.WrapContent,
Alignment: layout.Middle,
Padding: layout.Inset{
Top: values.MarginPadding16,
Top: dp16,
Bottom: values.MarginPadding10,
},
}.Layout(gtx,
Expand Down Expand Up @@ -308,7 +310,7 @@ func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Tr
Direction: layout.W,
}.Layout(gtx,
layout.Rigid(func(gtx C) D {
if hideTxAssetInfo {
if tx.Type == txhelper.TxTypeRegular {
return D{}
}

Expand All @@ -321,12 +323,12 @@ func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Tr
return walBalTxt.Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
if dcrAsset, ok := wal.(*dcr.Asset); ok && !hideTxAssetInfo {
if dcrAsset, ok := wal.(*dcr.Asset); ok {
if ok, _ := dcrAsset.TicketHasVotedOrRevoked(tx.Hash); ok {
return layout.Inset{
Left: values.MarginPadding4,
}.Layout(gtx, func(gtx C) D {
ic := cryptomaterial.NewIcon(l.Theme.Icons.ImageBrightness1)
ic := cryptomaterial.NewIcon(l.Theme.Icons.DotIcon)
ic.Color = grayText
return ic.Layout(gtx, values.MarginPadding6)
})
Expand All @@ -340,7 +342,7 @@ func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Tr
ticketSpender, _ = dcrAsset.TicketSpender(tx.Hash)
}

if ticketSpender == nil || hideTxAssetInfo {
if ticketSpender == nil {
return D{}
}
amnt := wal.ToAmount(ticketSpender.VoteReward).ToCoin()
Expand All @@ -355,7 +357,7 @@ func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Tr
)
}),
layout.Flexed(1, func(gtx C) D {
txSize := values.TextSize16
txSize := l.ConvertTextSize(values.TextSize16)
if !hideTxAssetInfo {
txSize = values.TextSize12
}
Expand Down Expand Up @@ -398,21 +400,22 @@ func LayoutTransactionRow(gtx C, l *load.Load, wal sharedW.Asset, tx *sharedW.Tr
layout.Rigid(func(gtx C) D {
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(func(gtx C) D {
if isStaking {
if hideTxAssetInfo {
title := values.String(values.StrRevoke)
if tx.Type == txhelper.TxTypeVote {
title = values.String(values.StrVote)
}

lbl := l.Theme.Label(l.ConvertTextSize(values.TextSize16), fmt.Sprintf("%dd to %s", tx.DaysToVoteOrRevoke, title))
lbl.Color = grayText
return lbl.Layout(gtx)
}
if !isStaking {
return status.Layout(gtx)
}

if !hideTxAssetInfo {
return txStakingStatus(gtx, l, wal, tx)
}

return status.Layout(gtx)
title := values.String(values.StrRevoke)
if tx.Type == txhelper.TxTypeVote {
title = values.String(values.StrVote)
}

lbl := l.Theme.Label(l.ConvertTextSize(values.TextSize16), fmt.Sprintf("%dd to %s", tx.DaysToVoteOrRevoke, title))
lbl.Color = grayText
return lbl.Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Left: values.MarginPadding7}.Layout(gtx, statusIcon.Layout12dp)
Expand Down
2 changes: 1 addition & 1 deletion ui/page/components/order_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func OrderItemWidget(gtx C, l *load.Load, orderItem *instantswap.Order) D {
Radius: cryptomaterial.Radius(14),
}.Layout(gtx,
func(gtx C) D {
textSize16 := values.TextSizeTransform(l.IsMobileView(), values.TextSize16)
textSize16 := l.ConvertTextSize(values.TextSize16)
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Inset{
Expand Down
4 changes: 2 additions & 2 deletions ui/page/components/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func LayoutIconAndTextWithSize(l *load.Load, gtx C, text string, col color.NRGBA
return layout.Inset{
Right: values.MarginPadding5,
}.Layout(gtx, func(gtx C) D {
ic := cryptomaterial.NewIcon(l.Theme.Icons.ImageBrightness1)
ic := cryptomaterial.NewIcon(l.Theme.Icons.DotIcon)
ic.Color = col
return ic.Layout(gtx, iconSize)
})
Expand Down Expand Up @@ -157,5 +157,5 @@ func LayoutOrderAmount(l *load.Load, gtx C, assetType string, amount float64) D
convertedAmountStr = "Unsupported asset type"
}

return l.Theme.Label(values.TextSizeTransform(l.IsMobileView(), values.TextSize16), convertedAmountStr).Layout(gtx)
return l.Theme.Label(l.ConvertTextSize(values.TextSize16), convertedAmountStr).Layout(gtx)
}
2 changes: 1 addition & 1 deletion ui/page/components/votebar_widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewVoteBar(l *load.Load) *VoteBar {
noColor: l.Theme.Color.Danger,
passTooltip: l.Theme.Tooltip(),
quorumTooltip: l.Theme.Tooltip(),
legendIcon: cryptomaterial.NewIcon(l.Theme.Icons.ImageBrightness1),
legendIcon: cryptomaterial.NewIcon(l.Theme.Icons.DotIcon),
}

_, vb.infoButton = SubpageHeaderButtons(l)
Expand Down
8 changes: 6 additions & 2 deletions ui/page/components/wallet_setup_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,14 @@ func (pg *CreateWallet) Layout(gtx C) D {
Width: cryptomaterial.MatchParent,
Height: cryptomaterial.MatchParent,
Direction: layout.Center,
Padding: layout.UniformInset(values.MarginPadding20),
}.Layout2(gtx, func(gtx C) D {
width := gtx.Dp(values.MarginPadding377)
if pg.IsMobileView() {
width = gtx.Dp(values.MarginPadding350)
}
return cryptomaterial.LinearLayout{
Width: gtx.Dp(values.MarginPadding377),
Width: width,
Height: cryptomaterial.MatchParent,
Alignment: layout.Middle,
Margin: layout.Inset{
Expand Down Expand Up @@ -224,7 +229,6 @@ func (pg *CreateWallet) Layout(gtx C) D {
})
}

// todo bitcoin wallet creation
func (pg *CreateWallet) walletTypeSection(gtx C) D {
return layout.Flex{Axis: layout.Vertical, Spacing: layout.SpaceBetween}.Layout(gtx,
layout.Rigid(func(gtx C) D {
Expand Down
Loading

0 comments on commit b6cad20

Please sign in to comment.