Quickstart
A themed window with a button, in one file.
NewTheme builds the one Theme instance — palette plus the embedded
DM Sans font. Pass it to every component. The event loop is plain Gio: paint the canvas,
lay out content in the readable column, hand the frame back.
A minimal app
package main
import (
"log"
"os"
"gioui.org/app"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/widget"
lotusui "github.com/ikaito-com/lotusui"
)
func main() {
go func() {
w := new(app.Window)
w.Option(app.Title("hello"))
if err := loop(w); err != nil {
log.Fatal(err)
}
os.Exit(0)
}()
app.Main()
}
func loop(w *app.Window) error {
th := lotusui.NewTheme()
var btn widget.Clickable
var ops op.Ops
for {
switch e := w.Event().(type) {
case app.DestroyEvent:
return e.Err
case app.FrameEvent:
gtx := app.NewContext(&ops, e)
lotusui.Fill(gtx, th.Palette.Bg)
lotusui.LayoutPage(gtx, func(gtx layout.Context) layout.Dimensions {
return lotusui.Button(th, &btn, "Hello", lotusui.ButtonOpts{})(gtx)
})
e.Frame(gtx.Ops)
}
}
}