summary refs log tree commit diff stats
path: root/widgets/directories.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-13 20:02:21 -0500
committerDrew DeVault <sir@cmpwn.com>2019-01-13 20:02:21 -0500
commita782b709d1312bfe80dda7c864de96ba1c854bc2 (patch)
tree206846b95e787e302694cbc3f812e173eeb76b5e /widgets/directories.go
parentf87fe502a6d252bac9da5f08fd2aa682a9fc2277 (diff)
downloadaerc-a782b709d1312bfe80dda7c864de96ba1c854bc2.tar.gz
Add loading spinner
Diffstat (limited to 'widgets/directories.go')
-rw-r--r--widgets/directories.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/widgets/directories.go b/widgets/directories.go
index 13018bb..11fe2d6 100644
--- a/widgets/directories.go
+++ b/widgets/directories.go
@@ -17,13 +17,24 @@ type DirectoryList struct {
 	logger       *log.Logger
 	onInvalidate func(d ui.Drawable)
 	selected     string
+	spinner      *Spinner
 	worker       *types.Worker
 }
 
 func NewDirectoryList(conf *config.AccountConfig,
 	logger *log.Logger, worker *types.Worker) *DirectoryList {
 
-	return &DirectoryList{conf: conf, logger: logger, worker: worker}
+	dirlist := &DirectoryList{
+		conf:    conf,
+		logger:  logger,
+		spinner: NewSpinner(),
+		worker:  worker,
+	}
+	dirlist.spinner.OnInvalidate(func(_ ui.Drawable) {
+		dirlist.Invalidate()
+	})
+	dirlist.spinner.Start()
+	return dirlist
 }
 
 func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
@@ -37,6 +48,7 @@ func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
 			case *types.Done:
 				sort.Strings(dirs)
 				dirlist.dirs = dirs
+				dirlist.spinner.Stop()
 				dirlist.Invalidate()
 				if done != nil {
 					done(dirs)
@@ -63,6 +75,12 @@ func (dirlist *DirectoryList) Invalidate() {
 
 func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
 	ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
+
+	if dirlist.spinner.IsRunning() {
+		dirlist.spinner.Draw(ctx)
+		return
+	}
+
 	row := 0
 	for _, name := range dirlist.dirs {
 		if row >= ctx.Height() {
d=2887ca25fb58362d5d644ecda5f0bc51c80ec404'>2887ca25 ^
9097b81b ^
2887ca25 ^

bd627dc4 ^







2887ca25 ^

0926af9f ^
2f41a544 ^
2887ca25 ^



ae16120a ^

ae16120a ^

0926af9f ^

9097b81b ^
2887ca25 ^
9097b81b ^

2887ca25 ^

0926af9f ^
9097b81b ^

2887ca25 ^

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80