Skip to content

Commit

Permalink
fix the recent trade display section on overview page
Browse files Browse the repository at this point in the history
  • Loading branch information
ukane-philemon authored and dreacot committed Sep 27, 2023
1 parent 118a9f8 commit 7fe343e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
29 changes: 27 additions & 2 deletions ui/page/components/order_list.go
Expand Up @@ -22,6 +22,10 @@ func OrderItemWidget(gtx C, l *load.Load, orderItem *instantswap.Order) D {
Background: l.Theme.Color.Surface,
Alignment: layout.Middle,
Border: cryptomaterial.Border{Radius: cryptomaterial.Radius(14)},
Margin: layout.Inset{
Top: values.MarginPadding8,
Bottom: values.MarginPadding10,
},
}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
Expand Down Expand Up @@ -68,12 +72,23 @@ func OrderItemWidget(gtx C, l *load.Load, orderItem *instantswap.Order) D {
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Inset{
Right: values.MarginPadding10,
Right: values.MarginPadding50,
}.Layout(gtx, func(gtx C) D {
return D{}
})
}),
layout.Rigid(l.Theme.Label(values.TextSize16, orderItem.Status.String()).Layout),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(l.Theme.Label(values.TextSize16, orderItem.Status.String()).Layout),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
statusLayout := statusIcon(l, orderItem.Status)
if statusLayout == nil {
return layout.Dimensions{}
}
return layout.Inset{Left: values.MarginPadding6}.Layout(gtx, statusLayout)
}),
)
}),
layout.Flexed(1, func(gtx C) D {
return layout.E.Layout(gtx, func(gtx C) D {
return layout.Flex{
Expand All @@ -98,6 +113,16 @@ func OrderItemWidget(gtx C, l *load.Load, orderItem *instantswap.Order) D {
)
}

func statusIcon(l *load.Load, status api.Status) func(gtx C) layout.Dimensions {
switch status {
case api.OrderStatusCompleted:
return l.Theme.Icons.ConfirmIcon.Layout16dp
case api.OrderStatusCanceled, api.OrderStatusExpired, api.OrderStatusFailed:
return l.Theme.Icons.FailedIcon.Layout16dp
}
return nil
}

func LayoutNoOrderHistory(gtx C, l *load.Load, syncing bool) D {
gtx.Constraints.Min.X = gtx.Constraints.Max.X
text := l.Theme.Body1(values.String(values.StrNoOrders))
Expand Down
12 changes: 10 additions & 2 deletions ui/page/root/overview_page.go
Expand Up @@ -77,6 +77,10 @@ func NewOverviewPage(l *load.Load) *OverviewPage {
Axis: layout.Vertical,
Alignment: layout.Middle,
},
recentTradeList: layout.List{
Axis: layout.Vertical,
Alignment: layout.Middle,
},
recentProposalList: layout.List{
Axis: layout.Vertical,
Alignment: layout.Middle,
Expand Down Expand Up @@ -585,11 +589,15 @@ func (pg *OverviewPage) recentTrades(gtx C) D {
return components.OrderItemWidget(gtx, pg.Load, pg.orders[i])
}),
layout.Rigid(func(gtx C) D {
// No divider for last row
// Show bottom divider for all rows except the last row.
if i == len(pg.orders)-1 {
return layout.Dimensions{}
}
return pg.Theme.Separator().Layout(gtx)

gtx.Constraints.Min.X = gtx.Constraints.Max.X
return layout.E.Layout(gtx, func(gtx C) D {
return layout.Inset{Left: values.MarginPadding50}.Layout(gtx, pg.Theme.Separator().Layout)
})
}),
)
})
Expand Down

0 comments on commit 7fe343e

Please sign in to comment.