• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fyne-io / fyne / 18807176232

25 Oct 2025 06:34PM UTC coverage: 61.057% (-0.004%) from 61.061%
18807176232

Pull #5989

github

Jacalz
Fix TODO regarding comparable map key
Pull Request #5989: RFC: Proof of concept for upgrading Go to 1.24

155 of 188 new or added lines in 62 files covered. (82.45%)

27 existing lines in 6 files now uncovered.

25609 of 41943 relevant lines covered (61.06%)

692.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cmd/fyne_demo/tutorials/collection.go
1
package tutorials
2

3
import (
4
        "fmt"
5
        "strconv"
6

7
        "fyne.io/fyne/v2"
8
        "fyne.io/fyne/v2/container"
9
        "fyne.io/fyne/v2/theme"
10
        "fyne.io/fyne/v2/widget"
11
)
12

13
// collectionScreen loads a tab panel for collection widgets
14
func collectionScreen(_ fyne.Window) fyne.CanvasObject {
×
15
        content := container.NewVBox(
×
16
                widget.NewLabelWithStyle("func Length() int", fyne.TextAlignLeading, fyne.TextStyle{Monospace: true}),
×
17
                widget.NewLabelWithStyle("func CreateItem() fyne.CanvasObject", fyne.TextAlignLeading, fyne.TextStyle{Monospace: true}),
×
18
                widget.NewLabelWithStyle("func UpdateItem(ListItemID, fyne.CanvasObject)", fyne.TextAlignLeading, fyne.TextStyle{Monospace: true}),
×
19
                widget.NewLabelWithStyle("func OnSelected(ListItemID)", fyne.TextAlignLeading, fyne.TextStyle{Monospace: true}),
×
20
                widget.NewLabelWithStyle("func OnUnselected(ListItemID)", fyne.TextAlignLeading, fyne.TextStyle{Monospace: true}))
×
21
        return container.NewCenter(content)
×
22
}
×
23

24
func makeGridWrapTab(_ fyne.Window) fyne.CanvasObject {
×
25
        data := make([]string, 1000)
×
26
        for i := range data {
×
27
                data[i] = "Test Item " + strconv.Itoa(i)
×
28
        }
×
29

30
        icon := widget.NewIcon(nil)
×
31
        label := widget.NewLabel("Select An Item From The List")
×
32
        vbox := container.NewVBox(icon, label)
×
33

×
34
        grid := widget.NewGridWrap(
×
35
                func() int {
×
36
                        return len(data)
×
37
                },
×
38
                func() fyne.CanvasObject {
×
39
                        text := widget.NewLabel("Template Object")
×
40
                        text.Alignment = fyne.TextAlignCenter
×
41
                        return container.NewVBox(container.NewPadded(widget.NewIcon(theme.DocumentIcon())), text)
×
42
                },
×
43
                func(id widget.ListItemID, item fyne.CanvasObject) {
×
44
                        item.(*fyne.Container).Objects[1].(*widget.Label).SetText(data[id])
×
45
                },
×
46
        )
47
        grid.OnSelected = func(id widget.ListItemID) {
×
48
                label.SetText(data[id])
×
49
                icon.SetResource(theme.DocumentIcon())
×
50
        }
×
51
        grid.OnUnselected = func(id widget.ListItemID) {
×
52
                label.SetText("Select An Item From The List")
×
53
                icon.SetResource(nil)
×
54
        }
×
55
        grid.Select(15)
×
56

×
57
        split := container.NewHSplit(grid, container.NewCenter(vbox))
×
58
        split.Offset = 0.6
×
59
        return split
×
60
}
61

62
func makeListTab(_ fyne.Window) fyne.CanvasObject {
×
63
        data := make([]string, 1000)
×
64
        for i := range data {
×
65
                data[i] = "Test Item " + strconv.Itoa(i)
×
66
        }
×
67

68
        icon := widget.NewIcon(nil)
×
69
        label := widget.NewLabel("Select An Item From The List")
×
70
        hbox := container.NewHBox(icon, label)
×
71

×
72
        list := widget.NewList(
×
73
                func() int {
×
74
                        return len(data)
×
75
                },
×
76
                func() fyne.CanvasObject {
×
77
                        return container.NewHBox(widget.NewIcon(theme.DocumentIcon()), widget.NewLabel("Template Object"))
×
78
                },
×
79
                func(id widget.ListItemID, item fyne.CanvasObject) {
×
80
                        if id == 5 || id == 6 {
×
81
                                item.(*fyne.Container).Objects[1].(*widget.Label).SetText(data[id] + "\ntaller")
×
82
                        } else {
×
83
                                item.(*fyne.Container).Objects[1].(*widget.Label).SetText(data[id])
×
84
                        }
×
85
                },
86
        )
87
        list.OnSelected = func(id widget.ListItemID) {
×
88
                label.SetText(data[id])
×
89
                icon.SetResource(theme.DocumentIcon())
×
90
        }
×
91
        list.OnUnselected = func(id widget.ListItemID) {
×
92
                label.SetText("Select An Item From The List")
×
93
                icon.SetResource(nil)
×
94
        }
×
95
        list.Select(125)
×
96
        list.SetItemHeight(5, 50)
×
97
        list.SetItemHeight(6, 50)
×
98

×
99
        return container.NewHSplit(list, container.NewCenter(hbox))
×
100
}
101

102
func makeTableTab(_ fyne.Window) fyne.CanvasObject {
×
103
        t := widget.NewTableWithHeaders(
×
104
                func() (int, int) { return 500, 150 },
×
105
                func() fyne.CanvasObject {
×
106
                        return widget.NewLabel("Cell 000, 000")
×
107
                },
×
108
                func(id widget.TableCellID, cell fyne.CanvasObject) {
×
109
                        label := cell.(*widget.Label)
×
110
                        switch id.Col {
×
111
                        case 0:
×
112
                                label.SetText("A longer cell")
×
113
                        default:
×
114
                                label.SetText(fmt.Sprintf("Cell %d, %d", id.Row+1, id.Col+1))
×
115
                        }
116
                })
117
        t.SetColumnWidth(0, 102)
×
118
        t.SetRowHeight(2, 50)
×
119
        return t
×
120
}
121

122
func makeTreeTab(_ fyne.Window) fyne.CanvasObject {
×
123
        data := map[string][]string{
×
124
                "":  {"A"},
×
125
                "A": {"B", "D", "H", "J", "L", "O", "P", "S", "V", "Z"},
×
126
                "B": {"C"},
×
127
                "C": {"abc"},
×
128
                "D": {"E"},
×
129
                "E": {"F", "G"},
×
130
                "F": {"adef"},
×
131
                "G": {"adeg"},
×
132
                "H": {"I"},
×
133
                "I": {"ahi"},
×
134
                "O": {"ao"},
×
135
                "P": {"Q"},
×
136
                "Q": {"R"},
×
137
                "R": {"apqr"},
×
138
                "S": {"T"},
×
139
                "T": {"U"},
×
140
                "U": {"astu"},
×
141
                "V": {"W"},
×
142
                "W": {"X"},
×
143
                "X": {"Y"},
×
144
                "Y": {"zzz"},
×
145
                "Z": {},
×
146
        }
×
147

×
148
        childlen := 10000
×
149
        z := make([]string, childlen)
×
NEW
150
        for i := range childlen {
×
151
                z[i] = strconv.Itoa(i)
×
152
        }
×
153
        data["Z"] = z
×
154

×
155
        tree := widget.NewTreeWithStrings(data)
×
156
        tree.OnSelected = func(id string) {
×
157
                fmt.Println("Tree node selected:", id)
×
158
        }
×
159
        tree.OnUnselected = func(id string) {
×
160
                fmt.Println("Tree node unselected:", id)
×
161
        }
×
162
        tree.OpenBranch("A")
×
163
        tree.OpenBranch("D")
×
164
        tree.OpenBranch("E")
×
165
        tree.OpenBranch("L")
×
166
        tree.OpenBranch("M")
×
167
        return tree
×
168
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc