2021-08-26 04:18:24 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fyne.io/fyne/v2/app"
|
|
|
|
"fyne.io/fyne/v2/container"
|
2021-10-24 20:27:14 +00:00
|
|
|
"go.arsenm.dev/itd/api"
|
2021-08-26 04:18:24 +00:00
|
|
|
)
|
|
|
|
|
2021-10-24 20:27:14 +00:00
|
|
|
var onClose []func()
|
2021-08-26 04:18:24 +00:00
|
|
|
|
|
|
|
func main() {
|
2021-08-26 15:47:17 +00:00
|
|
|
// Create new app
|
2021-08-26 04:18:24 +00:00
|
|
|
a := app.New()
|
2021-08-26 15:47:17 +00:00
|
|
|
// Create new window with title "itgui"
|
2021-08-26 04:18:24 +00:00
|
|
|
window := a.NewWindow("itgui")
|
2021-10-24 20:27:14 +00:00
|
|
|
window.SetOnClosed(func() {
|
|
|
|
for _, closeFn := range onClose {
|
|
|
|
closeFn()
|
|
|
|
}
|
|
|
|
})
|
2021-08-26 04:18:24 +00:00
|
|
|
|
2021-10-24 20:27:14 +00:00
|
|
|
client, err := api.New(api.DefaultAddr)
|
2021-08-27 15:47:24 +00:00
|
|
|
if err != nil {
|
2021-10-24 20:27:14 +00:00
|
|
|
guiErr(err, "Error connecting to itd", true, window)
|
2021-08-27 15:47:24 +00:00
|
|
|
}
|
2021-10-24 20:27:14 +00:00
|
|
|
onClose = append(onClose, func() {
|
|
|
|
client.Close()
|
|
|
|
})
|
2021-08-27 15:47:24 +00:00
|
|
|
|
2021-08-26 15:47:17 +00:00
|
|
|
// Create new app tabs container
|
2021-08-26 04:18:24 +00:00
|
|
|
tabs := container.NewAppTabs(
|
2021-10-24 20:27:14 +00:00
|
|
|
container.NewTabItem("Info", infoTab(window, client)),
|
2021-10-25 16:45:19 +00:00
|
|
|
container.NewTabItem("Motion", motionTab(window, client)),
|
2021-10-24 20:27:14 +00:00
|
|
|
container.NewTabItem("Notify", notifyTab(window, client)),
|
|
|
|
container.NewTabItem("Set Time", timeTab(window, client)),
|
|
|
|
container.NewTabItem("Upgrade", upgradeTab(window, client)),
|
2021-08-26 04:18:24 +00:00
|
|
|
)
|
|
|
|
|
2021-08-26 15:47:17 +00:00
|
|
|
// Set tabs as window content
|
2021-08-26 04:18:24 +00:00
|
|
|
window.SetContent(tabs)
|
2021-08-26 15:47:17 +00:00
|
|
|
// Show window and run app
|
2021-08-26 04:18:24 +00:00
|
|
|
window.ShowAndRun()
|
|
|
|
}
|