Skip to content

Commit a5a8309

Browse files
Cleanup sample ios
1 parent ef39815 commit a5a8309

16 files changed

+55
-501
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ out/
2222
# Gradle files
2323
.gradle
2424
.gradle/
25-
#build/
25+
/build/
2626

2727
# Signing files
2828
.signing/

sample-ios/SampleiOS.xcodeproj/SampleiOS.xctestplan

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

sample-ios/SampleiOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 194 deletions
Large diffs are not rendered by default.

sample-ios/SampleiOS.xcodeproj/xcshareddata/xcschemes/SampleiOS.xcscheme

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<TestPlans>
31-
<TestPlanReference
32-
reference = "container:SampleiOS.xcodeproj/SampleiOS.xctestplan"
33-
default = "YES">
34-
</TestPlanReference>
3531
</TestPlans>
3632
<Testables>
3733
<TestableReference

sample-ios/SampleiOS/AppDelegate.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,12 @@ import UIKit
1212
class AppDelegate: UIResponder, UIApplicationDelegate {
1313

1414
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
15-
// Override point for customization after application launch.
16-
1715
return true
1816
}
1917

2018
// MARK: UISceneSession Lifecycle
2119

2220
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
23-
// Called when a new scene session is being created.
24-
// Use this method to select a configuration to create the new scene with.
2521
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
2622
}
27-
28-
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
29-
// Called when the user discards a scene session.
30-
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
31-
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
32-
}
33-
34-
3523
}
36-

sample-ios/SampleiOS/ContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ enum Environment: String, Hashable {
1717
case original = "http://api.github.com"
1818
}
1919

20-
struct ContentView: View {
20+
struct EnvironmentPickerView: View {
2121
@State private var environment: Environment = .mocked
2222
var didTap: ((Environment) -> Void)?
2323

@@ -40,6 +40,6 @@ struct ContentView: View {
4040

4141
struct ContentView_Previews: PreviewProvider {
4242
static var previews: some View {
43-
ContentView()
43+
EnvironmentPickerView()
4444
}
4545
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// ContentView.swift
3+
// SampleiOS
4+
//
5+
// Created by mlaskowski on 08/02/2020.
6+
// Copyright © 2020 Michal Laskowski. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
// navigation works once on simulators till xcode11.4, and it is back on 11.5
12+
// https://stackoverflow.com/questions/59279176/navigationlink-works-only-for-once
13+
14+
enum Environment: String, Hashable {
15+
case mocked = "http://localhost:8080"
16+
case sharedMock = "http://localhost:8081"
17+
case original = "http://api.github.com"
18+
}
19+
20+
struct EnvironmentPickerView: View {
21+
@State private var environment: Environment = .mocked
22+
var didTap: ((Environment) -> Void)?
23+
24+
var body: some View {
25+
VStack {
26+
Picker(selection: $environment, label: Text("Choose environment")) {
27+
Text("mocked").tag(Environment.mocked)
28+
Text("shared mock").tag(Environment.sharedMock)
29+
Text("original").tag(Environment.original)
30+
}.pickerStyle(SegmentedPickerStyle())
31+
32+
Button(action: {
33+
self.didTap?(self.environment)
34+
}, label: {
35+
Text("Go make that call")
36+
}).accessibility(identifier: "show_list")
37+
}
38+
}
39+
}
40+
41+
struct ContentView_Previews: PreviewProvider {
42+
static var previews: some View {
43+
EnvironmentPickerView()
44+
}
45+
}

sample-ios/SampleiOS/ListView.swift

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

sample-ios/SampleiOS/ListViewControler.swift

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

sample-ios/SampleiOS/SceneDelegate.swift

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1919
private var commonMockServer: MockServer?
2020

2121
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
22-
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
23-
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
24-
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
25-
26-
// Create the SwiftUI view that provides the window contents.
27-
let contentView = ContentView(didTap: { [weak self] environment in
28-
// self?.presentList()
22+
let contentView = EnvironmentPickerView(didTap: { [weak self] environment in
2923
self?.presentContributors(in: environment)
3024
})
3125
let contentViewController = UIHostingController(rootView: contentView)
@@ -39,22 +33,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
3933
}
4034
}
4135

42-
private func presentSwiftUIList() {
43-
let listView = ListView(didTapBack: {
44-
self.window?.rootViewController?.dismiss(animated: true)
45-
})
46-
let listViewController = UIHostingController(rootView: listView)
47-
self.window?.rootViewController?.present(listViewController, animated: true, completion: nil)
48-
}
49-
50-
private func presentList() {
51-
let listViewController = ListViewController()
52-
listViewController.didTapBack = {
53-
listViewController.dismiss(animated: true, completion: nil)
54-
}
55-
self.window?.rootViewController?.present(listViewController, animated: true, completion: nil)
56-
}
57-
5836
private func presentContributors(in environment: Environment) {
5937
switch environment {
6038
case .mocked:
@@ -96,9 +74,7 @@ private final class MockingRouter: Router {
9674
let responseBody = try! JSONSerialization.data(withJSONObject: [
9775
["login": "test", "contributions": 1]
9876
], options: [])
99-
10077
return Response(status: 200, headers: [:], body: responseBody, contentType: "application/json")
101-
10278
} else {
10379
return Response(status: 404, headers: [:], body: nil, contentType: nil)
10480
}

0 commit comments

Comments
 (0)