package main import ( "image/color" "log" "os" "gioui.org/app" "gioui.org/font/gofont" "gioui.org/io/system" "gioui.org/layout" "gioui.org/op" "gioui.org/text" "gioui.org/unit" "gioui.org/widget" "gioui.org/widget/material" ) type Limox struct { Button widget.Clickable Window *app.Window Operations op.Ops Theme *material.Theme } func main() { limox := NewLimox() go func() { err := limox.run() if err != nil { log.Fatal(err) } os.Exit(0) }() app.Main() } func NewLimox() Limox { return Limox{ Window: app.NewWindow( app.Title("LimoX"), app.Size(unit.Dp(400), unit.Dp(600)), ), Operations: op.Ops{}, Theme: material.NewTheme(gofont.Collection()), } } func (l *Limox) run() error { for { e := <-l.Window.Events() switch e := e.(type) { case system.DestroyEvent: return e.Err case system.FrameEvent: l.draw(e) } } } func (l *Limox) draw(e system.FrameEvent) { gtx := layout.NewContext(&l.Operations, e) 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) }