Skip to content

Commit

Permalink
Update logic segmented control and logic load transaction, layout bac…
Browse files Browse the repository at this point in the history
…k button on mobile
  • Loading branch information
JustinBeBoy committed Jan 5, 2024
1 parent 778120c commit 36e57d6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 30 deletions.
17 changes: 16 additions & 1 deletion ui/cryptomaterial/segmented_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (sc *SegmentedControl) Layout(gtx C, body func(gtx C) D, isMobileView ...bo
return body(gtx)
}
return sc.slideAction.DragLayout(gtx, func(gtx C) D {
return sc.slideAction.TransformLayout(gtx, body)
return sc.slideAction.TransformLayout(gtx, sc.layoutContent(body))
})
})
}),
Expand All @@ -133,6 +133,21 @@ func (sc *SegmentedControl) Layout(gtx C, body func(gtx C) D, isMobileView ...bo
return UniformPadding(gtx, widget, sc.isMobileView)
}

func (sc *SegmentedControl) layoutContent(body layout.Widget) layout.Widget {
return func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
dims := body(gtx)
return dims
}),
layout.Flexed(1, func(gtx layout.Context) layout.Dimensions {
// 600px use to fill height for swip action
return layout.Spacer{Height: values.MarginPadding600}.Layout(gtx)
}),
)
}
}

func (sc *SegmentedControl) GroupTileLayout(gtx C) D {
sc.handleEvents()

Expand Down
3 changes: 3 additions & 0 deletions ui/page/components/items_scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func (s *Scroll[T]) fetchScrollData(isScrollUp bool, window app.WindowNavigator)

s.isLoadingItems = true
itemsCountTemp := s.itemsCount
if s.itemsCount == -1 {
itemsCountTemp = 0
}
s.itemsCount = -1 // should trigger loading icon
offset := s.offset
tempSize := s.pageSize
Expand Down
25 changes: 9 additions & 16 deletions ui/page/root/single_wallet_main_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ func (swmp *SingleWalletMasterPage) Layout(gtx C) D {
}

func (swmp *SingleWalletMasterPage) LayoutTopBar(gtx C) D {
isMobile := swmp.Load.IsMobileView()
assetType := swmp.selectedWallet.GetAssetType()
return cryptomaterial.LinearLayout{
Width: cryptomaterial.MatchParent,
Expand All @@ -450,7 +451,7 @@ func (swmp *SingleWalletMasterPage) LayoutTopBar(gtx C) D {
h := values.MarginPadding24
v := values.MarginPadding8
orientation := layout.Horizontal
if swmp.Load.IsMobileView() {
if isMobile {
orientation = layout.Vertical
}
return cryptomaterial.LinearLayout{
Expand All @@ -468,7 +469,8 @@ func (swmp *SingleWalletMasterPage) LayoutTopBar(gtx C) D {
layout.Rigid(func(gtx C) D {
clickable := swmp.openWalletSelector
return layout.Flex{
Axis: layout.Horizontal,
Axis: layout.Horizontal,
Alignment: layout.Middle,
}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return cryptomaterial.LinearLayout{
Expand All @@ -483,7 +485,7 @@ func (swmp *SingleWalletMasterPage) LayoutTopBar(gtx C) D {
return layout.Center.Layout(gtx, func(gtx C) D {
alignment := layout.Start
orientation := layout.Horizontal
if swmp.Load.IsMobileView() {
if isMobile {
alignment = layout.Middle
orientation = layout.Vertical
clickable = nil
Expand All @@ -505,18 +507,12 @@ func (swmp *SingleWalletMasterPage) LayoutTopBar(gtx C) D {
if image == nil {
return D{}
}

if swmp.Load.IsMobileView() {
return image.Layout16dp(gtx)
}
return image.Layout24dp(gtx)
return image.LayoutTransform(gtx, isMobile, values.MarginPadding24)
}),
layout.Rigid(func(gtx C) D {
lbl := swmp.Theme.H6(swmp.selectedWallet.GetWalletName())
lbl.Color = swmp.Theme.Color.PageNavText
if swmp.Load.IsMobileView() {
lbl.TextSize = values.TextSize16
}
lbl.TextSize = values.TextSizeTransform(isMobile, values.TextSize20)
return layout.Inset{
Left: values.MarginPadding10,
}.Layout(gtx, lbl.Layout)
Expand All @@ -529,10 +525,7 @@ func (swmp *SingleWalletMasterPage) LayoutTopBar(gtx C) D {
return layout.Inset{
Left: values.MarginPadding10,
}.Layout(gtx, func(gtx C) D {
textSize := values.TextSize16
if swmp.Load.IsMobileView() {
textSize = values.TextSize12
}
textSize := values.TextSizeTransform(isMobile, values.TextSize16)
return components.WalletHightlighLabel(swmp.Theme, gtx, textSize, values.String(values.StrWatchOnly))
})
}),
Expand All @@ -541,7 +534,7 @@ func (swmp *SingleWalletMasterPage) LayoutTopBar(gtx C) D {
layout.Rigid(func(gtx C) D {
gtx.Constraints.Min.X = gtx.Constraints.Max.X
layoutPosition := layout.E
if swmp.Load.IsMobileView() {
if isMobile {
layoutPosition = layout.Center
}
return layoutPosition.Layout(gtx, func(gtx C) D {
Expand Down
4 changes: 2 additions & 2 deletions ui/page/send/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (pg *Page) contentLayout(gtx C) D {
return layout.Spacer{Height: gtx.Metric.PxToDp(dims.Size.Y)}.Layout(gtx)
})

return layout.Stack{}.Layout(gtx,
return layout.Stack{Alignment: layout.S}.Layout(gtx,
layout.Expanded(func(gtx C) D {
return pg.Theme.List(pg.pageContainer).Layout(gtx, len(pageContent), func(gtx C, i int) D {
mp := values.MarginPaddingTransform(pg.IsMobileView(), values.MarginPadding32)
Expand All @@ -79,7 +79,7 @@ func (pg *Page) contentLayout(gtx C) D {
return layout.Inset{Bottom: mp}.Layout(gtx, pageContent[i])
})
}),
layout.Expanded(func(gtx C) D {
layout.Stacked(func(gtx C) D {
return layout.S.Layout(gtx, func(gtx C) D {
call.Add(gtx.Ops)
return dims
Expand Down
13 changes: 2 additions & 11 deletions ui/page/transaction/transactions_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,14 @@ func (pg *TransactionsPage) Layout(gtx C) D {
isDCRAssetSelected := pg.selectedWallet != nil && pg.selectedWallet.GetAssetType() == utils.DCRWalletAsset
if isDCRAssetSelected || (pg.dcrWalletExists && pg.selectedWallet == nil) {
// Only show tx category navigation txCategoryTab for DCR wallets.
return pg.txCategoryTab.Layout(gtx, pg.layoutBody, pg.IsMobileView())
return pg.txCategoryTab.Layout(gtx, pg.layoutContent, pg.IsMobileView())
}

return cryptomaterial.UniformPadding(gtx, func(gtx C) D {
return pg.layoutBody(gtx)
return pg.layoutContent(gtx)
}, pg.IsMobileView())
}

func (pg *TransactionsPage) layoutBody(gtx C) D {
items := []layout.FlexChild{}
items = append(items, layout.Rigid(pg.layoutContent))
if pg.multiWalletLayout {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx, items...)
}
return layout.Flex{Axis: layout.Vertical}.Layout(gtx, items...)
}

func (pg *TransactionsPage) walletNotReady() bool {
return pg.selectedWallet != nil && (!pg.selectedWallet.IsSynced() || pg.selectedWallet.IsRescanning())
}
Expand Down

0 comments on commit 36e57d6

Please sign in to comment.