Skip to content

Commit 35aa2e4

Browse files
authored
[#499] MainView의 selectedTab에서 옵셔널을 제거한다 (#524)
fix: MainView 탭 선택 옵셔널 제거
1 parent beadf3e commit 35aa2e4

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

Application/DevLogPresentation/Sources/Main/MainView.swift

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ struct MainView: View {
1717
@State private var todayViewCoordinator: TodayViewCoordinator
1818
@State private var pushNotificationListViewCoordinator: PushNotificationListViewCoordinator
1919
@State private var profileViewCoordinator: ProfileViewCoordinator
20-
@Binding var selectedTab: MainTab?
20+
@Binding var selectedTab: MainTab
2121
private let windowEvent: TodoEditorWindowEvent
2222

2323
init(
2424
container: DIContainer,
2525
windowEvent: TodoEditorWindowEvent,
26-
selectedTab: Binding<MainTab?>
26+
selectedTab: Binding<MainTab>
2727
) {
2828
self._coordinator = State(initialValue: MainViewCoordinator(container: container))
2929
self._todoWindowCoordinator = State(initialValue: TodoWindowCoordinator(container: container))
@@ -39,12 +39,10 @@ struct MainView: View {
3939

4040
var body: some View {
4141
Group {
42-
if let selectedTab {
43-
if isCompactLayout {
44-
tabView
45-
} else {
46-
sidebarView(for: selectedTab)
47-
}
42+
if isCompactLayout {
43+
tabView
44+
} else {
45+
sidebarView(for: selectedTab)
4846
}
4947
}
5048
.onAppear {
@@ -53,7 +51,6 @@ struct MainView: View {
5351
todoWindowCoordinator.bindWindowEvent(windowEvent)
5452
}
5553
.onChange(of: selectedTab, initial: true) { _, newValue in
56-
guard let newValue else { return }
5754
coordinator.viewModel.send(.selectedTabChanged(newValue))
5855
if newValue == .home {
5956
homeViewCoordinator.fetchData()
@@ -81,26 +78,26 @@ struct MainView: View {
8178
.tabItem {
8279
tabLabel(.home)
8380
}
84-
.tag(MainTab.home as MainTab?)
81+
.tag(MainTab.home)
8582

8683
todayView
8784
.tabItem {
8885
tabLabel(.today)
8986
}
90-
.tag(MainTab.today as MainTab?)
87+
.tag(MainTab.today)
9188

9289
notificationView
9390
.tabItem {
9491
tabLabel(.notification)
9592
}
9693
.badge(coordinator.viewModel.state.unreadPushCount)
97-
.tag(MainTab.notification as MainTab?)
94+
.tag(MainTab.notification)
9895

9996
profileView
10097
.tabItem {
10198
tabLabel(.profile)
10299
}
103-
.tag(MainTab.profile as MainTab?)
100+
.tag(MainTab.profile)
104101
}
105102
}
106103

Application/DevLogPresentation/Sources/Root/RootView.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct RootView: View {
1414
@Environment(\.diContainer) var container: DIContainer
1515
@State var viewModel: RootViewModel
1616
@State private var selectedRoute: Route?
17-
@State private var selectedMainTab: MainTab?
17+
@State private var selectedMainTab = MainTab.home
1818
private let widgetURLTab: (URL) -> MainTab?
1919
private let windowEvent: TodoEditorWindowEvent
2020
private let pushNotificationTodoIdPublisher: AnyPublisher<String, Never>
@@ -65,8 +65,6 @@ public struct RootView: View {
6565
guard let value else { return }
6666
if value {
6767
selectedMainTab = .home
68-
} else {
69-
selectedMainTab = nil
7068
}
7169
}
7270
.onOpenURL { url in

0 commit comments

Comments
 (0)