File tree Expand file tree Collapse file tree 6 files changed +54
-6
lines changed
Expand file tree Collapse file tree 6 files changed +54
-6
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ struct AppLayer: Layer {
2020 " CFBundleVersion " : " $(CURRENT_PROJECT_VERSION) " ,
2121 " ITSAppUsesNonExemptEncryption " : false ,
2222 " UILaunchStoryboardName " : " LaunchScreen " ,
23+ " UIUserInterfaceStyle " : " Light " ,
2324 " UISupportedInterfaceOrientations " : [
2425 " UIInterfaceOrientationPortrait "
2526 ] ,
@@ -43,7 +44,7 @@ struct AppLayer: Layer {
4344 base: [
4445 " PRODUCT_BUNDLE_IDENTIFIER " : " $(APP_IDENTIFIER) " ,
4546 " TARGETED_DEVICE_FAMILY " : " 1 " ,
46- " MARKETING_VERSION " : " 1.0.0 " ,
47+ " MARKETING_VERSION " : " 1.0.1 " ,
4748 " CURRENT_PROJECT_VERSION " : " 0 " ,
4849 ] ,
4950 configurations: [
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ public final class RootViewController: UIViewController {
101101
102102 @objc private func moveButtonTapped( ) {
103103 TestAppRouter . shared. navigate (
104- to: selectedRoute ?? . lib, how: selectedPresentationStyle ?? . push, with: [ : ] )
104+ to: selectedRoute ?? . lib, how: selectedPresentationStyle ?? . push( ) , with: [ : ] )
105105 }
106106
107107 // MARK: - Alert Functions
@@ -131,7 +131,7 @@ public final class RootViewController: UIViewController {
131131 // 네비게이션 방식에 대한 액션 추가
132132 alert. addAction (
133133 UIAlertAction ( title: " Push " , style: . default) { [ weak self] _ in
134- self ? . selectedPresentationStyle = . push
134+ self ? . selectedPresentationStyle = . push( )
135135 self ? . howButton. setTitle ( " Push 방식으로 " , for: . normal)
136136 } )
137137 alert. addAction (
Original file line number Diff line number Diff line change @@ -54,6 +54,12 @@ public final class LibRouter: Routable {
5454 } else {
5555 topViewController. dismiss ( animated: true , completion: nil )
5656 }
57+ case . pop:
58+ if let navigationController = topViewController. navigationController {
59+ navigationController. popViewController ( animated: true )
60+ } else {
61+ topViewController. dismiss ( animated: true , completion: nil )
62+ }
5763 }
5864 }
5965}
Original file line number Diff line number Diff line change @@ -54,6 +54,12 @@ public final class SubRouter: Routable {
5454 } else {
5555 topViewController. dismiss ( animated: true , completion: nil )
5656 }
57+ case . pop:
58+ if let navigationController = topViewController. navigationController {
59+ navigationController. popViewController ( animated: true )
60+ } else {
61+ topViewController. dismiss ( animated: true , completion: nil )
62+ }
5763 }
5864 }
5965}
Original file line number Diff line number Diff line change @@ -55,6 +55,34 @@ public final class HistoryWebViewController: BaseViewController {
5555 self ? . webView. load ( request)
5656 }
5757 . store ( in: & cancellables)
58+
59+ viewModel. output. needsRecovery
60+ . removeDuplicates ( )
61+ . receive ( on: DispatchQueue . main)
62+ . sink { [ weak self] needsRecovery in
63+ guard let self = self else { return }
64+ guard needsRecovery else { return }
65+ if UIApplication . shared. applicationState == . active {
66+ self . recoverIfNeeded ( )
67+ }
68+ }
69+ . store ( in: & cancellables)
70+
71+ NotificationCenter . default. publisher (
72+ for: UIApplication . willEnterForegroundNotification
73+ )
74+ . receive ( on: DispatchQueue . main)
75+ . sink { [ weak self] _ in
76+ self ? . recoverIfNeeded ( )
77+ }
78+ . store ( in: & cancellables)
79+ }
80+
81+ private func recoverIfNeeded( ) {
82+ guard viewModel. output. needsRecovery. value else { return }
83+ showLoading ( )
84+ webView. reload ( )
85+ viewModel. send ( input: . recovered)
5886 }
5987}
6088
@@ -84,8 +112,6 @@ extension HistoryWebViewController: WKNavigationDelegate {
84112 }
85113
86114 public func webViewWebContentProcessDidTerminate( _ webView: WKWebView ) {
87- // TODO: 뷰모델로 분리
88- hideLoading ( )
89- // TODO: 에러 처리
115+ viewModel. send ( input: . webContentProcessDidTerminate)
90116 }
91117}
Original file line number Diff line number Diff line change @@ -12,10 +12,13 @@ public final class HistoryWebViewModel {
1212
1313 enum Input {
1414 case viewDidLoad
15+ case webContentProcessDidTerminate
16+ case recovered
1517 }
1618
1719 struct Output {
1820 let loadURL = PassthroughSubject < URLRequest , Never > ( )
21+ let needsRecovery = CurrentValueSubject < Bool , Never > ( false )
1922 }
2023
2124 let output = Output ( )
@@ -28,6 +31,12 @@ public final class HistoryWebViewModel {
2831 let url = URL ( string: " https://clever-kataifi-dcedaf.netlify.app/lotto-history " ) !
2932 let request = URLRequest ( url: url)
3033 output. loadURL. send ( request)
34+
35+ case . webContentProcessDidTerminate:
36+ output. needsRecovery. send ( true )
37+
38+ case . recovered:
39+ output. needsRecovery. send ( false )
3140 }
3241 }
3342}
You can’t perform that action at this time.
0 commit comments