From fba9734b01c195be3fa4161504ad20f11b1b1316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=84=ED=98=95?= <108233361+ShapeKim98@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:34:05 +0900 Subject: [PATCH] =?UTF-8?q?[design]=20#154=20RootView=EC=97=90=20MainSplit?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/App/Sources/Root/RootFeature.swift | 13 +++++++++---- Projects/App/Sources/Root/RootView.swift | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Projects/App/Sources/Root/RootFeature.swift b/Projects/App/Sources/Root/RootFeature.swift index a31a69de..a1e7b2e4 100644 --- a/Projects/App/Sources/Root/RootFeature.swift +++ b/Projects/App/Sources/Root/RootFeature.swift @@ -5,11 +5,12 @@ // Created by 김민호 on 7/4/24. // -import Foundation +import SwiftUI import ComposableArchitecture import FeatureLogin import CoreKit +import Util @Reducer public struct RootFeature { @@ -24,6 +25,7 @@ public struct RootFeature { public enum State { case intro(IntroFeature.State = .init()) case mainTab(MainTabFeature.State = .init()) + case mainTabSplit(MainTabSplitFeature.State = .init()) public init() { self = .intro() } } @@ -32,6 +34,7 @@ public struct RootFeature { case _sceneChange(State) case intro(IntroFeature.Action) case mainTab(MainTabFeature.Action) + case mainTabSplit(MainTabSplitFeature.Action) } public init() {} @@ -43,8 +46,9 @@ public struct RootFeature { return .none case .intro(.delegate(.moveToTab)): return .run { send in + guard let fcmToken = userDefaults.stringKey(.fcmToken) else { - await send(._sceneChange(.mainTab())) + await send(._sceneChange(UIDevice.isPhone ? .mainTab() : .mainTabSplit())) return } let fcmRequest = FCMRequest(token: fcmToken) @@ -52,14 +56,14 @@ public struct RootFeature { await userDefaults.setString(user.token, .fcmToken) await userDefaults.setString("\(user.userId)", .userId) - await send(._sceneChange(.mainTab())) + await send(._sceneChange(UIDevice.isPhone ? .mainTab() : .mainTabSplit())) } case .mainTab(.delegate(.로그아웃)), .mainTab(.delegate(.회원탈퇴)): return .run { send in await send(._sceneChange(.intro(.login()))) } - case .intro, .mainTab: + case .intro, .mainTab, .mainTabSplit: return .none } } @@ -68,6 +72,7 @@ public struct RootFeature { Reduce(self.core) .ifCaseLet(\.intro, action: \.intro) { IntroFeature() } .ifCaseLet(\.mainTab, action: \.mainTab) { MainTabFeature() } + .ifCaseLet(\.mainTabSplit, action: \.mainTabSplit) { MainTabSplitFeature() } ._printChanges() } } diff --git a/Projects/App/Sources/Root/RootView.swift b/Projects/App/Sources/Root/RootView.swift index 748e5057..b446632a 100644 --- a/Projects/App/Sources/Root/RootView.swift +++ b/Projects/App/Sources/Root/RootView.swift @@ -33,6 +33,10 @@ extension RootView { if let store = store.scope(state: \.mainTab, action: \.mainTab) { MainTabView(store: store) } + case .mainTabSplit: + if let store = store.scope(state: \.mainTabSplit, action: \.mainTabSplit) { + MainTabSplitView(store: store) + } } } .background(.pokit(.bg(.base)))