From b33adb02b320df5223a57c179f638b3aaede3af9 Mon Sep 17 00:00:00 2001 From: Zoe Date: Sat, 16 Nov 2024 03:41:41 +0900 Subject: [PATCH 01/15] =?UTF-8?q?[Feat/#104]=20DSKit=EC=97=90=EC=84=9C=20L?= =?UTF-8?q?ottie=20=EC=82=AC=EC=9A=A9=EC=9D=84=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EC=8A=A4=ED=85=90=EC=8B=A4=ED=8C=8C=EC=9D=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tuist/ResourceSynthesizers/Lottie.stencil | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 HMH_Tuist_iOS/Tuist/ResourceSynthesizers/Lottie.stencil diff --git a/HMH_Tuist_iOS/Tuist/ResourceSynthesizers/Lottie.stencil b/HMH_Tuist_iOS/Tuist/ResourceSynthesizers/Lottie.stencil new file mode 100644 index 00000000..b420b4aa --- /dev/null +++ b/HMH_Tuist_iOS/Tuist/ResourceSynthesizers/Lottie.stencil @@ -0,0 +1,58 @@ +// swiftformat:disable all +// swiftlint:disable all +{% if files %} +{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %} +{% set documentPrefix %}{{param.documentName|default:"Document"}}{% endset %} +import Foundation +#if canImport(Lottie) +import Lottie +// MARK: - Animations Assets +{{accessModifier}} extension AnimationAsset { + {% for file in files %} + static let {{file.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = Self(named: "{{file.name}}") + {% endfor %} +} +// MARK: - Animation Helpers +{{accessModifier}} extension AnimationAsset { + /// All the available animation. Can be used to preload them + static let allAnimations: [Self] = [ + {% for file in files %} + Self.{{file.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}, + {% endfor %} + ] +} +// MARK: - Structures +{{accessModifier}} struct AnimationAsset: Hashable { + {{accessModifier}} fileprivate(set) var name: String + {{accessModifier}} let animation: LottieAnimation? + {{accessModifier}} init(named name: String) { + self.name = name + if let url = Bundle.module.url(forResource: name, withExtension: "json") { + self.animation = LottieAnimation.filepath(url.path) + } else { + self.animation = nil + } + } + // MARK: Hashable Conformance + {{accessModifier}} static func == (lhs: Self, rhs: Self) -> Bool { + return lhs.name == rhs.name + } + {{accessModifier}} func hash(into hasher: inout Hasher) { + hasher.combine(self.name) + } +} +// MARK: - Preload Helpers +{{accessModifier}} extension AnimationAsset { + /// Preloads all the Lottie Animations to avoid performance issues when loading them + static func preload() -> Void { + for animationAsset in Self.allAnimations { + _ = animationAsset.animation + } + } +} +// swiftformat:enable all +// swiftlint:enable all +#endif +{% else %} +// No files found +{% endif %} From 7c3c74aea98561b0d6ba85bec5b44ea43b572cca Mon Sep 17 00:00:00 2001 From: Zoe Date: Sat, 16 Nov 2024 03:43:04 +0900 Subject: [PATCH 02/15] =?UTF-8?q?[Feat/#104]=20App=20State=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_Tuist_iOS/Projects/Core/Sources/AppState.swift | 9 --------- .../Projects/Core/Sources/Manager/UserManager.swift | 8 ++++++++ 2 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 HMH_Tuist_iOS/Projects/Core/Sources/AppState.swift diff --git a/HMH_Tuist_iOS/Projects/Core/Sources/AppState.swift b/HMH_Tuist_iOS/Projects/Core/Sources/AppState.swift deleted file mode 100644 index 1410a996..00000000 --- a/HMH_Tuist_iOS/Projects/Core/Sources/AppState.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Foundation - -public enum AppState: String { - case login - case onboarding - case onboardingComplete - case home - case servicePrepare -} diff --git a/HMH_Tuist_iOS/Projects/Core/Sources/Manager/UserManager.swift b/HMH_Tuist_iOS/Projects/Core/Sources/Manager/UserManager.swift index 7a87de2d..7f2ba4e5 100644 --- a/HMH_Tuist_iOS/Projects/Core/Sources/Manager/UserManager.swift +++ b/HMH_Tuist_iOS/Projects/Core/Sources/Manager/UserManager.swift @@ -7,6 +7,14 @@ import SwiftUI +public enum AppState: String { + case login + case onboarding + case onboardingComplete + case home + case servicePrepare +} + public class UserManager: ObservableObject { @KeychainStorage("accessToken") public var accessToken @KeychainStorage("refreshToken") public var refreshToken From 37b0c4a7232925d8309de4eced0a3b3ec42c9704 Mon Sep 17 00:00:00 2001 From: Zoe Date: Sat, 16 Nov 2024 03:44:04 +0900 Subject: [PATCH 03/15] =?UTF-8?q?[Feat/#104]=20=EC=BD=94=EB=94=94=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=A0=81=EC=9A=A9=EC=9C=BC=EB=A1=9C=20Con?= =?UTF-8?q?tentView=20AppView=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Projects/App/Sources/AppView.swift | 31 +++++++ .../Sources/Common/Custom/ContentView.swift | 91 ------------------- .../Projects/App/Sources/HMH_iOSApp.swift | 12 +-- 3 files changed, 32 insertions(+), 102 deletions(-) create mode 100644 HMH_Tuist_iOS/Projects/App/Sources/AppView.swift delete mode 100644 HMH_Tuist_iOS/Projects/App/Sources/Common/Custom/ContentView.swift diff --git a/HMH_Tuist_iOS/Projects/App/Sources/AppView.swift b/HMH_Tuist_iOS/Projects/App/Sources/AppView.swift new file mode 100644 index 00000000..6c517bea --- /dev/null +++ b/HMH_Tuist_iOS/Projects/App/Sources/AppView.swift @@ -0,0 +1,31 @@ +// +// AppView.swift +// HMH-iOS +// +// Created by 이지희 on 11/15/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import SwiftUI + +import KakaoSDKAuth + +import DSKit +import Core + +struct AppView: View { + @StateObject var coordinator = AppCoordinator(navigationPath: .init()) + + var body: some View { + ZStack { + Color(DSKitAsset.blackground.swiftUIColor) + .ignoresSafeArea(.all) + coordinator.start() + } + .onOpenURL { url in + if AuthApi.isKakaoTalkLoginUrl(url) { + _ = AuthController.handleOpenUrl(url: url) + } + } + } +} diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Common/Custom/ContentView.swift b/HMH_Tuist_iOS/Projects/App/Sources/Common/Custom/ContentView.swift deleted file mode 100644 index 5f2d4e95..00000000 --- a/HMH_Tuist_iOS/Projects/App/Sources/Common/Custom/ContentView.swift +++ /dev/null @@ -1,91 +0,0 @@ -// -// ContentView.swift -// HMH_iOS -// -// Created by 지희의 MAC on 2/15/24. -// - -import SwiftUI - -import KakaoSDKAuth - -import LoginFeature -import OnboardingFeature -import MyPageFeature -import HomeFeature - -import DSKit -import Core - -struct ContentView: View { - @StateObject var loginViewModel = LoginViewModel() - @StateObject var userManager = UserManager.shared - @StateObject var appStateViewModel = AppStateViewModel.shared - - @State private var showWelcomeAlert = false - - var body: some View { - ZStack { - Color(DSKitAsset.blackground.swiftUIColor) - .ignoresSafeArea() - if loginViewModel.isLoading { - SplashView(viewModel: loginViewModel) - } else { - switch userManager.appState { - case .onboarding: - OnboardingContentView() - case .onboardingComplete: - OnboardingCompleteView() - case .servicePrepare: - ServicePrepareView() - case .home: - TabBarView() - .onAppear { - appStateViewModel.onAppear() - if userManager.isFirstLogin { - showWelcomeAlert = true - userManager.isFirstLogin = false - } - } - .overlay( - CustomAlertView( - alertType: appStateViewModel.currentAlertType, - confirmBtn: CustomAlertButtonView( - buttonType: .Confirm, - alertType: appStateViewModel.currentAlertType, - isPresented: $appStateViewModel.showCustomAlert, - action: { - appStateViewModel.cancelAlert() - } - ), - cancelBtn: CustomAlertButtonView( - buttonType: .Cancel, - alertType: appStateViewModel.currentAlertType, - isPresented: $appStateViewModel.showCustomAlert, - action: { - appStateViewModel.nextAlert() - } - ), currentPoint: appStateViewModel.currentPoint, usagePoint: appStateViewModel.usagePoint - ) - .opacity(appStateViewModel.showCustomAlert ? 1 : 0) - ) - .overlay( - GuideView(isPresented: $showWelcomeAlert) - .opacity(showWelcomeAlert ? 1 : 0) - ) - case .login: - LoginView(viewModel: loginViewModel) - .onOpenURL { url in - if AuthApi.isKakaoTalkLoginUrl(url) { - _ = AuthController.handleOpenUrl(url: url) - } - } - } - } - } - } -} - -#Preview { - ContentView() -} diff --git a/HMH_Tuist_iOS/Projects/App/Sources/HMH_iOSApp.swift b/HMH_Tuist_iOS/Projects/App/Sources/HMH_iOSApp.swift index dba4075a..1401fb7c 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/HMH_iOSApp.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/HMH_iOSApp.swift @@ -14,7 +14,6 @@ import KakaoSDKAuth struct HMH_iOSApp: App { let kakaoAPIKey = Bundle.main.infoDictionary?["KAKAO_API_KEY"] as! String @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate - @StateObject private var scheduler = MidnightTaskScheduler() @Environment(\.scenePhase) private var scenePhase init() { @@ -23,16 +22,7 @@ struct HMH_iOSApp: App { var body: some Scene { WindowGroup { - ContentView() - } - .onChange(of: scenePhase) { newPhase in - switch newPhase { - case .background: - print("App moved to background.") - scheduler.scheduleMidnightTask() - @unknown default: - break - } + AppView() } } } From 28fc60fbd1273910774974015787c4d903756066 Mon Sep 17 00:00:00 2001 From: Zoe Date: Sat, 16 Nov 2024 03:45:33 +0900 Subject: [PATCH 04/15] =?UTF-8?q?[Feat/#104]=20=EC=B5=9C=EC=83=81=EC=9C=84?= =?UTF-8?q?=20Coordinator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Coordinator/AppCoordinator.swift | 64 +++++++++++++++++++ .../Sources/Coordinator/BaseCoordinator.swift | 38 +++++++++++ 2 files changed, 102 insertions(+) create mode 100644 HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift create mode 100644 HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift new file mode 100644 index 00000000..8b87d981 --- /dev/null +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift @@ -0,0 +1,64 @@ +// +// AppCoordinator.swift +// Coordinator +// +// Created by 이지희 on 11/7/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import SwiftUI + +import Core +import LoginFeature +import OnboardingFeature +import MyPageFeature + + +final class AppCoordinator: ObservableObject, CoordinatorType { + @Published var currentView: AnyView = AnyView(SplashView(coordinator: AppCoordinator(navigationPath: .init()))) + @Published var appState: AppState = .login + + var navigationPath: NavigationPath + var parentCoordinator: (any CoordinatorType)? + + init(navigationPath: NavigationPath) { + self.navigationPath = navigationPath + } + + func start() -> AnyView { + // 초기 상태에 따라 적절한 뷰를 설정합니다. + showSplashScreen() + return currentView + } + + private func showSplashScreen() { + currentView = AnyView(SplashView(coordinator: self)) // 코디네이터 주입 + + /// 스플래쉬에서 토큰 검사 과정 (혹은 홈뷰 API 호출) 로 로그인 필요 여부 확인 + } + + func transitionToNextView() { + switch UserManager.shared.appState { + case .onboarding: + currentView = AnyView(OnboardingContentView()) + case .onboardingComplete: + currentView = AnyView(OnboardingCompleteView()) + case .servicePrepare: + currentView = AnyView(ServicePrepareView()) + case .home: + startTabBar() + case .login: + startLogin() + } + } + + func startLogin() { + let authCoordinator = AuthCoordinator(parentCoordinator: self, navigationPath: navigationPath) + currentView = authCoordinator.start() + } + + func startTabBar() { + let tabBarCoordinator = TabBarCoordinator(parentCoordinator: self, navigationPath: self.navigationPath) + currentView = tabBarCoordinator.start() + } +} diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift new file mode 100644 index 00000000..1b457c7e --- /dev/null +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift @@ -0,0 +1,38 @@ +// +// BaseCoordinator.swift +// Coordinator +// +// Created by 이지희 on 11/7/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// +import SwiftUI +import Combine + +import Core + +// MARK: - BaseCoordinator 프로토콜 +public protocol CoordinatorType: AnyObject { + + var parentCoordinator: (any CoordinatorType)? { get set } + var navigationPath: NavigationPath { get set } + + func start() -> AnyView + + func push(to view: any Hashable) + func pop() + func popToRoot() +} + +extension CoordinatorType { + func push(to view: any Hashable) { + navigationPath.append(view) + } + + func pop() { + navigationPath.removeLast() + } + + func popToRoot() { + navigationPath.removeLast(navigationPath.count) + } +} From 866653f364634240aeb878c2f4136f27cc20685a Mon Sep 17 00:00:00 2001 From: Zoe Date: Sat, 16 Nov 2024 03:46:12 +0900 Subject: [PATCH 05/15] =?UTF-8?q?[Fix/#104]=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EB=B7=B0=EB=AA=A8=EB=8D=B8=20=EC=A3=BC=EC=9E=85=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=BD=94=EB=94=94=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=ED=84=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../App/Sources/Common/Custom/SplashView.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Common/Custom/SplashView.swift b/HMH_Tuist_iOS/Projects/App/Sources/Common/Custom/SplashView.swift index f2ae4aaa..37afaaf4 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/Common/Custom/SplashView.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/Common/Custom/SplashView.swift @@ -7,13 +7,13 @@ import SwiftUI -import Lottie - -import LoginFeature import DSKit +import Core + +import Lottie struct SplashView: View { - @ObservedObject var viewModel: LoginViewModel + @ObservedObject var coordinator: AppCoordinator var body: some View { ZStack { @@ -29,9 +29,9 @@ struct SplashView: View { .frame(maxWidth: .infinity, maxHeight: .infinity) .background(DSKitAsset.blackground.swiftUIColor, ignoresSafeAreaEdges: .all) .onAppear { - DispatchQueue.main.asyncAfter(deadline: .now() + 3.5, execute: { -// viewModel.handleSplashScreen() - }) + DispatchQueue.main.asyncAfter(deadline: .now() + 3.5) { + coordinator.appState = .login // Splash에서 홈뷰 통신하면서 상태 판단 필요 + } } } } From 9fdebbdfa0e98b372ce69bfe2296bed442ded5f1 Mon Sep 17 00:00:00 2001 From: Zoe Date: Sat, 16 Nov 2024 03:46:39 +0900 Subject: [PATCH 06/15] =?UTF-8?q?[Feat/#104]=20Feature=EB=B3=84=20?= =?UTF-8?q?=EC=BD=94=EB=94=94=EB=84=A4=EC=9D=B4=ED=84=B0=20=EC=A0=9C?= =?UTF-8?q?=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Coordinator/AuthCoordinator.swift | 29 +++++++++++++++ .../Coordinator/OnboardingCoordinator.swift | 29 +++++++++++++++ .../Coordinator/TabBarCoordinator.swift | 35 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift create mode 100644 HMH_Tuist_iOS/Projects/App/Sources/Coordinator/OnboardingCoordinator.swift create mode 100644 HMH_Tuist_iOS/Projects/App/Sources/Coordinator/TabBarCoordinator.swift diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift new file mode 100644 index 00000000..4bff3112 --- /dev/null +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift @@ -0,0 +1,29 @@ +// +// LoginCoordinator.swift +// Coordinator +// +// Created by 이지희 on 11/15/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import SwiftUI + +import LoginFeature + +final class AuthCoordinator: ObservableObject, CoordinatorType { + var parentCoordinator: (any CoordinatorType)? + + var navigationPath: NavigationPath + + init( + parentCoordinator: any CoordinatorType, + navigationPath: NavigationPath + ) { + self.parentCoordinator = parentCoordinator + self.navigationPath = navigationPath + } + + func start() -> AnyView { + return AnyView(LoginView(viewModel: LoginViewModel())) + } +} diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/OnboardingCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/OnboardingCoordinator.swift new file mode 100644 index 00000000..9270f8c3 --- /dev/null +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/OnboardingCoordinator.swift @@ -0,0 +1,29 @@ +// +// OnboardingCoordinator.swift +// Coordinator +// +// Created by 이지희 on 11/15/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import SwiftUI + +import OnboardingFeature + +final class OnboardingCoordinator: ObservableObject, CoordinatorType { + var parentCoordinator: (any CoordinatorType)? + + var navigationPath: NavigationPath + + init( + parentCoordinator: (any CoordinatorType)? = nil, + navigationPath: NavigationPath + ) { + self.parentCoordinator = parentCoordinator + self.navigationPath = navigationPath + } + + func start() -> AnyView { + return AnyView(OnboardingContentView()) + } +} diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/TabBarCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/TabBarCoordinator.swift new file mode 100644 index 00000000..bb88f97f --- /dev/null +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/TabBarCoordinator.swift @@ -0,0 +1,35 @@ +// +// TabBarCoordinator.swift +// Coordinator +// +// Created by 이지희 on 11/15/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import SwiftUI + +class TabBarCoordinator: ObservableObject, CoordinatorType { + var navigationPath: NavigationPath + + var parentCoordinator: (any CoordinatorType)? + + @Published var selectedTab: Tab = .home + + init( + parentCoordinator: CoordinatorType, + navigationPath: NavigationPath + ) { + self.parentCoordinator = parentCoordinator + self.navigationPath = navigationPath + } + + func start() -> AnyView { + AnyView(TabBarView()) + } + + enum Tab { + case home + case challenge + case myPage + } +} From b3ce6516a709eea74a8f9784fc2df9918e310ce9 Mon Sep 17 00:00:00 2001 From: Zoe Date: Sat, 16 Nov 2024 03:49:38 +0900 Subject: [PATCH 07/15] =?UTF-8?q?[Delete/#104]=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_Tuist_iOS/Projects/App/Sources/Example.swift | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 HMH_Tuist_iOS/Projects/App/Sources/Example.swift diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Example.swift b/HMH_Tuist_iOS/Projects/App/Sources/Example.swift deleted file mode 100644 index e69de29b..00000000 From 02c6a5898818b084108790e3c69804c01fc81109 Mon Sep 17 00:00:00 2001 From: Zoe Date: Sat, 16 Nov 2024 03:50:42 +0900 Subject: [PATCH 08/15] =?UTF-8?q?[Chore/#104]=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Projects/App/Sources/Manager/.gitkeep | 0 .../Projects/App/Sources/Manager/NotificationManager.swift | 0 .../Projects/App/Sources/Manager/UserDefaultsManager.swift | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename "HMH_Tuist_iOS/Projects/App/Sources/Manager \354\230\244\355\233\204 9.25.10 \354\230\244\355\233\204 9.35.22/.gitkeep" => HMH_Tuist_iOS/Projects/App/Sources/Manager/.gitkeep (100%) rename "HMH_Tuist_iOS/Projects/App/Sources/Manager \354\230\244\355\233\204 9.25.10 \354\230\244\355\233\204 9.35.22/NotificationManager.swift" => HMH_Tuist_iOS/Projects/App/Sources/Manager/NotificationManager.swift (100%) rename "HMH_Tuist_iOS/Projects/App/Sources/Manager \354\230\244\355\233\204 9.25.10 \354\230\244\355\233\204 9.35.22/UserDefaultsManager.swift" => HMH_Tuist_iOS/Projects/App/Sources/Manager/UserDefaultsManager.swift (100%) diff --git "a/HMH_Tuist_iOS/Projects/App/Sources/Manager \354\230\244\355\233\204 9.25.10 \354\230\244\355\233\204 9.35.22/.gitkeep" b/HMH_Tuist_iOS/Projects/App/Sources/Manager/.gitkeep similarity index 100% rename from "HMH_Tuist_iOS/Projects/App/Sources/Manager \354\230\244\355\233\204 9.25.10 \354\230\244\355\233\204 9.35.22/.gitkeep" rename to HMH_Tuist_iOS/Projects/App/Sources/Manager/.gitkeep diff --git "a/HMH_Tuist_iOS/Projects/App/Sources/Manager \354\230\244\355\233\204 9.25.10 \354\230\244\355\233\204 9.35.22/NotificationManager.swift" b/HMH_Tuist_iOS/Projects/App/Sources/Manager/NotificationManager.swift similarity index 100% rename from "HMH_Tuist_iOS/Projects/App/Sources/Manager \354\230\244\355\233\204 9.25.10 \354\230\244\355\233\204 9.35.22/NotificationManager.swift" rename to HMH_Tuist_iOS/Projects/App/Sources/Manager/NotificationManager.swift diff --git "a/HMH_Tuist_iOS/Projects/App/Sources/Manager \354\230\244\355\233\204 9.25.10 \354\230\244\355\233\204 9.35.22/UserDefaultsManager.swift" b/HMH_Tuist_iOS/Projects/App/Sources/Manager/UserDefaultsManager.swift similarity index 100% rename from "HMH_Tuist_iOS/Projects/App/Sources/Manager \354\230\244\355\233\204 9.25.10 \354\230\244\355\233\204 9.35.22/UserDefaultsManager.swift" rename to HMH_Tuist_iOS/Projects/App/Sources/Manager/UserDefaultsManager.swift From 0b7bfc3b05f7af3ede92a947608f9c30579ba3e8 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 28 Nov 2024 04:20:30 +0900 Subject: [PATCH 09/15] =?UTF-8?q?[Fix/#104]=20=EC=BD=94=EB=94=94=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Coordinator/AppCoordinator.swift | 14 ++++++++------ .../Sources/Coordinator/AuthCoordinator.swift | 17 +++++++++-------- .../Sources/Coordinator/BaseCoordinator.swift | 6 +++--- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift index 8b87d981..52cbf5b2 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift @@ -15,14 +15,15 @@ import MyPageFeature final class AppCoordinator: ObservableObject, CoordinatorType { - @Published var currentView: AnyView = AnyView(SplashView(coordinator: AppCoordinator(navigationPath: .init()))) + @Published var currentView: AnyView = AnyView(EmptyView()) @Published var appState: AppState = .login - var navigationPath: NavigationPath - var parentCoordinator: (any CoordinatorType)? + + var navigationPath: NavigationPath = NavigationPath() + private let diContainer: AppDIContainer - init(navigationPath: NavigationPath) { - self.navigationPath = navigationPath + init(diContainer: AppDIContainer) { + self.diContainer = diContainer } func start() -> AnyView { @@ -53,7 +54,8 @@ final class AppCoordinator: ObservableObject, CoordinatorType { } func startLogin() { - let authCoordinator = AuthCoordinator(parentCoordinator: self, navigationPath: navigationPath) + let authDIContainer = diContainer.injectAuthDIContainer() + let authCoordinator = AuthCoordinator(navigationPath: navigationPath, diContainer: authDIContainer) currentView = authCoordinator.start() } diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift index 4bff3112..933126c9 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift @@ -11,19 +11,20 @@ import SwiftUI import LoginFeature final class AuthCoordinator: ObservableObject, CoordinatorType { - var parentCoordinator: (any CoordinatorType)? - var navigationPath: NavigationPath - + private let diContainer: AuthDIContainer + init( - parentCoordinator: any CoordinatorType, - navigationPath: NavigationPath + navigationPath: NavigationPath, + diContainer: AuthDIContainer ) { - self.parentCoordinator = parentCoordinator self.navigationPath = navigationPath + self.diContainer = diContainer } - + func start() -> AnyView { - return AnyView(LoginView(viewModel: LoginViewModel())) + let viewModel = diContainer.injectLoginViewModel() + let view = LoginView(viewModel: viewModel) + return AnyView(view) } } diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift index 1b457c7e..08808fb4 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift @@ -10,10 +10,10 @@ import Combine import Core -// MARK: - BaseCoordinator 프로토콜 +// MARK: - BaseCoordinator + +/// NavigationStack을 사용할 경우 이전에 대한 정보를 모두 갖고 있기 때문에 부모 - 자식 코디네이터 불필요 public protocol CoordinatorType: AnyObject { - - var parentCoordinator: (any CoordinatorType)? { get set } var navigationPath: NavigationPath { get set } func start() -> AnyView From 2b2ea228daa697d001263d31109df1b73cce4721 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 28 Nov 2024 04:21:05 +0900 Subject: [PATCH 10/15] =?UTF-8?q?[Feat/#104]=20Feature=20DIContainer=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/DIContainer/AuthDIContainer.swift | 46 +++++++++++++++++++ .../DIContainer/ChallengeDIContainer.swift | 32 +++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 HMH_Tuist_iOS/Projects/App/Sources/DIContainer/AuthDIContainer.swift create mode 100644 HMH_Tuist_iOS/Projects/App/Sources/DIContainer/ChallengeDIContainer.swift diff --git a/HMH_Tuist_iOS/Projects/App/Sources/DIContainer/AuthDIContainer.swift b/HMH_Tuist_iOS/Projects/App/Sources/DIContainer/AuthDIContainer.swift new file mode 100644 index 00000000..9796e963 --- /dev/null +++ b/HMH_Tuist_iOS/Projects/App/Sources/DIContainer/AuthDIContainer.swift @@ -0,0 +1,46 @@ +// +// AuthDIContainer.swift +// HMH-iOS +// +// Created by 이지희 on 11/28/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import Foundation + +import Networks +import Core +import Data +import Domain + +// TODO: UseCase가 Feature안에 존재해서 import 수정 후 import 제거 +import LoginFeature + +final class AuthDIContainer: ObservableObject { + + private let services: AuthService + private let oAuthServiceFactory: OAuthServiceFactory + + init(services: AuthService, oAuthServiceFactory: OAuthServiceFactory) { + self.services = services + self.oAuthServiceFactory = oAuthServiceFactory + } + + func injectLoginViewModel() -> LoginViewModel { + let useCase = injectLoginUseCase() + return LoginViewModel(loginUseCase: useCase) + } + + // MARK: Usecase + + private func injectLoginUseCase() -> LoginUseCase { + let repository = injectAuthRepository() + return LoginUseCase(repository: repository) + } + + // MARK: Repository + + private func injectAuthRepository() -> AuthRepository { + return AuthRepository(authService: services, oauthServiceFactory: oAuthServiceFactory) + } +} diff --git a/HMH_Tuist_iOS/Projects/App/Sources/DIContainer/ChallengeDIContainer.swift b/HMH_Tuist_iOS/Projects/App/Sources/DIContainer/ChallengeDIContainer.swift new file mode 100644 index 00000000..62dcd935 --- /dev/null +++ b/HMH_Tuist_iOS/Projects/App/Sources/DIContainer/ChallengeDIContainer.swift @@ -0,0 +1,32 @@ +// +// ChallengeDIContainer.swift +// HMH-iOS +// +// Created by 이지희 on 11/27/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import Networks + +import Core +import Data +import Domain + +final class ChallengeDIContainer { + + private let service: ChallengeService = ChallengeService() + + // MARK: Usecase + + private func injectChallengeUseCase() -> ChallengeUseCase { + return ChallengeUseCase( + repository: injectChallengeRepository() + ) + } + + // MARK: Repository + + private func injectChallengeRepository() -> ChallengeRepository { + return ChallengeRepository(service: service) + } +} From 027a2e0d7b97238c32f2b4e90e31114f437d27a8 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 28 Nov 2024 04:21:26 +0900 Subject: [PATCH 11/15] [Feat/#104] AppDIContainer --- .../Sources/DIContainer/AppDIContainer.swift | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 HMH_Tuist_iOS/Projects/App/Sources/DIContainer/AppDIContainer.swift diff --git a/HMH_Tuist_iOS/Projects/App/Sources/DIContainer/AppDIContainer.swift b/HMH_Tuist_iOS/Projects/App/Sources/DIContainer/AppDIContainer.swift new file mode 100644 index 00000000..684681cf --- /dev/null +++ b/HMH_Tuist_iOS/Projects/App/Sources/DIContainer/AppDIContainer.swift @@ -0,0 +1,31 @@ +// +// AppDIConatiner.swift +// HMH-iOS +// +// Created by 이지희 on 11/27/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import SwiftUI + +import Networks +import Data +import Domain + +final class AppDIContainer: ObservableObject { + + // Auth DI + func injectAuthDIContainer() -> AuthDIContainer { + let service = injectAuthService() + let serviceFactory = injectOAuthFactory() + return AuthDIContainer(services: service, oAuthServiceFactory: serviceFactory) + } + + private func injectAuthService() -> AuthService { + return AuthService() + } + + private func injectOAuthFactory() -> OAuthServiceFactory { + return OAuthServiceFactory() + } +} From ed986c4d071e75c9c7abd0bcadd32cbe64bbe635 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 28 Nov 2024 04:21:59 +0900 Subject: [PATCH 12/15] =?UTF-8?q?[Feat/#104]=20AppDIContainer=20=EC=A3=BC?= =?UTF-8?q?=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_Tuist_iOS/Projects/App/Sources/AppView.swift | 1 + HMH_Tuist_iOS/Projects/App/Sources/HMH_iOSApp.swift | 2 ++ 2 files changed, 3 insertions(+) diff --git a/HMH_Tuist_iOS/Projects/App/Sources/AppView.swift b/HMH_Tuist_iOS/Projects/App/Sources/AppView.swift index 6c517bea..2bce6222 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/AppView.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/AppView.swift @@ -14,6 +14,7 @@ import DSKit import Core struct AppView: View { + @EnvironmentObject var appDIContainer: AppDIContainer @StateObject var coordinator = AppCoordinator(navigationPath: .init()) var body: some View { diff --git a/HMH_Tuist_iOS/Projects/App/Sources/HMH_iOSApp.swift b/HMH_Tuist_iOS/Projects/App/Sources/HMH_iOSApp.swift index 1401fb7c..0047f423 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/HMH_iOSApp.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/HMH_iOSApp.swift @@ -14,6 +14,7 @@ import KakaoSDKAuth struct HMH_iOSApp: App { let kakaoAPIKey = Bundle.main.infoDictionary?["KAKAO_API_KEY"] as! String @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate + @StateObject private var appDIContainer = AppDIContainer() @Environment(\.scenePhase) private var scenePhase init() { @@ -23,6 +24,7 @@ struct HMH_iOSApp: App { var body: some Scene { WindowGroup { AppView() + .environmentObject(appDIContainer) } } } From e3177d2199a7bfed62615d0a116b9768d30e781b Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 28 Nov 2024 04:22:32 +0900 Subject: [PATCH 13/15] =?UTF-8?q?[Fix/#104]=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Mapper/Challenge/ChallengeDetailMapper.swift | 2 +- .../Sources/Service/Challenge/ChallengeService.swift | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/HMH_Tuist_iOS/Projects/Data/Sources/Mapper/Challenge/ChallengeDetailMapper.swift b/HMH_Tuist_iOS/Projects/Data/Sources/Mapper/Challenge/ChallengeDetailMapper.swift index 6ee75462..b95b36f1 100644 --- a/HMH_Tuist_iOS/Projects/Data/Sources/Mapper/Challenge/ChallengeDetailMapper.swift +++ b/HMH_Tuist_iOS/Projects/Data/Sources/Mapper/Challenge/ChallengeDetailMapper.swift @@ -14,7 +14,7 @@ import Networks extension GetChallengeResult { public func toEntity() -> ChallengeDetail { .init( - statuses: statuses, + statuses: statuses.map{ PointStatusEnum(rawValue: $0) ?? .none}, todayIndex: todayIndex, startDate: startDate, challengeInfo: .init( diff --git a/HMH_Tuist_iOS/Projects/Modules/Networks/Sources/Service/Challenge/ChallengeService.swift b/HMH_Tuist_iOS/Projects/Modules/Networks/Sources/Service/Challenge/ChallengeService.swift index 5c1a33f6..d8544ffa 100644 --- a/HMH_Tuist_iOS/Projects/Modules/Networks/Sources/Service/Challenge/ChallengeService.swift +++ b/HMH_Tuist_iOS/Projects/Modules/Networks/Sources/Service/Challenge/ChallengeService.swift @@ -23,11 +23,12 @@ public protocol ChallengeServiceType { } extension ChallengeService: ChallengeServiceType { + public func getDailyChallenge() -> AnyPublisher { return requestWithResult(.getdailyChallenge) } - public func getSuccesChallenge() -> AnyPublisher { + public func postSuccesChallenge(request: ChallengeSuccessRequest) -> AnyPublisher { return requestWithResult(.postSuccesChallenge) } @@ -65,7 +66,7 @@ public struct StubChallengeService: ChallengeServiceType { .eraseToAnyPublisher() } - public func getSuccesChallenge() -> AnyPublisher { + public func postSuccesChallenge(request: ChallengeSuccessRequest) -> AnyPublisher { return Just(.stub) .setFailureType(to: HMHNetworkError.self) .eraseToAnyPublisher() From fc23a087287d6ea10c3cbbc3170e706838d28602 Mon Sep 17 00:00:00 2001 From: Zoe Date: Thu, 28 Nov 2024 04:23:03 +0900 Subject: [PATCH 14/15] =?UTF-8?q?[Chore/#104]=20Domain=EC=97=90=20DSKit=20?= =?UTF-8?q?=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HMH_Tuist_iOS/Projects/Domain/Project.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HMH_Tuist_iOS/Projects/Domain/Project.swift b/HMH_Tuist_iOS/Projects/Domain/Project.swift index 433e3d79..02c989c9 100644 --- a/HMH_Tuist_iOS/Projects/Domain/Project.swift +++ b/HMH_Tuist_iOS/Projects/Domain/Project.swift @@ -15,6 +15,7 @@ let project = Project.makeModule( name: "Domain", targets: [.dynamicFramework], internalDependencies: [ - .core + .core, + .Modules.dsKit ] ) From 3063dad8a54f424cd11178be16e0881a09192152 Mon Sep 17 00:00:00 2001 From: Zoe Date: Wed, 18 Dec 2024 23:59:26 +0900 Subject: [PATCH 15/15] =?UTF-8?q?[Chore/#104]=20Coordinator=20Type=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Projects/App/Sources/Coordinator/BaseCoordinator.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift index 08808fb4..08b6a2fe 100644 --- a/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift +++ b/HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift @@ -14,9 +14,11 @@ import Core /// NavigationStack을 사용할 경우 이전에 대한 정보를 모두 갖고 있기 때문에 부모 - 자식 코디네이터 불필요 public protocol CoordinatorType: AnyObject { + associatedtype View: SwiftUI.View + var navigationPath: NavigationPath { get set } - func start() -> AnyView + func start() -> View func push(to view: any Hashable) func pop()