-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.go
More file actions
59 lines (46 loc) · 1.48 KB
/
ui.go
File metadata and controls
59 lines (46 loc) · 1.48 KB
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
package main
import (
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
)
func (app *Config) makeUI() {
// get the current price of gold
openPrice, currentPrice, priceChange := app.GetPriceText()
// put price information into a container
priceContent := container.NewGridWithColumns(3, openPrice, currentPrice, priceChange)
app.PriceContainer = priceContent
// get toolbar
toolbar := app.getToolBar()
app.Toolbar = toolbar
priceTabContent := app.pricesTab()
holdingsTabContent := app.holdingsTab()
// get app tabs
tabs := container.NewAppTabs(
container.NewTabItemWithIcon("Prices", theme.HomeIcon(), priceTabContent),
container.NewTabItemWithIcon("Holdings", theme.InfoIcon(), holdingsTabContent),
)
tabs.SetTabLocation(container.TabLocationTop)
// add container to the window
finalContent := container.NewVBox(priceContent, toolbar, tabs)
app.MainWindow.SetContent(finalContent)
go func() {
for range time.Tick(time.Second * 30) {
app.refreshPriceContent()
}
}()
}
func (app *Config) refreshPriceContent() {
app.InfoLog.Println("Refreshing prices")
open, current, change := app.GetPriceText()
app.PriceContainer.Objects = []fyne.CanvasObject{open, current, change}
app.PriceContainer.Refresh()
chart := app.getChart()
app.PriceChartContainer.Objects = []fyne.CanvasObject{chart}
app.PriceChartContainer.Refresh()
}
func (app *Config) refreshHoldingsTable() {
app.Holdings = app.getHoldingSlice()
app.HoldingsTable.Refresh()
}