Skip to content

Commit

Permalink
reviews, refactor andd improved UI changes
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon committed Dec 5, 2023
1 parent 0d454d3 commit 06e0586
Show file tree
Hide file tree
Showing 16 changed files with 997 additions and 1,205 deletions.
458 changes: 239 additions & 219 deletions ui/cryptomaterial/dropdown.go

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions ui/cryptomaterial/segmented_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type SegmentedControl struct {
leftNavBtn,
rightNavBtn *Clickable

Padding layout.Inset

selectedIndex int
segmentTitles []string

Expand All @@ -33,6 +35,7 @@ func (t *Theme) SegmentedControl(segmentTitles []string) *SegmentedControl {
segmentTitles: segmentTitles,
leftNavBtn: t.NewClickable(false),
rightNavBtn: t.NewClickable(false),
Padding: layout.UniformInset(values.MarginPadding8),
}
}

Expand All @@ -57,14 +60,17 @@ func (sc *SegmentedControl) Layout(gtx C) D {
txt.Color = sc.theme.Color.Text
border = Border{Radius: Radius(8)}
}
return LinearLayout{

ll := LinearLayout{
Width: WrapContent,
Height: WrapContent,
Padding: layout.UniformInset(values.MarginPadding8),
Background: bg,
Margin: layout.UniformInset(values.MarginPadding5),
Border: border,
}.Layout2(gtx, txt.Layout)
Padding: sc.Padding,
}

return ll.Layout2(gtx, txt.Layout)
})
})
}),
Expand Down
8 changes: 4 additions & 4 deletions ui/cryptomaterial/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,17 @@ func mulAlpha(c color.NRGBA, alpha uint8) color.NRGBA {
func (t *Theme) closeAllDropdownMenus(group uint) {
for _, dropDown := range t.dropDownMenus {
if dropDown.group == group {
dropDown.isOpen = false
dropDown.expanded = false
}
}
}

// isOpenDropdownGroup iterate over Dropdowns registered as a member
// isDropdownGroupCollapsed iterate over Dropdowns registered as a member
// of {group}, returns true if any of the drop down state is open.
func (t *Theme) isOpenDropdownGroup(group uint) bool {
func (t *Theme) isDropdownGroupCollapsed(group uint) bool {
for _, dropDown := range t.dropDownMenus {
if dropDown.group == group {
if dropDown.isOpen {
if dropDown.expanded {
return true
}
}
Expand Down
101 changes: 0 additions & 101 deletions ui/cryptomaterial/toggle_button.go

This file was deleted.

10 changes: 1 addition & 9 deletions ui/modal/info_modal.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ func (in *InfoModal) NegativeButtonStyle(background, text color.NRGBA) *InfoModa
return in
}

// for backwards compatibility. template can be a translated string or an
// existing template.
// for backwards compatibility.
func (in *InfoModal) SetupWithTemplate(template string) *InfoModal {
title := in.dialogTitle
subtitle := in.subtitle
Expand Down Expand Up @@ -260,13 +259,6 @@ func (in *InfoModal) SetupWithTemplate(template string) *InfoModal {
customTemplate = totalValueInfo(in.Theme)
case BondStrengthInfoTemplate:
customTemplate = bondStrengthInfo(in.Theme)
default:
prepTemplate := func(th *cryptomaterial.Theme) func(gtx C) D {
return func(gtx layout.Context) layout.Dimensions {
return th.Body2(template).Layout(gtx)
}
}
customTemplate = append(customTemplate, prepTemplate(in.Theme))
}

in.dialogTitle = title
Expand Down
30 changes: 29 additions & 1 deletion ui/page/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ func BrowserURLWidget(gtx C, l *load.Load, url string, copyRedirect *cryptomater
})
})
}),
layout.Stacked(func(gtx layout.Context) layout.Dimensions {
layout.Stacked(func(gtx C) D {
return layout.Inset{
Top: values.MarginPaddingMinus10,
Left: values.MarginPadding10,
Expand Down Expand Up @@ -946,3 +946,31 @@ func FlexLayout(gtx C, options FlexOptions, widgets []func(gtx C) D) D {
Alignment: options.Alignment,
}.Layout(gtx, flexChildren...)
}

// IconButton creates the display for an icon button. The default icon and text
// color is Theme.Color.Primary.
func IconButton(icon *widget.Icon, txt string, inset layout.Inset, th *cryptomaterial.Theme, clickable *cryptomaterial.Clickable) func(gtx C) D {
return func(gtx C) D {
return inset.Layout(gtx, func(gtx C) D {
color := th.Color.Primary
return cryptomaterial.LinearLayout{
Width: cryptomaterial.MatchParent,
Height: cryptomaterial.WrapContent,
Orientation: layout.Horizontal,
Alignment: layout.Start,
Clickable: clickable,
}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return icon.Layout(gtx, color)
}),
layout.Rigid(layout.Spacer{Width: values.MarginPadding5}.Layout),
layout.Rigid(func(gtx C) D {
label := th.Label(values.TextSize16, txt)
label.Color = color
label.Font.Weight = font.SemiBold
return label.Layout(gtx)
}),
)
})
}
}
20 changes: 5 additions & 15 deletions ui/page/dcrdex/dcrdex_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func (pg *DEXPage) ID() string {
// Part of the load.Page interface.
func (pg *DEXPage) OnNavigatedTo() {
pg.ctx, pg.ctxCancel = context.WithCancel(context.TODO())
if !pg.inited {
pg.Display(NewDEXOnboarding(pg.Load))
} else if pg.CurrentPage() == nil {
if pg.CurrentPage() != nil {
pg.CurrentPage().OnNavigatedTo()
} else if pg.inited {
pg.Display(NewDEXMarketPage(pg.Load))
} else {
pg.CurrentPage().OnNavigatedTo()
pg.Display(NewDEXOnboarding(pg.Load))
}
}

Expand All @@ -85,17 +85,7 @@ func (pg *DEXPage) Layout(gtx C) D {
return pg.splashPage(gtx)
})
}
return layout.Stack{}.Layout(gtx,
layout.Expanded(func(gtx C) D {
return cryptomaterial.LinearLayout{
Width: cryptomaterial.MatchParent,
Height: cryptomaterial.MatchParent,
Orientation: layout.Vertical,
}.Layout(gtx,
layout.Flexed(1, pg.CurrentPage().Layout),
)
}),
)
return pg.CurrentPage().Layout(gtx)
}

// HandleUserInteractions is called just before Layout() to determine if any
Expand Down
Loading

0 comments on commit 06e0586

Please sign in to comment.