Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct AppLayer: Layer {
"CFBundleVersion": "$(CURRENT_PROJECT_VERSION)",
"ITSAppUsesNonExemptEncryption": false,
"UILaunchStoryboardName": "LaunchScreen",
"UIUserInterfaceStyle": "Light",
"UISupportedInterfaceOrientations": [
"UIInterfaceOrientationPortrait"
],
Expand All @@ -43,7 +44,7 @@ struct AppLayer: Layer {
base: [
"PRODUCT_BUNDLE_IDENTIFIER": "$(APP_IDENTIFIER)",
"TARGETED_DEVICE_FAMILY": "1",
"MARKETING_VERSION": "1.0.0",
"MARKETING_VERSION": "1.0.1",
"CURRENT_PROJECT_VERSION": "0",
],
configurations: [
Expand Down
4 changes: 2 additions & 2 deletions Common/LibTest/Sources/RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public final class RootViewController: UIViewController {

@objc private func moveButtonTapped() {
TestAppRouter.shared.navigate(
to: selectedRoute ?? .lib, how: selectedPresentationStyle ?? .push, with: [:])
to: selectedRoute ?? .lib, how: selectedPresentationStyle ?? .push(), with: [:])
}

// MARK: - Alert Functions
Expand Down Expand Up @@ -131,7 +131,7 @@ public final class RootViewController: UIViewController {
// 네비게이션 방식에 대한 액션 추가
alert.addAction(
UIAlertAction(title: "Push", style: .default) { [weak self] _ in
self?.selectedPresentationStyle = .push
self?.selectedPresentationStyle = .push()
self?.howButton.setTitle("Push 방식으로", for: .normal)
})
alert.addAction(
Expand Down
6 changes: 6 additions & 0 deletions Common/LibTest/Sources/Router/LibRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public final class LibRouter: Routable {
} else {
topViewController.dismiss(animated: true, completion: nil)
}
case .pop:
if let navigationController = topViewController.navigationController {
navigationController.popViewController(animated: true)
} else {
topViewController.dismiss(animated: true, completion: nil)
}
}
}
}
6 changes: 6 additions & 0 deletions Common/LibTest/Sources/Router/SubRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public final class SubRouter: Routable {
} else {
topViewController.dismiss(animated: true, completion: nil)
}
case .pop:
if let navigationController = topViewController.navigationController {
navigationController.popViewController(animated: true)
} else {
topViewController.dismiss(animated: true, completion: nil)
}
}
}
}
32 changes: 29 additions & 3 deletions Feature/History/Sources/HistoryWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,34 @@ public final class HistoryWebViewController: BaseViewController {
self?.webView.load(request)
}
.store(in: &cancellables)

viewModel.output.needsRecovery
.removeDuplicates()
.receive(on: DispatchQueue.main)
.sink { [weak self] needsRecovery in
guard let self = self else { return }
guard needsRecovery else { return }
if UIApplication.shared.applicationState == .active {
self.recoverIfNeeded()
}
}
.store(in: &cancellables)

NotificationCenter.default.publisher(
for: UIApplication.willEnterForegroundNotification
)
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
self?.recoverIfNeeded()
}
.store(in: &cancellables)
}

private func recoverIfNeeded() {
guard viewModel.output.needsRecovery.value else { return }
showLoading()
webView.reload()
viewModel.send(input: .recovered)
}
}

Expand Down Expand Up @@ -84,8 +112,6 @@ extension HistoryWebViewController: WKNavigationDelegate {
}

public func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
// TODO: 뷰모델로 분리
hideLoading()
// TODO: 에러 처리
viewModel.send(input: .webContentProcessDidTerminate)
}
}
9 changes: 9 additions & 0 deletions Feature/History/Sources/HistoryWebViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ public final class HistoryWebViewModel {

enum Input {
case viewDidLoad
case webContentProcessDidTerminate
case recovered
}

struct Output {
let loadURL = PassthroughSubject<URLRequest, Never>()
let needsRecovery = CurrentValueSubject<Bool, Never>(false)
}

let output = Output()
Expand All @@ -28,6 +31,12 @@ public final class HistoryWebViewModel {
let url = URL(string: "https://clever-kataifi-dcedaf.netlify.app/lotto-history")!
let request = URLRequest(url: url)
output.loadURL.send(request)

case .webContentProcessDidTerminate:
output.needsRecovery.send(true)

case .recovered:
output.needsRecovery.send(false)
}
}
}
Loading