Hello, Gio level
The same idea as Hello, declarative, written against ImmyGo's lower-level widgets and Gio's layout API.
Run it on your machine:
go run github.com/amken3d/immygo/examples/hello@latestSource
// Package hello is the hello example's app, as a package so that// other programs (the immygo.app demo bundle) can run it. main.go runs it.package hello
import ( "fmt"
"gioui.org/layout"
"github.com/amken3d/immygo/app" immylayout "github.com/amken3d/immygo/layout" "github.com/amken3d/immygo/theme" "github.com/amken3d/immygo/widget")
var clickCount intvar btn = widget.NewButton("Click Me!"). WithVariant(widget.ButtonPrimary). WithOnClick(func() { clickCount++ fmt.Printf("Clicked %d times\n", clickCount) })
// Main runs the example. It blocks until the window closes.func Main() { app.New("Hello ImmyGo"). WithSize(600, 400). WithLayout(func(gtx layout.Context, th *theme.Theme) layout.Dimensions { return immylayout.Center{}.Layout(gtx, func(gtx layout.Context) layout.Dimensions { return immylayout.NewVStack().WithSpacing(20). WithAlignment(immylayout.AlignCenter). Child(func(gtx layout.Context) layout.Dimensions { return widget.H1("Hello, ImmyGo!").Layout(gtx, th) }). Child(func(gtx layout.Context) layout.Dimensions { return widget.Body("Build beautiful Go UIs with ease.").Layout(gtx, th) }). Child(func(gtx layout.Context) layout.Dimensions { return btn.Layout(gtx, th) }). Child(func(gtx layout.Context) layout.Dimensions { msg := fmt.Sprintf("Clicks: %d", clickCount) return widget.Caption(msg).Layout(gtx, th) }). Layout(gtx) }) }). Run()}// Command hello is the simplest possible ImmyGo application.// It creates a window with centered text and a button.package main
import "github.com/amken3d/immygo/examples/hello/hello"
func main() { hello.Main() }