-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.go
74 lines (62 loc) · 1.73 KB
/
prefs.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
package windows
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
"github.com/chooban/progger/exporter/app"
"github.com/chooban/progger/exporter/prefs"
)
type cb func()
func NewSettingsCanvas(a *app.ProggerApp) fyne.CanvasObject {
fyneApp := a.FyneApp
allSettings := container.New(
layout.NewVBoxLayout(),
directoriesContainer(fyneApp, a.RootWindow),
widget.NewSeparator(),
rebellionContainer(fyneApp),
)
return allSettings
}
func rebellionContainer(a fyne.App) *fyne.Container {
pass := widget.NewPasswordEntry()
pass.Bind(prefs.BoundRebellionPassword(a))
formContainer := container.New(
layout.NewVBoxLayout(),
widget.NewLabel("Rebellion Account"),
container.New(
layout.NewFormLayout(),
widget.NewLabel("Username"),
widget.NewEntryWithData(prefs.BoundRebellionUsername(a)),
widget.NewLabel("Password"),
pass,
),
)
return formContainer
}
func directoriesContainer(a fyne.App, w fyne.Window) *fyne.Container {
boundSource := prefs.BoundSourceDir(a)
boundExport := prefs.BoundExportDir(a)
directoriesFormContainer := container.New(
layout.NewFormLayout(),
widget.NewLabelWithData(boundSource),
widget.NewButton("Choose Input Directory", func() {
dialog.ShowFolderOpen(func(l fyne.ListableURI, err error) {
boundSource.Set(l.Path())
}, w)
}),
widget.NewLabelWithData(boundExport),
widget.NewButton("Choose Export Directory", func() {
dialog.ShowFolderOpen(func(l fyne.ListableURI, err error) {
boundExport.Set(l.Path())
}, w)
}),
)
directoriesContainer := container.New(
layout.NewVBoxLayout(),
widget.NewLabel("Directories"),
directoriesFormContainer,
)
return directoriesContainer
}