Skip to content

Commit

Permalink
[design] #154 RootView에 MainSplit 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ShapeKim98 committed Oct 25, 2024
1 parent fbdbf37 commit fba9734
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Projects/App/Sources/Root/RootFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() }
}
Expand All @@ -32,6 +34,7 @@ public struct RootFeature {
case _sceneChange(State)
case intro(IntroFeature.Action)
case mainTab(MainTabFeature.Action)
case mainTabSplit(MainTabSplitFeature.Action)
}

public init() {}
Expand All @@ -43,23 +46,24 @@ 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)
let user = try await userClient.fcm_토큰_저장(fcmRequest)

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
}
}
Expand All @@ -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()
}
}
4 changes: 4 additions & 0 deletions Projects/App/Sources/Root/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit fba9734

Please sign in to comment.