-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Infra] App Coordinator 생성, RootView 설정
- Loading branch information
1 parent
3e084b7
commit 793e329
Showing
3 changed files
with
82 additions
and
0 deletions.
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 |
---|---|---|
@@ -1,11 +1,49 @@ | ||
import SwiftUI | ||
import DesignCore | ||
import DesignPreview | ||
import CoreKit | ||
import Main | ||
|
||
@main | ||
struct ThreeDaysApp: App { | ||
let coordinator = AppCoordinator.shared | ||
|
||
var body: some Scene { | ||
WindowGroup { | ||
ZStack(alignment: .bottomLeading) { | ||
rootView | ||
#if DEBUG | ||
debugMenuPicker | ||
.padding(.leading, 16) | ||
.padding(.bottom, 16) | ||
#endif | ||
} | ||
} | ||
} | ||
|
||
@ViewBuilder | ||
var rootView: some View { | ||
switch coordinator.rootView { | ||
case .designPreview: | ||
DesignPreviewView() | ||
case .main: | ||
MainView() | ||
} | ||
} | ||
|
||
#if DEBUG | ||
@ViewBuilder | ||
var debugMenuPicker: some View { | ||
Menu("🚀 개발모드") { | ||
ForEach(FeatureType.allCases, id: \.self) { feature in | ||
Button(feature.name) { | ||
coordinator.changeRootView(feature) | ||
} | ||
} | ||
} | ||
.buttonStyle(BorderedProminentButtonStyle()) | ||
.typography(.semibold_14) | ||
.tint(DesignCore.grey300) | ||
} | ||
#endif | ||
} |
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,23 @@ | ||
// | ||
// AppCoordinator.swift | ||
// CoreKit | ||
// | ||
// Created by 김지수 on 9/18/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
@Observable public final class AppCoordinator { | ||
//MARK: - Lifecycle | ||
public static var shared = AppCoordinator() | ||
private init() {} | ||
|
||
//MARK: - Properties | ||
public private(set) var rootView = FeatureType.designPreview | ||
|
||
//MARK: - Methods | ||
public func changeRootView(_ feature: FeatureType) { | ||
rootView = feature | ||
} | ||
} |
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,21 @@ | ||
// | ||
// FeatureTypes.swift | ||
// CoreKit | ||
// | ||
// Created by 김지수 on 9/18/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum FeatureType: CaseIterable { | ||
case designPreview | ||
case main | ||
|
||
public var name: String { | ||
switch self { | ||
case .designPreview: return "Design Preview" | ||
case .main: return "메인" | ||
} | ||
} | ||
} |