From b32c51172c370f7c2ab5b5276cb73229013f38d2 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Fri, 6 Oct 2023 17:16:57 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat=20::=20=EB=B0=80=EB=A6=AC=ED=84=B0?= =?UTF-8?q?=EB=A6=AC=20off=20=EC=82=AC=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Contents.json | 0 .../Frame 20767.svg | 14 +++++++++++++ .../Contents.json | 21 +++++++++++++++++++ .../Frame 20767.svg | 0 .../Sources/Image/JOBISIcon.swift | 10 ++++++--- 5 files changed, 42 insertions(+), 3 deletions(-) rename Projects/Shared/DesignSystem/Resources/Icons.xcassets/{MilitaryServiceExceptionIcon.imageset => MilitaryExceptionOff.imageset}/Contents.json (100%) create mode 100644 Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOff.imageset/Frame 20767.svg create mode 100644 Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOn.imageset/Contents.json rename Projects/Shared/DesignSystem/Resources/Icons.xcassets/{MilitaryServiceExceptionIcon.imageset => MilitaryExceptionOn.imageset}/Frame 20767.svg (100%) diff --git a/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryServiceExceptionIcon.imageset/Contents.json b/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOff.imageset/Contents.json similarity index 100% rename from Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryServiceExceptionIcon.imageset/Contents.json rename to Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOff.imageset/Contents.json diff --git a/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOff.imageset/Frame 20767.svg b/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOff.imageset/Frame 20767.svg new file mode 100644 index 00000000..d7e8d4f1 --- /dev/null +++ b/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOff.imageset/Frame 20767.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOn.imageset/Contents.json b/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOn.imageset/Contents.json new file mode 100644 index 00000000..7643931f --- /dev/null +++ b/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOn.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Frame 20767.svg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryServiceExceptionIcon.imageset/Frame 20767.svg b/Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOn.imageset/Frame 20767.svg similarity index 100% rename from Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryServiceExceptionIcon.imageset/Frame 20767.svg rename to Projects/Shared/DesignSystem/Resources/Icons.xcassets/MilitaryExceptionOn.imageset/Frame 20767.svg diff --git a/Projects/Shared/DesignSystem/Sources/Image/JOBISIcon.swift b/Projects/Shared/DesignSystem/Sources/Image/JOBISIcon.swift index e0c9a5ae..f3fef6c5 100644 --- a/Projects/Shared/DesignSystem/Sources/Image/JOBISIcon.swift +++ b/Projects/Shared/DesignSystem/Sources/Image/JOBISIcon.swift @@ -34,7 +34,8 @@ public struct JOBISIcon: View { case menu case profile case house - case militaryServiceExceptionIcon + case militaryExceptionOn + case militaryExceptionOff case bookmarkOn case bookmarkOff case filterIcon @@ -140,8 +141,11 @@ public struct JOBISIcon: View { case .house: return DesignSystemAsset.Icons.house.suiImage - case .militaryServiceExceptionIcon: - return DesignSystemAsset.Icons.militaryServiceExceptionIcon.suiImage + case .militaryExceptionOn: + return DesignSystemAsset.Icons.militaryExceptionOn.suiImage + + case .militaryExceptionOff: + return DesignSystemAsset.Icons.militaryExceptionOff.suiImage case .bookmarkOn: return DesignSystemAsset.Icons.bookmarkOn.suiImage From 7cd546a0235530de7e1d1b3de40308b42971e933 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Fri, 6 Oct 2023 17:17:11 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat=20::=20URL=20=EC=9D=B4=EB=A9=B4=20Imag?= =?UTF-8?q?e=20=EC=95=9E=EC=97=90=20URL=20=EC=95=88=20=EB=B6=99=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Shared/DesignSystem/Sources/Image/URLImage.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Projects/Shared/DesignSystem/Sources/Image/URLImage.swift b/Projects/Shared/DesignSystem/Sources/Image/URLImage.swift index d9bd717a..967d7a81 100644 --- a/Projects/Shared/DesignSystem/Sources/Image/URLImage.swift +++ b/Projects/Shared/DesignSystem/Sources/Image/URLImage.swift @@ -13,7 +13,11 @@ public struct URLImage: View { public init(imageURL urlString: String, shape: ImageShape) { let baseURL = Environment.getUrlValue(key: .s3BaseUrl) - self.imageURL = baseURL.appendingPathComponent(urlString) + if urlString.contains(baseURL.description) { + imageURL = URL(string: urlString) + } else { + self.imageURL = baseURL.appendingPathComponent(urlString) + } self.shape = shape } From 3d0149fa711d3547abb03089defa582d58b1a345 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Fri, 6 Oct 2023 17:17:23 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat=20::=20=20=EA=B0=95=EC=A0=9C=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SplashFeature/Sources/SplashView.swift | 68 ++++++++++------- .../Sources/SplashViewModel.swift | 75 +++++++++++-------- 2 files changed, 82 insertions(+), 61 deletions(-) diff --git a/Projects/Feature/SplashFeature/Sources/SplashView.swift b/Projects/Feature/SplashFeature/Sources/SplashView.swift index 66199280..f0c12f99 100644 --- a/Projects/Feature/SplashFeature/Sources/SplashView.swift +++ b/Projects/Feature/SplashFeature/Sources/SplashView.swift @@ -18,6 +18,45 @@ struct SplashView: View { .resizable() .frame(width: 200, height: 200) } + .alert(isPresented: $viewModel.showUpdateAlert) { + if viewModel.forceAlert { + return Alert( + title: Text(viewModel.alertTitle), + message: Text(viewModel.alertMessage), + dismissButton: Alert.Button.destructive( + Text("확인"), + action: { + viewModel.openAppStore() + } + ) + ) + } else { + let reissue: () -> Void = { + viewModel.compareRefreshToke { authority in + appState.authority = authority + appState.sceneFlow = .main + } onError: { _ in + appState.sceneFlow = .auth + } + } + + return Alert( + title: Text(viewModel.alertTitle), + message: Text(viewModel.alertMessage), + primaryButton: Alert.Button.destructive( + Text("확인"), + action: { + viewModel.openAppStore() + reissue() + } + ), + secondaryButton: Alert.Button.cancel( + Text("취소"), + action: reissue + ) + ) + } + } .onAppear { viewModel.onAppear { authority in appState.authority = authority @@ -26,34 +65,5 @@ struct SplashView: View { appState.sceneFlow = .auth } } - .alert(isPresented: $viewModel.showUpdateAlert) { - Alert( - title: Text(viewModel.alertTitle), - message: Text(viewModel.alertMessage), - primaryButton: Alert.Button.destructive( - Text("확인"), - action: { - viewModel.openAppStore() - appState.sceneFlow = .auth - } - ), - secondaryButton: Alert.Button.cancel( - Text("취소") - ) - ) - } - .alert(isPresented: $viewModel.showUpdateForceAlert) { - Alert( - title: Text(viewModel.alertTitle), - message: Text(viewModel.alertMessage), - dismissButton: Alert.Button.destructive( - Text("확인"), - action: { - viewModel.openAppStore() - appState.sceneFlow = .auth - } - ) - ) - } } } diff --git a/Projects/Feature/SplashFeature/Sources/SplashViewModel.swift b/Projects/Feature/SplashFeature/Sources/SplashViewModel.swift index c427a30d..97609fbc 100644 --- a/Projects/Feature/SplashFeature/Sources/SplashViewModel.swift +++ b/Projects/Feature/SplashFeature/Sources/SplashViewModel.swift @@ -7,7 +7,7 @@ import UsersDomainInterface final class SplashViewModel: BaseViewModel { private let reissueTokenUseCase: any ReissueTokenUseCase @Published var showUpdateAlert: Bool = false - @Published var showUpdateForceAlert: Bool = false + @Published var forceAlert: Bool = false public var alertTitle = "" public var alertMessage = "" private let appleID = "6450888392" @@ -23,46 +23,57 @@ final class SplashViewModel: BaseViewModel { onError: @escaping (Error) -> Void ) { update { - addCancellable(reissueTokenUseCase.execute()) { authority in - if authority { - onSuccess(.developer) - } else { - onSuccess(.student) - } - } onReceiveError: { error in - onError(error) + self.compareRefreshToke(onSuccess: onSuccess, onError: onError) + } + } + + func compareRefreshToke( + onSuccess: @escaping (AuthorityType) -> Void, + onError: @escaping (Error) -> Void + ) { + addCancellable(reissueTokenUseCase.execute()) { authority in + if authority { + onSuccess(.developer) + } else { + onSuccess(.student) } + } onReceiveError: { error in + onError(error) } } - private func update(action: () -> Void) { + private func update(action: @escaping () -> Void) { let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String + let urlString = "http://itunes.apple.com/lookup?id=\(self.appleID)&country=kr" - let latestVersion: String? = { - guard let url = URL(string: "http://itunes.apple.com/lookup?id=\(self.appleID)&country=kr"), - let data = try? Data(contentsOf: url), - let json = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any], + guard appVersion != "0.0.0" else { return action() } + guard let url = URL(string: urlString) else { return } + let urlRequest = URLRequest(url: url) + URLSession.shared.dataTask(with: urlRequest) { data, _, _ in + guard let json = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String: Any], let results = json["results"] as? [[String: Any]], - let appStoreVersion = results[0]["version"] as? String else { - return nil - } - return appStoreVersion - }() - - let marketingVersion = latestVersion! - let currentProjectVersion = appVersion! - let splitMarketingVersion = marketingVersion.split(separator: ".").map {$0} - let splitCurrentProjectVersion = currentProjectVersion.split(separator: ".").map {$0} + let marketingVersion = results[0]["version"] as? String else { return } + let currentProjectVersion = appVersion! + let splitMarketingVersion = marketingVersion.split(separator: ".").map {$0} + let splitCurrentProjectVersion = currentProjectVersion.split(separator: ".").map {$0} - alertTitle = "업데이트 알림" - alertMessage = "JOBIS의 새로운 버전이 있습니다.\n\(marketingVersion) 버전으로 업데이트 해주세요." - if splitCurrentProjectVersion[0] < splitMarketingVersion[0] { - showUpdateForceAlert.toggle() - } else if splitCurrentProjectVersion[1] < splitMarketingVersion[1] { - showUpdateForceAlert.toggle() - } else { - showUpdateAlert.toggle() + DispatchQueue.main.async { + self.alertTitle = "업데이트 알림" + self.alertMessage = "JOBIS의 새로운 버전이 있습니다.\n\(marketingVersion) 버전으로 업데이트 해주세요." + if splitCurrentProjectVersion[0] < splitMarketingVersion[0] { + self.showUpdateAlert.toggle() + self.forceAlert.toggle() + } else if splitCurrentProjectVersion[1] < splitMarketingVersion[1] { + self.showUpdateAlert.toggle() + self.forceAlert.toggle() + } else if splitCurrentProjectVersion[2] < splitMarketingVersion[2] { + self.showUpdateAlert.toggle() + } else { + action() + } + } } + .resume() } func openAppStore() {