go_dreamfactory/cmd/ptt/ui/tool_bar.go
2022-08-09 18:02:24 +08:00

42 lines
828 B
Go

package ui
import (
"fmt"
"go_dreamfactory/cmd/ptt/lib/common"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus"
)
type toolBar struct {
toolbar *widget.Toolbar
}
func newToolBar() *toolBar {
var tb toolBar
tb.toolbar = widget.NewToolbar(
widget.NewToolbarAction(theme.ComputerIcon(), func() {
openApp(common.TOOLBAR_WELCOME)
}),
widget.NewToolbarAction(theme.AccountIcon(), func() {
openApp(common.TOOLBAR_TESTER)
}),
widget.NewToolbarSeparator(),
widget.NewToolbarAction(theme.DocumentIcon(), func() {}),
)
return &tb
}
func openApp(name string) {
for _, app := range appRegister {
if app.GetAppName() == name {
err := globalWin.at.openApp(app)
if err != nil {
logrus.Error(fmt.Errorf("theme.RunAppFailedFormat", app.GetAppName(), err))
}
}
}
}