diff --git a/Modules/Sources/AppFeature/AppView.swift b/Modules/Sources/AppFeature/AppView.swift index 593f663..7dbf80f 100644 --- a/Modules/Sources/AppFeature/AppView.swift +++ b/Modules/Sources/AppFeature/AppView.swift @@ -138,67 +138,25 @@ struct LiquidTabView: View { } .tabBarMinimizeBehavior(store.appSettings.hideTabBarOnScroll ? .onScrollDown : .never) .if(store.appSettings.experimentalFloatingNavigation) { content in - content - .tabViewBottomAccessory { - BottomAccessory() - } - } - } - } - - @ViewBuilder - private func BottomAccessory() -> some View { - switch store.selectedTab { - case .articles: - Page(for: store.scope(state: \.articlesTab, action: \.articlesTab)) - case .favorites: - Page(for: store.scope(state: \.favoritesTab, action: \.favoritesTab)) - case .forum: - Page(for: store.scope(state: \.forumTab, action: \.forumTab)) - case .profile: - switch store.scope(state: \.profileFlow, action: \.profileFlow).case { - case let .loggedIn(store), let .loggedOut(store): - Page(for: store) - } - } - } - - @ViewBuilder - private func Page(for tab: Store) -> some View { - if tab.path.isEmpty { - _Page(for: tab.scope(state: \.root, action: \.root)) - } else if let id = tab.path.ids.last { - if let path = tab.scope(state: \.path[id: id], action: \.path[id: id]) { - _Page(for: path) + if #available(iOS 26.1, *) { + let isEnabled = getNavigation()?.state.count ?? 0 > 1 + content + .tabViewBottomAccessory(isEnabled: isEnabled) { + if let navigationStore = getNavigation() { + PageNavigation(store: navigationStore) + } + } + } else { + content + .tabViewBottomAccessory { + if let navigationStore = getNavigation() { + PageNavigation(store: navigationStore) + } + } + } } } } - - @ViewBuilder - private func _Page(for store: Store) -> some View { - switch store.case { - case let .favorites(store): - PageNavigation(store: store.scope(state: \.favorites.pageNavigation, action: \.favorites.pageNavigation)) - case let .forum(path): - switch path.case { - case let .forum(store): - PageNavigation(store: store.scope(state: \.pageNavigation, action: \.pageNavigation)) - case let .topic(store): - PageNavigation(store: store.scope(state: \.pageNavigation, action: \.pageNavigation)) - default: - EmptyView() - } - case let .profile(path): - switch path.case { - case let .history(store): - PageNavigation(store: store.scope(state: \.pageNavigation, action: \.pageNavigation)) - default: - EmptyView() - } - default: - EmptyView() - } - } } // MARK: - Old Tab View @@ -406,3 +364,64 @@ extension AppTintColor { } ) } + +@available(iOS 26.0, *) +extension LiquidTabView { + private func getNavigation() -> Store? { + switch store.selectedTab { + case .articles: + return getPage(for: store.scope(state: \.articlesTab, action: \.articlesTab)) + case .favorites: + return getPage(for: store.scope(state: \.favoritesTab, action: \.favoritesTab)) + case .forum: + return getPage(for: store.scope(state: \.forumTab, action: \.forumTab)) + case .profile: + switch store.scope(state: \.profileFlow, action: \.profileFlow).case { + case let .loggedIn(store), let .loggedOut(store): + return getPage(for: store) + } + } + } + + private func getPage( + for tab: Store + ) -> Store? { + if tab.path.isEmpty { + return getFeature(for: tab.scope(state: \.root, action: \.root)) + } else if let id = tab.path.ids.last, let path = tab.scope(state: \.path[id: id], action: \.path[id: id]) { + return getFeature(for: path) + } else { + return nil + } + } + + private func getFeature( + for store: Store + ) -> Store? { + switch store.case { + case let .favorites(store): + return store.scope(state: \.favorites.pageNavigation, action: \.favorites.pageNavigation) + + case let .forum(path): + switch path.case { + case let .forum(store): + return store.scope(state: \.pageNavigation, action: \.pageNavigation) + case let .topic(store): + return store.scope(state: \.pageNavigation, action: \.pageNavigation) + default: + return nil + } + + case let .profile(path): + switch path.case { + case let .history(store): + return store.scope(state: \.pageNavigation, action: \.pageNavigation) + default: + return nil + } + + default: + return nil + } + } +} diff --git a/Modules/Sources/SharedUI/If.swift b/Modules/Sources/SharedUI/If.swift index aff3ae5..6de212f 100644 --- a/Modules/Sources/SharedUI/If.swift +++ b/Modules/Sources/SharedUI/If.swift @@ -9,7 +9,7 @@ import SwiftUI public extension View { @ViewBuilder - func `if`(_ condition: Bool, transform: (Self) -> Content) -> some View { + func `if`(_ condition: Bool, @ViewBuilder transform: (Self) -> Content) -> some View { if condition { transform(self) } else {