forked from fyne-io/fyne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud.go
47 lines (39 loc) · 1 KB
/
cloud.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
package app
import "github.com/nemesis567/fyne"
func (a *fyneApp) SetCloudProvider(p fyne.CloudProvider) {
if p == nil {
a.cloud = nil
return
}
a.transitionCloud(p)
}
func (a *fyneApp) transitionCloud(p fyne.CloudProvider) {
if a.cloud != nil {
a.cloud.Cleanup(a)
}
err := p.Setup(a)
if err != nil {
fyne.LogError("Failed to set up cloud provider "+p.ProviderName(), err)
return
}
a.cloud = p
listeners := a.prefs.ChangeListeners()
if pp, ok := p.(fyne.CloudProviderPreferences); ok {
a.prefs = pp.CloudPreferences(a)
} else {
a.prefs = a.newDefaultPreferences()
}
if cloud, ok := p.(fyne.CloudProviderStorage); ok {
a.storage = cloud.CloudStorage(a)
} else {
store := &store{a: a}
store.Docs = makeStoreDocs(a.uniqueID, a.prefs, store)
a.storage = store
}
for _, l := range listeners {
a.prefs.AddChangeListener(l)
l() // assume that preferences have changed because we replaced the provider
}
// after transition ensure settings listener is fired
a.settings.apply()
}