Skip to content

Commit

Permalink
Add example project
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schmiedmayer committed Jun 23, 2021
1 parent e8c6d23 commit 1ec2085
Show file tree
Hide file tree
Showing 73 changed files with 2,872 additions and 210 deletions.
90 changes: 0 additions & 90 deletions .github/workflows/build-and-test.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/docs.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/spm-update.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .jazzy.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Client/PresenterExample/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
31 changes: 31 additions & 0 deletions Client/PresenterExample/ConnectView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import SwiftUI


struct ConnectView: View {
// MARK: Stored Properties

var action: (URL) -> Void

@State private var url = ""

// MARK: Computed Properties

var body: some View {
NavigationView {
VStack(spacing: 32) {
TextField("URL", text: $url)
Button("Connect", action: load)
}
.padding(32)
.navigationTitle("Select Server")
}
}

// MARK: Actions

private func load() {
if let url = URL(string: self.url) {
action(url)
}
}
}
44 changes: 44 additions & 0 deletions Client/PresenterExample/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Presenter
import SwiftUI


struct ContentView: SwiftUI.View {
// MARK: Stored Properties

@ObservedObject var model: Model

@SwiftUI.State private var url: URL?
@SwiftUI.State private var error: String?
@SwiftUI.State private var view: AnyView?

// MARK: Computed Properties

var body: some SwiftUI.View {
if let view = view {
view.environmentObject(model)
} else if let error = error {
ErrorView(error: error) {
self.view = nil
self.error = nil
self.url = nil
}
} else if let url = url {
LoadingView(
url: url,
view: $view,
error: $error
)
} else {
ConnectView { url in
self.url = url
}
}
}
}


struct ContentView_Previews: PreviewProvider {
static var previews: some SwiftUI.View {
ContentView(model: .init())
}
}
22 changes: 22 additions & 0 deletions Client/PresenterExample/ErrorView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import SwiftUI


struct ErrorView: View {
// MARK: Stored Properties

var error: String
var action: () -> Void

// MARK: Computed Properties

var body: some View {
NavigationView {
VStack(spacing: 32) {
Text(error)
Button("Try again", action: action)
}
.padding(32)
.navigationTitle("Error")
}
}
}
Loading

0 comments on commit 1ec2085

Please sign in to comment.