Skip to content

Commit

Permalink
review 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 Nov 3, 2023
1 parent 6695a53 commit aed41bc
Show file tree
Hide file tree
Showing 3 changed files with 324 additions and 345 deletions.
19 changes: 9 additions & 10 deletions ui/cryptomaterial/dropdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
)

const (
DropdownBasePos uint = 0
DropdownBasePos uint = 0

Check failure on line 14 in ui/cryptomaterial/dropdown.go

View workflow job for this annotation

GitHub Actions / Build

SA9004: only the first constant in this group has an explicit type (staticcheck)
maxDropdownItemChar = 20
)

var MaxWidth = unit.Dp(800)
Expand Down Expand Up @@ -219,8 +220,8 @@ func (d *DropDown) layoutOption(gtx C, itemIndex int) D {
}

lbl := d.theme.Body2(item.Text)
if !d.isOpen && len(item.Text) > 20 {
lbl.Text = item.Text[:20-3] + "..."
if !d.isOpen && len(item.Text) > maxDropdownItemChar {
lbl.Text = item.Text[:maxDropdownItemChar-3 /* subtract space for the ellipsis */] + "..."
}
lbl.Font.Weight = d.FontWeight
return lbl.Layout(gtx)
Expand Down Expand Up @@ -264,13 +265,13 @@ func (d *DropDown) Layout(gtx C, dropPos int, reversePos bool) D {
if d.Stack {
isOpen := d.isOpen
return layout.Stack{Alignment: alig}.Layout(gtx,
layout.Expanded(func(gtx layout.Context) layout.Dimensions {
d.isOpen = false
layout.Expanded(func(gtx C) D {
d.isOpen = false // enforce a closed layout display before creating the layout Dimensions and undo later.
display := d.closedLayout(gtx, iLeft, iRight)
d.isOpen = isOpen
return display
}),
layout.Stacked(func(gtx layout.Context) layout.Dimensions {
layout.Stacked(func(gtx C) D {
maxY := unit.Dp(len(d.items))*values.MarginPadding50 + d.OpenedLayoutInset.Top
if d.extraDisplay != nil {
maxY += values.MarginPadding50
Expand Down Expand Up @@ -362,12 +363,10 @@ func (d *DropDown) dropDownItemMenu(gtx C) D {
return list.Layout(gtx, listItems, func(gtx C, index int) D {
if (index == listItems-1 || listItems == 0) && d.extraDisplay != nil {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
layout.Rigid(func(gtx C) D {
return d.layoutOption(gtx, index)
}),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return d.extraDisplay(gtx)
}),
layout.Rigid(d.extraDisplay),
)
} else if listItems != 0 {
return d.layoutOption(gtx, index)
Expand Down
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 compatibilty. 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
Loading

0 comments on commit aed41bc

Please sign in to comment.