-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
121 lines (87 loc) · 2.42 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package main
import (
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2"
ui "io.tualo.bp/ui"
theme "io.tualo.bp/ui/theme"
config "io.tualo.bp/config"
grab "io.tualo.bp/grab"
globals "io.tualo.bp/globals"
api "io.tualo.bp/api"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"log"
)
var topWindow fyne.Window
var loginContainer *fyne.Container
var cameraContainer *fyne.Container
var mainScreenClass *ui.MainScreenClass
var loginScreenClass *ui.LoginScreenClass
var settingsScreenClass *ui.SettingsScreenClass
var configData *config.ConfigurationClass
var g *globals.GlobalValuesClass
var appID = "io.tualo.bp"
func main() {
configData = config.NewConfigurationClass()
configData.SetAppID(appID)
configData.Load()
g = globals.NewGlobalValuesClass()
g.SetDefaults()
log.Println("globals",g)
g.ConfigData = configData
g.Load()
log.Println("globals",g)
grabber := grab.NewGrabcameraClass()
grabber.SetGlobalValues( g )
a := app.NewWithID(appID)
w := a.NewWindow("tualo - ballot scanner")
topWindow = w
fyne.CurrentApp().Settings().SetTheme(theme.DefaultTheme())
loginScreenClass = ui.NewLoginScreenClass()
loginScreenClass.SetConfig(configData)
loginScreenClass.SetOnLogin(func(name string) {
loginContainer.Hide()
cameraContainer.Show()
mainScreenClass.SetFullName(name)
})
loginContainer = loginScreenClass.CreateContainer()
mainScreenClass = ui.NewMainScreenClass()
mainScreenClass.SetGlobals(g)
startStop:=func() {
if !mainScreenClass.GetPlayState() {
conf,err := api.GetConfig()
if err != nil {
log.Println("GetConfig ERROR",err)
return
}
log.Println("GetConfig",conf)
log.Println("GetConfig ROIS",conf[0].Rois)
grabber.SetDocumentConfigurations(conf)
}
mainScreenClass.SetChannel(grabber.GetChannel())
grabber.SetRun(!mainScreenClass.GetPlayState())
mainScreenClass.SetPlayState(!mainScreenClass.GetPlayState())
}
cameraContainer = mainScreenClass.CreateContainer(startStop)
mainScreenClass.SetOnLogout(func( ) {
cameraContainer.Hide()
loginContainer.Show()
})
content := container.New(
layout.NewStackLayout(),
loginContainer,
cameraContainer,
)
loginContainer.Show()
cameraContainer.Hide()
w.SetContent(content)
w.SetMaster()
w.Canvas().SetOnTypedKey(func(k *fyne.KeyEvent) {
log.Println(k.Name)
if (cameraContainer.Visible()){
mainScreenClass.OnTypedKey(k,startStop)
}
})
w.Resize(fyne.NewSize(640, 460))
w.ShowAndRun()
}