Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tsukinoko-kun/fyneflow

Dialog flow for fyne v2
https://github.com/tsukinoko-kun/fyneflow

fyne golang golang-library gui ui-library

Last synced: about 1 month ago
JSON representation

Dialog flow for fyne v2

Awesome Lists containing this project

README

        

# fyneflow

Dialog flow for fyne v2

This library manages the content state of a `fyne.Window`

## Install

```bash
go get -u github.com/tsukinoko-kun/fyneflow
```

## Usage

```go
package main

import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"github.com/tsukinoko-kun/fyneflow"
)

const (
FlowKeyA = iota
FlowKeyB
)

func main() {
a := app.New()
w := a.NewWindow("Flow Test")

// wrap the fyne.Window using a flow
// the generic type is the type for the flow keys
flow := fyneflow.NewFlow(w)
defer flow.Close()

// add an item to the flow with the key A
flow.Set(FlowKeyA, func(flow *fyneflow.Flow) fyne.CanvasObject {
// use flow shared data of key "txt"
return container.NewVBox(
widget.NewLabel("I am A"),
widget.NewButton("Go to B", func() {
// swich to flow item with key B
if err := flow.GoTo(FlowKeyB); err != nil {
panic(err)
}
}),
)
})

// add an item to the flow with the key B
flow.Set(FlowKeyB, func(flow *fyneflow.Flow) fyne.CanvasObject {
// use flow shared data of key "txt"
return container.NewVBox(
widget.NewLabel("I am B"),
widget.NewButton("Go to A", func() {
// swich to flow item with key A
if err := flow.GoTo(FlowKeyA); err != nil {
panic(err)
}
}),
)
})

// display the window
w.ShowAndRun()
}
```