Skip to content

Commit

Permalink
Add scrollbar to send page and modal widget
Browse files Browse the repository at this point in the history
- fix wallet and ticket page scrollbar bug
  • Loading branch information
Sirmorrison committed Oct 26, 2021
1 parent 28f0178 commit ad24fa2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
19 changes: 13 additions & 6 deletions ui/decredmaterial/modal.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
type Modal struct {
overlayColor color.NRGBA
background color.NRGBA
list *layout.List
list *widget.List
button *widget.Clickable
card Card
scroll ListStyle
isFloatTitle bool
}

Expand All @@ -28,13 +29,19 @@ func (t *Theme) Modal() *Modal {
overlayColor.A = 200
background := t.Color.Surface

return &Modal{
m := &Modal{
overlayColor: overlayColor,
background: background,
list: &layout.List{Axis: layout.Vertical, Alignment: layout.Middle},
button: new(widget.Clickable),
card: t.Card(),
list: &widget.List{
List: layout.List{Axis: layout.Vertical, Alignment: layout.Middle},
},
button: new(widget.Clickable),
card: t.Card(),
}

m.scroll = t.List(m.list)

return m
}

// Layout renders the modal widget to screen. The modal assumes the size of
Expand Down Expand Up @@ -84,7 +91,7 @@ func (m *Modal) Layout(gtx layout.Context, widgets []layout.Widget, margin int)
return D{}
}),
layout.Rigid(func(gtx C) D {
return m.list.Layout(gtx, len(widgetFuncs), func(gtx C, i int) D {
return m.scroll.Layout(gtx, len(widgetFuncs), func(gtx C, i int) D {
gtx.Constraints.Min.X = gtx.Constraints.Max.X
return layout.UniformInset(unit.Dp(10)).Layout(gtx, widgetFuncs[i])
})
Expand Down
13 changes: 8 additions & 5 deletions ui/page/send/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"gioui.org/layout"
"gioui.org/op"
"gioui.org/widget"

"github.com/planetdecred/godcr/ui/decredmaterial"
"github.com/planetdecred/godcr/ui/page/components"
Expand All @@ -17,9 +18,11 @@ type (
)

func (pg *Page) initLayoutWidgets() {
pg.pageContainer = layout.List{
Axis: layout.Vertical,
Alignment: layout.Middle,
pg.pageContainer = &widget.List{
List: layout.List{
Axis: layout.Vertical,
Alignment: layout.Middle,
},
}

pg.txFeeCollapsible = pg.Theme.Collapsible()
Expand Down Expand Up @@ -162,8 +165,8 @@ func (pg *Page) Layout(gtx layout.Context) layout.Dimensions {
})
}),
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: values.MarginPadding16}.Layout(gtx, func(gtx C) D {
return pg.pageContainer.Layout(gtx, len(pageContent), func(gtx C, i int) D {
return pg.Theme.List(pg.pageContainer).Layout(gtx, len(pageContent), func(gtx C, i int) D {
return layout.Inset{Bottom: values.MarginPadding16, Right: values.MarginPadding10}.Layout(gtx, func(gtx C) D {
return layout.Inset{Bottom: values.MarginPadding4, Top: values.MarginPadding4}.Layout(gtx, pageContent[i])
})
})
Expand Down
3 changes: 1 addition & 2 deletions ui/page/send/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"gioui.org/io/key"
"gioui.org/layout"
"gioui.org/widget"

"github.com/decred/dcrd/dcrutil/v3"
Expand All @@ -31,7 +30,7 @@ type moreItem struct {

type Page struct {
*load.Load
pageContainer layout.List
pageContainer *widget.List

sourceAccountSelector *components.AccountSelector
sendDestination *destination
Expand Down
1 change: 0 additions & 1 deletion ui/page/tickets/list_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ func (pg *ListPage) Layout(gtx C) D {
}

func (pg *ListPage) ticketListLayout(gtx layout.Context, tickets []*transactionItem) layout.Dimensions {
gtx.Constraints.Min = gtx.Constraints.Max
return pg.ticketsList.Layout(gtx, len(tickets), func(gtx C, index int) D {
var ticket = tickets[index]

Expand Down
2 changes: 1 addition & 1 deletion ui/page/wallet_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (pg *WalletPage) Layout(gtx layout.Context) layout.Dimensions {
body := func(gtx C) D {
return layout.Stack{Alignment: layout.SE}.Layout(gtx,
layout.Expanded(func(gtx C) D {
return pg.Theme.List(pg.container).Layout(gtx, len(pageContent), func(gtx C, i int) D {
return pg.Theme.List(pg.container).Layout(gtx, 1, func(gtx C, i int) D {
return layout.Inset{Right: values.MarginPadding10}.Layout(gtx, func(gtx C) D {
dims := pageContent[i](gtx)
if pg.isAddWalletMenuOpen || pg.openPopupIndex != -1 {
Expand Down

0 comments on commit ad24fa2

Please sign in to comment.