-
Notifications
You must be signed in to change notification settings - Fork 0
/
details.go
56 lines (47 loc) · 1.35 KB
/
details.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
package main
import (
"fmt"
"log/slog"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
var (
typeLbl = widget.NewLabel("")
keyLbl = widget.NewLabel("")
valueLbl = widget.NewLabel("")
)
func makeDetails(a fyne.App, w fyne.Window) fyne.CanvasObject {
curItemBinding.AddListener(binding.NewDataListener(updateDetails))
deleteBtn := widget.NewButtonWithIcon("Delete", theme.ContentRemoveIcon(), func() {
slog.Info("clicked Delete button")
deleteSelected()
})
deleteBtn.Importance = widget.DangerImportance
return container.NewStack(container.NewVBox(
container.NewBorder(nil, nil, widget.NewLabel("Type: "), nil, typeLbl),
container.NewBorder(nil, nil, widget.NewLabel("Key: "), nil, keyLbl),
container.NewBorder(nil, nil, widget.NewLabel("Value: "), nil, valueLbl),
widget.NewSeparator(),
container.NewHBox(
widget.NewButtonWithIcon("Edit", theme.DocumentCreateIcon(), func() {
slog.Info("clicked Edit button")
editSelected(w)
}),
deleteBtn,
),
))
}
func updateDetails() {
slog.Info("updating details tab")
var item ListItem = ListItem{nil, ""}
_item, _ := curItemBinding.Get()
if _item != nil {
item = _item.(ListItem)
}
typeLbl.SetText(fmt.Sprint(item.Type))
keyLbl.SetText(item.Key)
valueLbl.SetText(fmt.Sprint(theMap[item.Key]))
}