-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/#140 챌린지 탭 분기처리 #145
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
Fix/#140 챌린지 탭 분기처리 #145
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,30 +10,36 @@ import SwiftUI | |
| struct ChallengeCoordinatorView: View { | ||
| @EnvironmentObject private var challengeCoordinator: ChallengeCoordinator | ||
| @EnvironmentObject private var tabBarCoordinator: TabBarCoordinator | ||
| private let userDefaultService: UserDefaultService = DefaultUserDefaultService() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial 🧩 Analysis chain🏁 Script executed: rg -n "UserDefaultService" --type swift -C2Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 10776 🏁 Script executed: cat -n Cherrish-iOS/Cherrish-iOS/Presentation/Feature/ChallengeView/Coordinator/ChallengeCoordinatorView.swiftRepository: TEAM-Cherrish/Cherrish-iOS Length of output: 2055 🏁 Script executed: cat -n Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Onboarding/SplashView.swift | head -20Repository: TEAM-Cherrish/Cherrish-iOS Length of output: 669 의존성 주입 패턴 일관성 개선 필요
다음과 같이 개선하면 테스트 시 mock 서비스 주입이 가능해지고 일관성이 향상됩니다: 🤖 Prompt for AI Agents |
||
|
|
||
| var body: some View { | ||
| NavigationStack(path: $challengeCoordinator.path) { | ||
| ViewFactory.shared.makeStartChallengeView() | ||
| .navigationDestination(for: ChallengeRoute.self) { route in | ||
| Group { | ||
| switch route { | ||
| case .root: | ||
| ViewFactory.shared.makeHomeView() | ||
| case .startChallenge: | ||
| ViewFactory.shared.makeStartChallengeView() | ||
| case .createChallenge: | ||
| ViewFactory.shared.makeCreateChallengeView() | ||
| .onAppear { | ||
| tabBarCoordinator.isTabbarHidden = true | ||
| } | ||
| case .challengeProgress: | ||
| ViewFactory.shared.makeChallengeProgressView() | ||
| .onAppear() { | ||
| tabBarCoordinator.isTabbarHidden = false | ||
| } | ||
| } | ||
| Group { | ||
| if let hasProgress: Bool = userDefaultService.load(key: .hasProgressChallenge), hasProgress { | ||
| ViewFactory.shared.makeChallengeProgressView() | ||
| } else { | ||
| ViewFactory.shared.makeStartChallengeView() | ||
| } | ||
| } | ||
| .navigationDestination(for: ChallengeRoute.self) { route in | ||
| Group { | ||
| switch route { | ||
| case .startChallenge: | ||
| ViewFactory.shared.makeStartChallengeView() | ||
| case .createChallenge: | ||
| ViewFactory.shared.makeCreateChallengeView() | ||
| .onAppear { | ||
| tabBarCoordinator.isTabbarHidden = true | ||
| } | ||
| case .challengeProgress: | ||
| ViewFactory.shared.makeChallengeProgressView() | ||
| .onAppear() { | ||
| tabBarCoordinator.isTabbarHidden = false | ||
| } | ||
| } | ||
| .navigationBarBackButtonHidden() | ||
| } | ||
| .navigationBarBackButtonHidden() | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
Force cast 사용으로 인한 런타임 크래시 위험
error as! CherrishError는 error가CherrishError타입이 아닐 경우 앱이 크래시됩니다. 네트워크 에러, 디코딩 에러 등 다른 타입의 에러가 발생할 수 있으므로 안전한 캐스팅을 사용해야 합니다.🐛 안전한 캐스팅으로 수정
} catch { - if error as! CherrishError == CherrishError.conflict { + if let cherrishError = error as? CherrishError, cherrishError == .conflict { let _ = userDefaultService.save(false, key: .hasProgressChallenge) } throw error }📝 Committable suggestion
🧰 Tools
🪛 SwiftLint (0.57.0)
[Error] 43-43: Force casts should be avoided
(force_cast)
🤖 Prompt for AI Agents