-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (36 loc) · 1.11 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
package main
import (
"log"
"net/http"
"os"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
_ "github.com/glebarez/go-sqlite" // embedded db for local storage
ui "github.com/simon-lentz/marketwatcher/ui"
)
func main() {
var myApp ui.Config
//create a fyne app
fyneApp := app.NewWithID("placeholder")
myApp.App = fyneApp
myApp.HTTPClient = &http.Client{}
// create loggers
myApp.InfoLog = log.New(os.Stdout, "INFO\t", log.Ldate|log.Ltime)
myApp.ErrorLog = log.New(os.Stdout, "ERROR\t", log.Ldate|log.Ltime|log.Lshortfile)
// open a connection to db
db, err := myApp.ConnectDB()
if err != nil {
log.Panic(err) // if db can't be written then the app will fail to run
}
// create a db repo
myApp.InitDB(db)
fyneApp.Preferences().StringWithFallback("Currency", "USD")
// create and size a fyne window
myApp.MainWindow = fyneApp.NewWindow("MarketWatcher")
myApp.MainWindow.Resize(fyne.Size{Height: 800, Width: 1000})
myApp.MainWindow.SetFixedSize(true) // to be removed later for dynamic ui sizing
myApp.MainWindow.SetMaster()
myApp.MakeUI()
// show and run the application
myApp.MainWindow.ShowAndRun()
}