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() } } }