-
Notifications
You must be signed in to change notification settings - Fork 0
/
activities.go
54 lines (43 loc) · 1.49 KB
/
activities.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
package main
import (
"strconv"
"fyne.io/fyne"
"fyne.io/fyne/canvas"
"fyne.io/fyne/dialog"
"fyne.io/fyne/layout"
"fyne.io/fyne/widget"
)
func activityDetails(activity *Activity) *widget.Group {
generic := widget.NewGroupWithScroller("Values")
generic.Prepend(widget.NewLabel("Activity Id: " + strconv.Itoa(activity.Id)))
// TODO: generate image only when user clicks on activity. we don't want to make loading slow
// Consider caching images
activity.GenerateMap()
mapImg := canvas.NewImageFromImage(activity.Image)
mapImg.SetMinSize(fyne.NewSize(MapWidth, MapHeight))
generic.Prepend(widget.NewHBox(layout.NewSpacer(), mapImg, layout.NewSpacer()))
return generic
}
func makeActivitiesList(application App) fyne.Widget {
activityList := []*widget.TabItem{}
activities, err := application.db.Activities()
if err != nil {
dialog.ShowError(err, application.window)
}
for _, activity := range activities {
activityList = append(activityList,
widget.NewTabItemWithIcon(activity.Content.StartTimeStr(), nil, activityDetails(activity)),
)
}
activityTabs := widget.NewTabContainer(activityList...)
activityTabs.SetTabLocation(widget.TabLocationLeading)
scroll := widget.NewScrollContainer(activityTabs)
scroll.Resize(fyne.NewSize(200, 200))
return scroll
}
// WidgetScreen shows a panel containing widget demos
func ActivitiesScreen(application App) fyne.CanvasObject {
return fyne.NewContainerWithLayout(layout.NewBorderLayout(nil, nil, nil, nil),
makeActivitiesList(application),
)
}