Skip to content

Commit

Permalink
use vertical flex for buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
habuvo committed Apr 16, 2024
1 parent 27ea533 commit cc40e86
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ require (
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 // indirect
gioui.org/shader v1.0.8 // indirect
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372 // indirect
github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636 // indirect
github.com/shurcooL/go-goon v1.0.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91 // indirect
golang.org/x/image v0.10.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372 h1:FQivqchis6b
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k=
github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22 h1:LBQTFxP2MfsyEDqSKmUBZaDuDHN1vpqDyOZjcqS7MYI=
github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o=
github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636 h1:aSISeOcal5irEhJd1M+IrApc0PdcN7e7Aj4yuEnOrfQ=
github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
github.com/shurcooL/go-goon v1.0.0 h1:BCQPvxGkHHJ4WpBO4m/9FXbITVIsvAm/T66cCcCGI7E=
github.com/shurcooL/go-goon v1.0.0/go.mod h1:2wTHMsGo7qnpmqA8ADYZtP4I1DD94JpXGQ3Dxq2YQ5w=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
Expand Down
48 changes: 22 additions & 26 deletions mainwidget.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,35 +102,31 @@ func mainWidget(gtx layout.Context, th *material.Theme) layout.Dimensions {
return material.Button(th, cancelButton, "cancel").Layout(gtx)
})
}),
layout.Rigid(layout.Spacer{Height: unit.Dp(10)}.Layout),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return in.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.Flex{}.
Layout(gtx,
layout.Rigid(material.RadioButton(th, bidaskGroup, "bid", "bid").Layout),
layout.Rigid(material.RadioButton(th, bidaskGroup, "ask", "ask").Layout),
layout.Flexed(10, func(gtx layout.Context) layout.Dimensions {
l := material.Label(th, 18, orderAsset)
l.Alignment = text.Alignment(layout.Middle)
return l.Layout(gtx)
}),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
e := material.Editor(th, &amountInput, "amount")
e.Font.Style = font.Italic
border := widget.Border{Color: color.NRGBA{A: 0xff}, CornerRadius: unit.Dp(8), Width: unit.Dp(2)}
return border.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.UniformInset(unit.Dp(8)).Layout(gtx, e.Layout)
})
}),
)
})
}),
)
})
}),
layout.Rigid(
layout.Spacer{Height: unit.Dp(25)}.Layout,
),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return in.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.Flex{Spacing: layout.SpaceAround, Alignment: layout.Middle}.
Layout(gtx,
layout.Flexed(10, material.RadioButton(th, bidaskGroup, "bid", "bid").Layout),
layout.Flexed(10, material.RadioButton(th, bidaskGroup, "ask", "ask").Layout),
layout.Flexed(10, func(gtx layout.Context) layout.Dimensions {
l := material.Label(th, 18, orderAsset)
l.Alignment = text.Alignment(layout.Middle)
return l.Layout(gtx)
}),
layout.Flexed(10, func(gtx layout.Context) layout.Dimensions {
e := material.Editor(th, &amountInput, "amount")
e.Font.Style = font.Italic
border := widget.Border{Color: color.NRGBA{A: 0xff}, CornerRadius: unit.Dp(8), Width: unit.Dp(2)}
return border.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.UniformInset(unit.Dp(8)).Layout(gtx, e.Layout)
})
}),
)
})
}),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return border.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.Flex{Alignment: layout.Baseline}.Layout(gtx,
Expand Down

0 comments on commit cc40e86

Please sign in to comment.