Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions Application/DevLogPresentation/Sources/Main/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ struct MainView: View {
@State private var todayViewCoordinator: TodayViewCoordinator
@State private var pushNotificationListViewCoordinator: PushNotificationListViewCoordinator
@State private var profileViewCoordinator: ProfileViewCoordinator
@Binding var selectedTab: MainTab?
@Binding var selectedTab: MainTab
private let windowEvent: TodoEditorWindowEvent

init(
container: DIContainer,
windowEvent: TodoEditorWindowEvent,
selectedTab: Binding<MainTab?>
selectedTab: Binding<MainTab>
) {
self._coordinator = State(initialValue: MainViewCoordinator(container: container))
self._todoWindowCoordinator = State(initialValue: TodoWindowCoordinator(container: container))
Expand All @@ -39,12 +39,10 @@ struct MainView: View {

var body: some View {
Group {
if let selectedTab {
if isCompactLayout {
tabView
} else {
sidebarView(for: selectedTab)
}
if isCompactLayout {
tabView
} else {
sidebarView(for: selectedTab)
}
}
.onAppear {
Expand All @@ -53,7 +51,6 @@ struct MainView: View {
todoWindowCoordinator.bindWindowEvent(windowEvent)
}
.onChange(of: selectedTab, initial: true) { _, newValue in
guard let newValue else { return }
coordinator.viewModel.send(.selectedTabChanged(newValue))
if newValue == .home {
homeViewCoordinator.fetchData()
Comment thread
opficdev marked this conversation as resolved.
Expand Down Expand Up @@ -81,26 +78,26 @@ struct MainView: View {
.tabItem {
tabLabel(.home)
}
.tag(MainTab.home as MainTab?)
.tag(MainTab.home)

todayView
.tabItem {
tabLabel(.today)
}
.tag(MainTab.today as MainTab?)
.tag(MainTab.today)

notificationView
.tabItem {
tabLabel(.notification)
}
.badge(coordinator.viewModel.state.unreadPushCount)
.tag(MainTab.notification as MainTab?)
.tag(MainTab.notification)

profileView
.tabItem {
tabLabel(.profile)
}
.tag(MainTab.profile as MainTab?)
.tag(MainTab.profile)
}
}

Expand Down
4 changes: 1 addition & 3 deletions Application/DevLogPresentation/Sources/Root/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct RootView: View {
@Environment(\.diContainer) var container: DIContainer
@State var viewModel: RootViewModel
@State private var selectedRoute: Route?
@State private var selectedMainTab: MainTab?
@State private var selectedMainTab = MainTab.home
private let widgetURLTab: (URL) -> MainTab?
private let windowEvent: TodoEditorWindowEvent
private let pushNotificationTodoIdPublisher: AnyPublisher<String, Never>
Expand Down Expand Up @@ -65,8 +65,6 @@ public struct RootView: View {
guard let value else { return }
if value {
selectedMainTab = .home
} else {
selectedMainTab = nil
}
}
.onOpenURL { url in
Expand Down