Skip to content

Commit

Permalink
[Infra] App Coordinator 생성, RootView 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
jisu15-kim committed Sep 18, 2024
1 parent 3e084b7 commit 793e329
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Projects/App/Sources/ThreeDaysApp.swift
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
}
23 changes: 23 additions & 0 deletions Projects/Core/CoreKit/Sources/AppCoordinator.swift
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
}
}
21 changes: 21 additions & 0 deletions Projects/Core/CoreKit/Sources/FeatureTypes.swift
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 "메인"
}
}
}

0 comments on commit 793e329

Please sign in to comment.