go-xkcdreader/xkcdreader/app.go
surtur e669770871
All checks were successful
continuous-integration/drone/push Build is passing
app: create a toolbar
2022-05-23 00:49:04 +02:00

54 lines
1.3 KiB
Go

// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
package xkcdreader
import (
"log"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"git.dotya.ml/wanderer/go-xkcdreader/cmd"
)
const appGreeting = "welcome to go-xkcdreader"
// RunApp performs sets up and runs the main application
func RunApp() {
a := app.New()
w := a.NewWindow(cmd.GetAppName())
centered := container.New(layout.NewHBoxLayout(), layout.NewSpacer(), makeGreeting(), layout.NewSpacer())
w.SetContent(container.New(layout.NewVBoxLayout(), makeToolbar(), centered))
w.Resize(fyne.NewSize(400, 400))
w.ShowAndRun()
}
// makeGreeting creates a greeting label
func makeGreeting() *widget.Label {
w := widget.NewLabel(appGreeting)
w.TextStyle.Monospace = true
return w
}
func makeToolbar() *widget.Toolbar {
toolbar := widget.NewToolbar(
widget.NewToolbarAction(theme.SearchIcon(), func() {
log.Println("Search")
}),
widget.NewToolbarSpacer(),
widget.NewToolbarAction(theme.HelpIcon(), func() {
log.Println("Display help")
}),
widget.NewToolbarAction(theme.SettingsIcon(), func() {
log.Println("Display settings")
}),
)
return toolbar
}