Skip to content

Commit fddd14a

Browse files
committed
refactor: store을 Bindable 처리
1 parent 40c9196 commit fddd14a

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

Application/DevLogPresentation/Sources/Main/MainView.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct MainView: View {
1818
@State private var todayViewCoordinator: TodayViewCoordinator
1919
@State private var pushNotificationListViewCoordinator: PushNotificationListViewCoordinator
2020
@State private var profileViewCoordinator: ProfileViewCoordinator
21+
@Bindable var store: StoreOf<MainFeature>
2122
@Binding var selectedTab: MainTab
2223
private let windowEvent: TodoEditorWindowEvent
2324

@@ -26,21 +27,21 @@ struct MainView: View {
2627
windowEvent: TodoEditorWindowEvent,
2728
selectedTab: Binding<MainTab>
2829
) {
29-
self._coordinator = State(initialValue: MainViewCoordinator(container: container))
30+
let coordinator = MainViewCoordinator(container: container)
31+
self._coordinator = State(initialValue: coordinator)
3032
self._todoWindowCoordinator = State(initialValue: TodoWindowCoordinator(container: container))
3133
self._homeViewCoordinator = State(initialValue: HomeViewCoordinator(container: container))
3234
self._todayViewCoordinator = State(initialValue: TodayViewCoordinator(container: container))
3335
self._pushNotificationListViewCoordinator = State(
3436
initialValue: PushNotificationListViewCoordinator(container: container)
3537
)
3638
self._profileViewCoordinator = State(initialValue: ProfileViewCoordinator(container: container))
39+
self.store = coordinator.store
3740
self.windowEvent = windowEvent
3841
self._selectedTab = selectedTab
3942
}
4043

4144
var body: some View {
42-
@Bindable var store = coordinator.store
43-
4445
Group {
4546
if isCompactLayout {
4647
tabView
@@ -49,13 +50,13 @@ struct MainView: View {
4950
}
5051
}
5152
.onAppear {
52-
coordinator.store.send(.view(.onAppear))
53+
store.send(.view(.onAppear))
5354
homeViewCoordinator.bindWindowEvent(windowEvent)
5455
homeViewCoordinator.bindTodoMutationEvent()
5556
todoWindowCoordinator.bindWindowEvent(windowEvent)
5657
}
5758
.onChange(of: selectedTab, initial: true) { _, newValue in
58-
coordinator.store.send(.view(.selectedTabChanged(newValue)))
59+
store.send(.view(.selectedTabChanged(newValue)))
5960
if newValue == .home {
6061
homeViewCoordinator.fetchData()
6162
} else if newValue == .today {
@@ -88,7 +89,7 @@ struct MainView: View {
8889
.tabItem {
8990
tabLabel(.notification)
9091
}
91-
.badge(coordinator.store.unreadPushCount)
92+
.badge(store.unreadPushCount)
9293
.tag(MainTab.notification)
9394

9495
profileView
@@ -159,7 +160,7 @@ struct MainView: View {
159160
private func sidebarRow(_ tab: MainTab) -> some View {
160161
if tab == .notification {
161162
tabLabel(tab)
162-
.badge(coordinator.store.unreadPushCount)
163+
.badge(store.unreadPushCount)
163164
.tag(tab)
164165
} else {
165166
tabLabel(tab)

0 commit comments

Comments
 (0)