Skip to content

Commit 1ec2085

Browse files
author
Paul Schmiedmayer
committed
Add example project
1 parent e8c6d23 commit 1ec2085

73 files changed

Lines changed: 2872 additions & 210 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-and-test.yml

Lines changed: 0 additions & 90 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/spm-update.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.jazzy.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"scale" : "3x",
41+
"size" : "60x60"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"scale" : "1x",
46+
"size" : "20x20"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"scale" : "2x",
51+
"size" : "20x20"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"scale" : "1x",
56+
"size" : "29x29"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"scale" : "2x",
61+
"size" : "29x29"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"scale" : "1x",
66+
"size" : "40x40"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"scale" : "2x",
71+
"size" : "40x40"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "1x",
76+
"size" : "76x76"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"scale" : "2x",
81+
"size" : "76x76"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"scale" : "2x",
86+
"size" : "83.5x83.5"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"scale" : "1x",
91+
"size" : "1024x1024"
92+
}
93+
],
94+
"info" : {
95+
"author" : "xcode",
96+
"version" : 1
97+
}
98+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import SwiftUI
2+
3+
4+
struct ConnectView: View {
5+
// MARK: Stored Properties
6+
7+
var action: (URL) -> Void
8+
9+
@State private var url = ""
10+
11+
// MARK: Computed Properties
12+
13+
var body: some View {
14+
NavigationView {
15+
VStack(spacing: 32) {
16+
TextField("URL", text: $url)
17+
Button("Connect", action: load)
18+
}
19+
.padding(32)
20+
.navigationTitle("Select Server")
21+
}
22+
}
23+
24+
// MARK: Actions
25+
26+
private func load() {
27+
if let url = URL(string: self.url) {
28+
action(url)
29+
}
30+
}
31+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Presenter
2+
import SwiftUI
3+
4+
5+
struct ContentView: SwiftUI.View {
6+
// MARK: Stored Properties
7+
8+
@ObservedObject var model: Model
9+
10+
@SwiftUI.State private var url: URL?
11+
@SwiftUI.State private var error: String?
12+
@SwiftUI.State private var view: AnyView?
13+
14+
// MARK: Computed Properties
15+
16+
var body: some SwiftUI.View {
17+
if let view = view {
18+
view.environmentObject(model)
19+
} else if let error = error {
20+
ErrorView(error: error) {
21+
self.view = nil
22+
self.error = nil
23+
self.url = nil
24+
}
25+
} else if let url = url {
26+
LoadingView(
27+
url: url,
28+
view: $view,
29+
error: $error
30+
)
31+
} else {
32+
ConnectView { url in
33+
self.url = url
34+
}
35+
}
36+
}
37+
}
38+
39+
40+
struct ContentView_Previews: PreviewProvider {
41+
static var previews: some SwiftUI.View {
42+
ContentView(model: .init())
43+
}
44+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import SwiftUI
2+
3+
4+
struct ErrorView: View {
5+
// MARK: Stored Properties
6+
7+
var error: String
8+
var action: () -> Void
9+
10+
// MARK: Computed Properties
11+
12+
var body: some View {
13+
NavigationView {
14+
VStack(spacing: 32) {
15+
Text(error)
16+
Button("Try again", action: action)
17+
}
18+
.padding(32)
19+
.navigationTitle("Error")
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)