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

fyne-io / fyne / 13019330289

28 Jan 2025 08:51PM UTC coverage: 60.843% (+1.7%) from 59.13%
13019330289

push

github

web-flow
Merge pull request #5474 from Jacalz/generic-list-bindings

160 of 222 new or added lines in 2 files covered. (72.07%)

18 existing lines in 4 files now uncovered.

24981 of 41058 relevant lines covered (60.84%)

796.51 hits per line

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

9.52
/data/binding/bindlists.go
1
package binding
2

3
import (
4
        "bytes"
5

6
        "fyne.io/fyne/v2"
7
)
8

9
// BoolList supports binding a list of bool values.
10
//
11
// Since: 2.0
12
type BoolList interface {
13
        DataList
14

15
        Append(value bool) error
16
        Get() ([]bool, error)
17
        GetValue(index int) (bool, error)
18
        Prepend(value bool) error
19
        Remove(value bool) error
20
        Set(list []bool) error
21
        SetValue(index int, value bool) error
22
}
23

24
// ExternalBoolList supports binding a list of bool values from an external variable.
25
//
26
// Since: 2.0
27
type ExternalBoolList interface {
28
        BoolList
29

30
        Reload() error
31
}
32

33
// NewBoolList returns a bindable list of bool values.
34
//
35
// Since: 2.0
36
func NewBoolList() BoolList {
×
NEW
37
        return newListComparable[bool]()
×
38
}
×
39

40
// BindBoolList returns a bound list of bool values, based on the contents of the passed slice.
41
// If your code changes the content of the slice this refers to you should call Reload() to inform the bindings.
42
//
43
// Since: 2.0
44
func BindBoolList(v *[]bool) ExternalBoolList {
×
NEW
45
        return bindListComparable(v)
×
46
}
×
47

48
// BytesList supports binding a list of []byte values.
49
//
50
// Since: 2.2
51
type BytesList interface {
52
        DataList
53

54
        Append(value []byte) error
55
        Get() ([][]byte, error)
56
        GetValue(index int) ([]byte, error)
57
        Prepend(value []byte) error
58
        Remove(value []byte) error
59
        Set(list [][]byte) error
60
        SetValue(index int, value []byte) error
61
}
62

63
// ExternalBytesList supports binding a list of []byte values from an external variable.
64
//
65
// Since: 2.2
66
type ExternalBytesList interface {
67
        BytesList
68

69
        Reload() error
70
}
71

72
// NewBytesList returns a bindable list of []byte values.
73
//
74
// Since: 2.2
75
func NewBytesList() BytesList {
×
NEW
76
        return newList(bytes.Equal)
×
77
}
×
78

79
// BindBytesList returns a bound list of []byte values, based on the contents of the passed slice.
80
// If your code changes the content of the slice this refers to you should call Reload() to inform the bindings.
81
//
82
// Since: 2.2
83
func BindBytesList(v *[][]byte) ExternalBytesList {
×
NEW
84
        return bindList(v, bytes.Equal)
×
85
}
×
86

87
// FloatList supports binding a list of float64 values.
88
//
89
// Since: 2.0
90
type FloatList interface {
91
        DataList
92

93
        Append(value float64) error
94
        Get() ([]float64, error)
95
        GetValue(index int) (float64, error)
96
        Prepend(value float64) error
97
        Remove(value float64) error
98
        Set(list []float64) error
99
        SetValue(index int, value float64) error
100
}
101

102
// ExternalFloatList supports binding a list of float64 values from an external variable.
103
//
104
// Since: 2.0
105
type ExternalFloatList interface {
106
        FloatList
107

108
        Reload() error
109
}
110

111
// NewFloatList returns a bindable list of float64 values.
112
//
113
// Since: 2.0
114
func NewFloatList() FloatList {
5✔
115
        return newListComparable[float64]()
5✔
116
}
5✔
117

118
// BindFloatList returns a bound list of float64 values, based on the contents of the passed slice.
119
// If your code changes the content of the slice this refers to you should call Reload() to inform the bindings.
120
//
121
// Since: 2.0
122
func BindFloatList(v *[]float64) ExternalFloatList {
3✔
123
        return bindListComparable(v)
3✔
124
}
3✔
125

126
// IntList supports binding a list of int values.
127
//
128
// Since: 2.0
129
type IntList interface {
130
        DataList
131

132
        Append(value int) error
133
        Get() ([]int, error)
134
        GetValue(index int) (int, error)
135
        Prepend(value int) error
136
        Remove(value int) error
137
        Set(list []int) error
138
        SetValue(index int, value int) error
139
}
140

141
// ExternalIntList supports binding a list of int values from an external variable.
142
//
143
// Since: 2.0
144
type ExternalIntList interface {
145
        IntList
146

147
        Reload() error
148
}
149

150
// NewIntList returns a bindable list of int values.
151
//
152
// Since: 2.0
NEW
153
func NewIntList() IntList {
×
NEW
154
        return newListComparable[int]()
×
NEW
155
}
×
156

157
// BindIntList returns a bound list of int values, based on the contents of the passed slice.
158
// If your code changes the content of the slice this refers to you should call Reload() to inform the bindings.
159
//
160
// Since: 2.0
NEW
161
func BindIntList(v *[]int) ExternalIntList {
×
NEW
162
        return bindListComparable(v)
×
UNCOV
163
}
×
164

165
// RuneList supports binding a list of rune values.
166
//
167
// Since: 2.0
168
type RuneList interface {
169
        DataList
170

171
        Append(value rune) error
172
        Get() ([]rune, error)
173
        GetValue(index int) (rune, error)
174
        Prepend(value rune) error
175
        Remove(value rune) error
176
        Set(list []rune) error
177
        SetValue(index int, value rune) error
178
}
179

180
// ExternalRuneList supports binding a list of rune values from an external variable.
181
//
182
// Since: 2.0
183
type ExternalRuneList interface {
184
        RuneList
185

186
        Reload() error
187
}
188

189
// NewRuneList returns a bindable list of rune values.
190
//
191
// Since: 2.0
NEW
192
func NewRuneList() RuneList {
×
NEW
193
        return newListComparable[rune]()
×
NEW
194
}
×
195

196
// BindRuneList returns a bound list of rune values, based on the contents of the passed slice.
197
// If your code changes the content of the slice this refers to you should call Reload() to inform the bindings.
198
//
199
// Since: 2.0
NEW
200
func BindRuneList(v *[]rune) ExternalRuneList {
×
NEW
201
        if v == nil {
×
NEW
202
                return NewRuneList().(ExternalRuneList)
×
UNCOV
203
        }
×
204

NEW
205
        b := newListComparable[rune]()
×
NEW
206
        b.val = v
×
NEW
207
        b.updateExternal = true
×
UNCOV
208

×
NEW
209
        for i := range *v {
×
NEW
210
                b.appendItem(bindListItemComparable(v, i, b.updateExternal))
×
UNCOV
211
        }
×
212

NEW
213
        return b
×
214
}
215

216
// StringList supports binding a list of string values.
217
//
218
// Since: 2.0
219
type StringList interface {
220
        DataList
221

222
        Append(value string) error
223
        Get() ([]string, error)
224
        GetValue(index int) (string, error)
225
        Prepend(value string) error
226
        Remove(value string) error
227
        Set(list []string) error
228
        SetValue(index int, value string) error
229
}
230

231
// ExternalStringList supports binding a list of string values from an external variable.
232
//
233
// Since: 2.0
234
type ExternalStringList interface {
235
        StringList
236

237
        Reload() error
238
}
239

240
// NewStringList returns a bindable list of string values.
241
//
242
// Since: 2.0
NEW
243
func NewStringList() StringList {
×
NEW
244
        return newListComparable[string]()
×
UNCOV
245
}
×
246

247
// BindStringList returns a bound list of string values, based on the contents of the passed slice.
248
// If your code changes the content of the slice this refers to you should call Reload() to inform the bindings.
249
//
250
// Since: 2.0
NEW
251
func BindStringList(v *[]string) ExternalStringList {
×
NEW
252
        return bindListComparable(v)
×
UNCOV
253
}
×
254

255
// UntypedList supports binding a list of any values.
256
//
257
// Since: 2.1
258
type UntypedList interface {
259
        DataList
260

261
        Append(value any) error
262
        Get() ([]any, error)
263
        GetValue(index int) (any, error)
264
        Prepend(value any) error
265
        Remove(value any) error
266
        Set(list []any) error
267
        SetValue(index int, value any) error
268
}
269

270
// ExternalUntypedList supports binding a list of any values from an external variable.
271
//
272
// Since: 2.1
273
type ExternalUntypedList interface {
274
        UntypedList
275

276
        Reload() error
277
}
278

279
// NewUntypedList returns a bindable list of any values.
280
//
281
// Since: 2.1
282
func NewUntypedList() UntypedList {
×
NEW
283
        return newList(func(t1, t2 any) bool { return t1 == t2 })
×
284
}
285

286
// BindUntypedList returns a bound list of any values, based on the contents of the passed slice.
287
// If your code changes the content of the slice this refers to you should call Reload() to inform the bindings.
288
//
289
// Since: 2.1
290
func BindUntypedList(v *[]any) ExternalUntypedList {
×
291
        if v == nil {
×
292
                return NewUntypedList().(ExternalUntypedList)
×
293
        }
×
294

NEW
295
        comparator := func(t1, t2 any) bool { return t1 == t2 }
×
NEW
296
        b := newExternalList(v, comparator)
×
297
        for i := range *v {
×
NEW
298
                b.appendItem(bindListItem(v, i, b.updateExternal, comparator))
×
299
        }
×
300

301
        return b
×
302
}
303

304
// URIList supports binding a list of fyne.URI values.
305
//
306
// Since: 2.1
307
type URIList interface {
308
        DataList
309

310
        Append(value fyne.URI) error
311
        Get() ([]fyne.URI, error)
312
        GetValue(index int) (fyne.URI, error)
313
        Prepend(value fyne.URI) error
314
        Remove(value fyne.URI) error
315
        Set(list []fyne.URI) error
316
        SetValue(index int, value fyne.URI) error
317
}
318

319
// ExternalURIList supports binding a list of fyne.URI values from an external variable.
320
//
321
// Since: 2.1
322
type ExternalURIList interface {
323
        URIList
324

325
        Reload() error
326
}
327

328
// NewURIList returns a bindable list of fyne.URI values.
329
//
330
// Since: 2.1
331
func NewURIList() URIList {
×
NEW
332
        return newList(compareURI)
×
333
}
×
334

335
// BindURIList returns a bound list of fyne.URI values, based on the contents of the passed slice.
336
// If your code changes the content of the slice this refers to you should call Reload() to inform the bindings.
337
//
338
// Since: 2.1
339
func BindURIList(v *[]fyne.URI) ExternalURIList {
×
NEW
340
        return bindList(v, compareURI)
×
341
}
×
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

© 2026 Coveralls, Inc