Skip to content

Commit 138e293

Browse files
authored
Merge pull request #19 from DDD-3/visitor
Visitor 프로토타이핑 (#18)
2 parents bfe6046 + aa96e5d commit 138e293

28 files changed

+1299
-293
lines changed

Podfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ target 'gigi' do
55

66
pod 'Then'
77
pod 'SnapKit'
8-
8+
pod 'RxSwift'
9+
pod 'RxCocoa'
10+
pod 'RxOptional'
11+
pod 'RxViewController'
912
end

Podfile.lock

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
11
PODS:
2+
- RxCocoa (5.0.1):
3+
- RxRelay (~> 5)
4+
- RxSwift (~> 5)
5+
- RxOptional (4.1.0):
6+
- RxCocoa (~> 5)
7+
- RxSwift (~> 5)
8+
- RxRelay (5.0.1):
9+
- RxSwift (~> 5)
10+
- RxSwift (5.0.0)
11+
- RxViewController (1.0.0):
12+
- RxCocoa (~> 5.0)
13+
- RxSwift (~> 5.0)
214
- SnapKit (5.0.1)
315
- Then (2.6.0)
416

517
DEPENDENCIES:
18+
- RxCocoa
19+
- RxOptional
20+
- RxSwift
21+
- RxViewController
622
- SnapKit
723
- Then
824

925
SPEC REPOS:
1026
trunk:
27+
- RxCocoa
28+
- RxOptional
29+
- RxRelay
30+
- RxSwift
31+
- RxViewController
1132
- SnapKit
1233
- Then
1334

1435
SPEC CHECKSUMS:
36+
RxCocoa: e741b9749968e8a143e2b787f1dfbff2b63d0a5c
37+
RxOptional: b1fcd60856807a564c0215c2184b8d33e7826dc2
38+
RxRelay: 89d54507f4fd4d969e6ec1d4bd7f3673640b4640
39+
RxSwift: 8b0671caa829a763bbce7271095859121cbd895f
40+
RxViewController: 7330a46e5c31cd680db169da4c9fc8676e975a81
1541
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
1642
Then: 90cd104fd951cec1980a03f57704ad8f784d4d79
1743

18-
PODFILE CHECKSUM: 56cb4175a7f7666772e2260ee0bba9ac886e4df0
44+
PODFILE CHECKSUM: 7cb51eaee1a44078c519092e0491f4aa5631f203
1945

2046
COCOAPODS: 1.8.3

SwiftUI를_선택하지_못한_이유.md

+4
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@
5353
- 다른 사람들도 많이 겪은 문제
5454

5555
- 이 문제가 발생하고 나서 SwiftUI를 사용할 수 없겠다고 결론을 내림
56+
57+
---
58+
59+
Combine도 안쓸거다

gigi.xcodeproj/project.pbxproj

+248-164
Large diffs are not rendered by default.

gigi/Base.lproj/LaunchScreen.storyboard

-25
This file was deleted.

gigi/Base.lproj/Main.storyboard

-24
This file was deleted.

gigi/Resources/Assets.swift

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// swiftlint:disable all
2+
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3+
4+
#if os(OSX)
5+
import AppKit.NSImage
6+
internal typealias AssetColorTypeAlias = NSColor
7+
internal typealias AssetImageTypeAlias = NSImage
8+
#elseif os(iOS) || os(tvOS) || os(watchOS)
9+
import UIKit.UIImage
10+
internal typealias AssetColorTypeAlias = UIColor
11+
internal typealias AssetImageTypeAlias = UIImage
12+
#endif
13+
14+
// swiftlint:disable superfluous_disable_command
15+
// swiftlint:disable file_length
16+
17+
// MARK: - Asset Catalogs
18+
19+
// swiftlint:disable identifier_name line_length nesting type_body_length type_name
20+
internal enum Asset {}
21+
22+
// swiftlint:enable identifier_name line_length nesting type_body_length type_name
23+
24+
// MARK: - Implementation Details
25+
26+
internal struct ColorAsset {
27+
internal fileprivate(set) var name: String
28+
29+
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
30+
internal var color: AssetColorTypeAlias {
31+
return AssetColorTypeAlias(asset: self)
32+
}
33+
}
34+
35+
internal extension AssetColorTypeAlias {
36+
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *)
37+
convenience init!(asset: ColorAsset) {
38+
let bundle = Bundle(for: BundleToken.self)
39+
#if os(iOS) || os(tvOS)
40+
self.init(named: asset.name, in: bundle, compatibleWith: nil)
41+
#elseif os(OSX)
42+
self.init(named: NSColor.Name(asset.name), bundle: bundle)
43+
#elseif os(watchOS)
44+
self.init(named: asset.name)
45+
#endif
46+
}
47+
}
48+
49+
internal struct DataAsset {
50+
internal fileprivate(set) var name: String
51+
52+
#if os(iOS) || os(tvOS) || os(OSX)
53+
@available(iOS 9.0, tvOS 9.0, OSX 10.11, *)
54+
internal var data: NSDataAsset {
55+
return NSDataAsset(asset: self)
56+
}
57+
#endif
58+
}
59+
60+
#if os(iOS) || os(tvOS) || os(OSX)
61+
@available(iOS 9.0, tvOS 9.0, OSX 10.11, *)
62+
internal extension NSDataAsset {
63+
convenience init!(asset: DataAsset) {
64+
let bundle = Bundle(for: BundleToken.self)
65+
#if os(iOS) || os(tvOS)
66+
self.init(name: asset.name, bundle: bundle)
67+
#elseif os(OSX)
68+
self.init(name: NSDataAsset.Name(asset.name), bundle: bundle)
69+
#endif
70+
}
71+
}
72+
#endif
73+
74+
internal struct ImageAsset {
75+
internal fileprivate(set) var name: String
76+
77+
internal var image: AssetImageTypeAlias {
78+
let bundle = Bundle(for: BundleToken.self)
79+
#if os(iOS) || os(tvOS)
80+
let image = AssetImageTypeAlias(named: name, in: bundle, compatibleWith: nil)
81+
#elseif os(OSX)
82+
let image = bundle.image(forResource: NSImage.Name(name))
83+
#elseif os(watchOS)
84+
let image = AssetImageTypeAlias(named: name)
85+
#endif
86+
guard let result = image else { fatalError("Unable to load image named \(name).") }
87+
return result
88+
}
89+
}
90+
91+
internal extension AssetImageTypeAlias {
92+
@available(iOS 1.0, tvOS 1.0, watchOS 1.0, *)
93+
@available(OSX, deprecated,
94+
message: "This initializer is unsafe on macOS, please use the ImageAsset.image property")
95+
convenience init!(asset: ImageAsset) {
96+
#if os(iOS) || os(tvOS)
97+
let bundle = Bundle(for: BundleToken.self)
98+
self.init(named: asset.name, in: bundle, compatibleWith: nil)
99+
#elseif os(OSX)
100+
self.init(named: NSImage.Name(asset.name))
101+
#elseif os(watchOS)
102+
self.init(named: asset.name)
103+
#endif
104+
}
105+
}
106+
107+
private final class BundleToken {}

gigi/Resources/Storyboard.swift

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// swiftlint:disable all
2+
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
3+
4+
// swiftlint:disable sorted_imports
5+
import Foundation
6+
import UIKit
7+
8+
// swiftlint:disable superfluous_disable_command
9+
// swiftlint:disable file_length
10+
11+
// MARK: - Storyboard Scenes
12+
13+
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
14+
internal enum StoryboardScene {
15+
internal enum Host: StoryboardType {
16+
internal static let storyboardName = "Host"
17+
}
18+
19+
internal enum LaunchScreen: StoryboardType {
20+
internal static let storyboardName = "LaunchScreen"
21+
22+
internal static let initialScene = InitialSceneType<UIKit.UIViewController>(storyboard: LaunchScreen.self)
23+
}
24+
25+
internal enum Map: StoryboardType {
26+
internal static let storyboardName = "Map"
27+
}
28+
29+
internal enum Visitor: StoryboardType {
30+
internal static let storyboardName = "Visitor"
31+
32+
internal static let initialScene = InitialSceneType<UIKit.UINavigationController>(storyboard: Visitor.self)
33+
34+
internal static let visitorFinishViewController = SceneType<VisitorFinishViewController>(storyboard: Visitor.self, identifier: "VisitorFinishViewController")
35+
36+
internal static let visitorMainViewController = SceneType<VisitorMainViewController>(storyboard: Visitor.self, identifier: "VisitorMainViewController")
37+
38+
internal static let visitorNameViewController = SceneType<VisitorNameViewController>(storyboard: Visitor.self, identifier: "VisitorNameViewController")
39+
40+
internal static let visitorStationViewController = SceneType<VisitorStationViewController>(storyboard: Visitor.self, identifier: "VisitorStationViewController")
41+
}
42+
}
43+
44+
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
45+
46+
// MARK: - Implementation Details
47+
48+
internal protocol StoryboardType {
49+
static var storyboardName: String { get }
50+
}
51+
52+
internal extension StoryboardType {
53+
static var storyboard: UIStoryboard {
54+
let name = storyboardName
55+
return UIStoryboard(name: name, bundle: Bundle(for: BundleToken.self))
56+
}
57+
}
58+
59+
internal struct SceneType<T: UIViewController> {
60+
internal let storyboard: StoryboardType.Type
61+
internal let identifier: String
62+
63+
internal func instantiate() -> T {
64+
let identifier = self.identifier
65+
guard let controller = storyboard.storyboard.instantiateViewController(withIdentifier: identifier) as? T else {
66+
fatalError("ViewController '\(identifier)' is not of the expected class \(T.self).")
67+
}
68+
return controller
69+
}
70+
}
71+
72+
internal struct InitialSceneType<T: UIViewController> {
73+
internal let storyboard: StoryboardType.Type
74+
75+
internal func instantiate() -> T {
76+
guard let controller = storyboard.storyboard.instantiateInitialViewController() as? T else {
77+
fatalError("ViewController is not of the expected class \(T.self).")
78+
}
79+
return controller
80+
}
81+
}
82+
83+
private final class BundleToken {}

gigi/Sources/AppDelegate.swift

+21-14
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@
66
// Copyright © 2019 Ieungieung. All rights reserved.
77
//
88

9-
import Combine
109
import UIKit
1110

11+
import RxSwift
12+
import Then
13+
1214
@UIApplicationMain
1315
final class AppDelegate: UIResponder, UIApplicationDelegate {
1416
var window: UIWindow?
1517

16-
private var cancellables = Set<AnyCancellable>()
18+
private var disposeBag = DisposeBag()
1719

1820
func application(_ application: UIApplication,
1921
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
22+
UINavigationBar.appearance().do {
23+
$0.setBackgroundImage(.init(), for: .default)
24+
$0.shadowImage = .init()
25+
$0.isTranslucent = true
26+
}
2027
return true
2128
}
2229
}
@@ -27,34 +34,34 @@ private extension AppDelegate {
2734

2835
service.requestAuthorization()
2936

30-
service.authorizationStatusPublisher
37+
service.authorizationStatusObservable
3138
.filter { $0 == .authorizedWhenInUse || $0 == .authorizedAlways }
32-
.sink(receiveValue: { _ in
39+
.subscribe(onNext: { _ in
3340
Log.debug("위치 정보 권한 허용됨")
3441
service.startUpdatingLocation()
3542
})
36-
.store(in: &cancellables)
43+
.disposed(by: disposeBag)
3744

38-
service.authorizationStatusPublisher
45+
service.authorizationStatusObservable
3946
.filter { !($0 == .authorizedWhenInUse || $0 == .authorizedAlways) }
40-
.sink(receiveValue: { _ in
47+
.subscribe(onNext: { _ in
4148
Log.error("위치 정보 권한 허용되지 않음")
4249
})
43-
.store(in: &cancellables)
50+
.disposed(by: disposeBag)
4451

45-
service.coordinateResultPublisher
52+
service.coordinateResultObservable
4653
.compactMap { $0.success }
47-
.sink(receiveValue: { coordinate in
54+
.subscribe(onNext: { coordinate in
4855
Log.debug("현재 위치 갱신됨 : \(coordinate)")
4956
service.stopUpdatingLocation()
5057
})
51-
.store(in: &cancellables)
58+
.disposed(by: disposeBag)
5259

53-
service.coordinateResultPublisher
60+
service.coordinateResultObservable
5461
.compactMap { $0.failure }
55-
.sink(receiveValue: { error in
62+
.subscribe(onNext: { error in
5663
Log.error("위치 갱신 에러 : \(error.localizedDescription)")
5764
})
58-
.store(in: &cancellables)
65+
.disposed(by: disposeBag)
5966
}
6067
}

0 commit comments

Comments
 (0)