-
Notifications
You must be signed in to change notification settings - Fork 4
/
fyles.go
49 lines (38 loc) · 889 Bytes
/
fyles.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
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/widget"
xWidget "fyne.io/x/fyne/widget"
"github.com/fyshos/fyles/pkg/fyles"
)
type fylesUI struct {
win fyne.Window
pwd fyne.URI
fileScroll *container.Scroll
fileTree *xWidget.FileTree
items *fyles.Panel
filePath *widget.Label
filter storage.FileFilter
}
type filter struct{}
func (f *filter) Matches(u fyne.URI) bool {
return u.Name()[0] != '.'
}
func filterHidden() storage.FileFilter {
return &filter{}
}
type dirFilter struct {
storage.FileFilter
}
func (f *dirFilter) Matches(u fyne.URI) bool {
if f.FileFilter != nil && !f.FileFilter.Matches(u) {
return false
}
listable, _ := storage.CanList(u)
return listable
}
func filterDir(files storage.FileFilter) storage.FileFilter {
return &dirFilter{FileFilter: files}
}