Skip to content

Commit

Permalink
#37 [Style/Feat] TabBarRouteView 구조 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
soletree committed Apr 24, 2024
1 parent 07043fe commit 64259cb
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions Score/Score/View/TabRouteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,48 @@ import SwiftUI

struct TabRouteView: View {
let store: StoreOf<SCTabBarFeature>
@ObservedObject var viewStore: ViewStoreOf<SCTabBarFeature>

init(store: StoreOf<SCTabBarFeature>) {
self.store = store
self.viewStore = ViewStore(store,
observe: { $0 })
}

var body: some View {
NavigationStackStore(
store.scope(state: \.path,
action: \.path)
) {
WithPerceptionTracking {
Text("Root View")
.onAppear {
store.send(.viewAppearing)
}
.fullScreenCover(
store: store.scope(
state: \.$destination.record,
action: \.destination.record)
) { store in
RecordMainView(store: store)
}
}
} destination: { store in
switch store.state {
case .home:
if let store = store.scope(state: \.home,
action: \.home) {
HomeMainView(store: store)
.scTabBar(store: self.store)
}
case .schoolGroup:
if let store = store.scope(state: \.schoolGroup,
action: \.schoolGroup) {
SchoolGroupMainView(store: store)
.scTabBar(store: self.store)
}
}
TabView(selection: viewStore.$selectedTab) {
HomeMainView(store: store.scope(state: \.home,
action: \.home))
.tag(SCTabItem.home)

SchoolGroupMainView(
store: self.store.scope(
state: \.schoolGroup,
action: \.schoolGroup)
)

.tag(SCTabItem.schoolGroup)
}
.scTabBar(store: store)
.onAppear {
store.send(.viewAppearing)
}
.fullScreenCover(
store: store.scope(
state: \.$destination.record,
action: \.destination.record)
) { store in
RecordMainView(store: store)
}
}
}

//MARK: - Preview

#Preview {
TabRouteView(
store: .init(initialState: .init(selectedTab: .home),
reducer: { SCTabBarFeature() }))
NavigationStack {
TabRouteView(
store: .init(initialState: .init(selectedTab: .home),
reducer: { SCTabBarFeature() }))
}
}

0 comments on commit 64259cb

Please sign in to comment.