diff options
author | xengineering <me@xengineering.eu> | 2023-04-11 20:54:59 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-04-11 20:56:19 +0200 |
commit | 58c8ae6edee39192589d9e754c053c4cf2b9d961 (patch) | |
tree | 53c2495c949c3fab2b6e499a6ee7dcee649faa9a /go | |
parent | 42c4332e628bc1380ac2559fca69ed0c949db730 (diff) | |
download | limox-58c8ae6edee39192589d9e754c053c4cf2b9d961.tar limox-58c8ae6edee39192589d9e754c053c4cf2b9d961.tar.zst limox-58c8ae6edee39192589d9e754c053c4cf2b9d961.zip |
Turn label to headline and add button
These elements should be part of the initial view.
Diffstat (limited to 'go')
-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) } |