-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
86 lines (73 loc) · 2.51 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"fmt"
"log"
"net/url"
"fyne.io/fyne"
"fyne.io/fyne/app"
"fyne.io/fyne/canvas"
"fyne.io/fyne/layout"
"fyne.io/fyne/theme"
"fyne.io/fyne/widget"
)
var db *Db
type App struct {
app fyne.App
db *Db
window fyne.Window
}
func welcomeScreen(a fyne.App) fyne.CanvasObject {
logo := canvas.NewImageFromResource(theme.FyneLogo())
logo.SetMinSize(fyne.NewSize(128, 128))
link, err := url.Parse("https://fyne.io/")
if err != nil {
fyne.LogError("Could not parse URL", err)
}
return widget.NewVBox(
widget.NewLabelWithStyle("Welcome to the Fyne toolkit demo app", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}),
layout.NewSpacer(),
widget.NewHBox(layout.NewSpacer(), logo, layout.NewSpacer()),
widget.NewHyperlinkWithStyle("fyne.io", link, fyne.TextAlignCenter, fyne.TextStyle{}),
layout.NewSpacer(),
widget.NewGroup("Theme",
fyne.NewContainerWithLayout(layout.NewGridLayout(2),
widget.NewButton("Dark", func() {
a.Settings().SetTheme(theme.DarkTheme())
}),
widget.NewButton("Light", func() {
a.Settings().SetTheme(theme.LightTheme())
}),
),
),
)
}
func main() {
var err error
var application App
application.db, err = NewDb("fixtures/test.sqlite3")
if err != nil {
log.Fatal(err.Error())
}
defer application.db.connection.Close()
application.app = app.New()
application.window = application.app.NewWindow("Stratosphere - free software for your watch")
application.window.SetMainMenu(fyne.NewMainMenu(fyne.NewMenu("File",
fyne.NewMenuItem("New", func() { fmt.Println("Menu New") }),
// a quit item will be appended to our first menu
), fyne.NewMenu("Edit",
fyne.NewMenuItem("Cut", func() { fmt.Println("Menu Cut") }),
fyne.NewMenuItem("Copy", func() { fmt.Println("Menu Copy") }),
fyne.NewMenuItem("Paste", func() { fmt.Println("Menu Paste") }),
)))
tabs := widget.NewTabContainer(
//widget.NewTabItemWithIcon("Welcome", theme.HomeIcon(), welcomeScreen(a)),
widget.NewTabItemWithIcon("Activities", theme.ContentCopyIcon(), ActivitiesScreen(application)),
widget.NewTabItemWithIcon("Widgets", theme.ContentCopyIcon(), WidgetScreen()),
widget.NewTabItemWithIcon("Graphics", theme.DocumentCreateIcon(), GraphicsScreen()),
widget.NewTabItemWithIcon("Windows", theme.ViewFullScreenIcon(), DialogScreen(application.window)),
widget.NewTabItemWithIcon("Advanced", theme.SettingsIcon(), AdvancedScreen(application.window)),
)
tabs.SetTabLocation(widget.TabLocationLeading)
application.window.SetContent(tabs)
application.window.ShowAndRun()
}