Skip to content

Latest commit

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Giorouter

Giorouter is package meant to simplify routing in a Gioui app.

It provides a simple API to use:

  • Push(route string)
  • Pop()
  • CanPop() bool `

Usage

typeHomestruct {
Router*giorouter.Routerclick*widget.Clickable
}
func (h*Home) Layout(gtx layout.Context, th*material.Theme) {
ifh.click.Clicked() {
h.Router.Push("about")
}
// Draw your page...
}
typeAboutstruct {
Router*giorouter.Router
}
func (a*About) Layout(gtx layout.Context, th*material.Theme) {
ifa.click.Clicked() {
a.Router.Pop()
}
// Draw your page...
}
funcmain() {
th:=material.NewTheme(gofont.Collection())
router:=giorouter.NewRouter(th)
home:=Home{Router: router}
about:=About{Router: router}
router.SetRoutes(giorouter.Routes{
"home": &home,
"about": &about,
}, "home")
gofunc() {
w:=app.NewWindow()
varops op.Opsfor {
select {
casee:=<-w.Events():
switche:=e.(type) {
case system.FrameEvent:
gtx:=layout.NewContext(&ops, e)
router.Layout(gtx) // Draw the current pagee.Frame(gtx.Ops)
case system.DestroyEvent:
os.Exit(0)
}
case<-router.C:
// Redraw the screen when the route is changingw.Invalidate()
}
}
}()
app.Main()
}

About

Giorouter is a package to handle multiple routes in Gioui easily. It provides a simple API to navigate through your app (Push, Pop, CanPop)

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages