-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat [#104] 코디네이터 구현 #110
Open
Zoe0929
wants to merge
15
commits into
develop
Choose a base branch
from
feat/#104
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat [#104] 코디네이터 구현 #110
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b33adb0
[Feat/#104] DSKit에서 Lottie 사용을 위한 스텐실파일 추가
Zoe0929 7c3c74a
[Feat/#104] App State 이동
Zoe0929 37b0c4a
[Feat/#104] 코디네이터 적용으로 ContentView AppView로 변경
Zoe0929 28fc60f
[Feat/#104] 최상위 Coordinator
Zoe0929 866653f
[Fix/#104] 불필요한 뷰모델 주입 제거 및 코디네이터
Zoe0929 9fdebbd
[Feat/#104] Feature별 코디네이터 제작
Zoe0929 b3ce651
[Delete/#104] 불필요한 파일 삭제
Zoe0929 02c6a58
[Chore/#104] 파일경로 변경
Zoe0929 0b7bfc3
[Fix/#104] 코디네이터 구조 변경
Zoe0929 2b2ea22
[Feat/#104] Feature DIContainer 구현
Zoe0929 027a2e0
[Feat/#104] AppDIContainer
Zoe0929 ed986c4
[Feat/#104] AppDIContainer 주입
Zoe0929 e3177d2
[Fix/#104] 빌드 오류 해결
Zoe0929 fc23a08
[Chore/#104] Domain에 DSKit 의존성 추가
Zoe0929 3063dad
[Chore/#104] Coordinator Type 변경
Zoe0929 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// 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 { | ||
@EnvironmentObject var appDIContainer: AppDIContainer | ||
@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) | ||
} | ||
} | ||
} | ||
} |
91 changes: 0 additions & 91 deletions
91
HMH_Tuist_iOS/Projects/App/Sources/Common/Custom/ContentView.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AppCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// 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(EmptyView()) | ||
@Published var appState: AppState = .login | ||
|
||
|
||
var navigationPath: NavigationPath = NavigationPath() | ||
private let diContainer: AppDIContainer | ||
|
||
init(diContainer: AppDIContainer) { | ||
self.diContainer = diContainer | ||
} | ||
|
||
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 authDIContainer = diContainer.injectAuthDIContainer() | ||
let authCoordinator = AuthCoordinator(navigationPath: navigationPath, diContainer: authDIContainer) | ||
currentView = authCoordinator.start() | ||
} | ||
|
||
func startTabBar() { | ||
let tabBarCoordinator = TabBarCoordinator(parentCoordinator: self, navigationPath: self.navigationPath) | ||
currentView = tabBarCoordinator.start() | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
HMH_Tuist_iOS/Projects/App/Sources/Coordinator/AuthCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// 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 navigationPath: NavigationPath | ||
private let diContainer: AuthDIContainer | ||
|
||
init( | ||
navigationPath: NavigationPath, | ||
diContainer: AuthDIContainer | ||
) { | ||
self.navigationPath = navigationPath | ||
self.diContainer = diContainer | ||
} | ||
|
||
func start() -> AnyView { | ||
let viewModel = diContainer.injectLoginViewModel() | ||
let view = LoginView(viewModel: viewModel) | ||
return AnyView(view) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
HMH_Tuist_iOS/Projects/App/Sources/Coordinator/BaseCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// BaseCoordinator.swift | ||
// Coordinator | ||
// | ||
// Created by 이지희 on 11/7/24. | ||
// Copyright © 2024 HMH-iOS. All rights reserved. | ||
// | ||
import SwiftUI | ||
import Combine | ||
|
||
import Core | ||
|
||
// MARK: - BaseCoordinator | ||
|
||
/// NavigationStack을 사용할 경우 이전에 대한 정보를 모두 갖고 있기 때문에 부모 - 자식 코디네이터 불필요 | ||
public protocol CoordinatorType: AnyObject { | ||
associatedtype View: SwiftUI.View | ||
|
||
var navigationPath: NavigationPath { get set } | ||
|
||
func start() -> View | ||
|
||
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) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
HMH_Tuist_iOS/Projects/App/Sources/Coordinator/OnboardingCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
HMH_Tuist_iOS/Projects/App/Sources/Coordinator/TabBarCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
HMH_Tuist_iOS/Projects/App/Sources/DIContainer/AppDIContainer.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분의 토큰 절차를 어디서 처리할지 애매하네요..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아니면 스플래시에서 별도의 체킹 없이
토큰 인터셉터에서 리프레쉬 만료 관련 에러가 뜨면 로그인으로 가게 하면 될까요.?