package ui import ( "fmt" "os" "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" ) type UI struct { Options *Options mw *fyne.Window } func New(op ...Option) GUIApp { opts := &Options{} for _, o := range op { o(opts) } if err := opts.Validate(); err != nil { panic(fmt.Errorf("init ui failed: %v", err)) } //fyne a := app.New() w := a.NewWindow(fmt.Sprintf("%v %v", opts.Name, opts.Version)) lable1 := widget.NewLabel(fmt.Sprintf("Listening at %v", opts.Port)) lable2 := widget.NewLabel("Running") w.SetContent(container.NewVBox( lable1, lable2, )) w.Resize(fyne.NewSize(240, 120)) return &UI{ Options: opts, mw: &w, } } func (u *UI) Run(exitCh chan os.Signal) int { window := *u.mw window.ShowAndRun() return 0 } func (u *UI) Close() { window := *u.mw window.Close() }