forked from pointfreeco/swift-sharing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentView.swift
More file actions
50 lines (44 loc) · 1.12 KB
/
ContentView.swift
File metadata and controls
50 lines (44 loc) · 1.12 KB
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
import Dependencies
import Sharing
import SwiftUI
struct ContentView: View {
@SharedReader(.remoteConfig("showPromo")) var showPromo = false
var body: some View {
ZStack(alignment: .bottom) {
Form {
Image(systemName: "globe")
.foregroundStyle(.tint)
Text("Hello, world!")
}
if $showPromo.isLoading {
ProgressView()
.padding()
} else if let loadError = $showPromo.loadError {
Text(loadError.localizedDescription)
.foregroundColor(.white)
.padding()
.background(Color.red)
.cornerRadius(8)
} else if showPromo {
Text("Our promo has started!")
.font(.title3)
.foregroundColor(.white)
.padding()
.background(Color.blue)
.cornerRadius(8)
}
}
}
}
#Preview("Promo: true") {
let _ = prepareDependencies {
$0.remoteConfig = MockRemoteConfig(config: ["showPromo": true])
}
ContentView()
}
#Preview("Promo: false") {
let _ = prepareDependencies {
$0.remoteConfig = MockRemoteConfig(config: ["showPromo": false])
}
ContentView()
}