diff options
-rw-r--r-- | go/main.go | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -12,11 +12,12 @@ import ( "gioui.org/op" "gioui.org/text" "gioui.org/unit" + "gioui.org/widget" "gioui.org/widget/material" ) type Limox struct { - ConnState string + Button widget.Clickable Window *app.Window Operations op.Ops Theme *material.Theme @@ -38,7 +39,6 @@ func main() { func NewLimox() Limox { return Limox{ - ConnState: "disconnected", Window: app.NewWindow( app.Title("LimoX"), app.Size(unit.Dp(400), unit.Dp(600)), @@ -63,10 +63,27 @@ func (l *Limox) run() error { func (l *Limox) draw(e system.FrameEvent) { gtx := layout.NewContext(&l.Operations, e) - stateLabel := material.H3(l.Theme, l.ConnState) - stateLabel.Color = color.NRGBA{R: 0, G: 212, B: 0, A: 255} - stateLabel.Alignment = text.Middle - stateLabel.Layout(gtx) + flex := layout.Flex{ + Axis: layout.Vertical, + Spacing: layout.SpaceBetween, + } + + flex.Layout(gtx, + layout.Rigid( + func(gtx layout.Context) layout.Dimensions { + stateLabel := material.H2(l.Theme, "LimoX") + stateLabel.Color = color.NRGBA{R: 20, G: 20, B: 20, A: 255} + stateLabel.Alignment = text.Middle + return stateLabel.Layout(gtx) + }, + ), + layout.Rigid( + func(gtx layout.Context) layout.Dimensions { + btn := material.Button(l.Theme, &l.Button, "connect") + return btn.Layout(gtx) + }, + ), + ) e.Frame(gtx.Ops) } |