Skip to content
Draft
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
135 changes: 77 additions & 58 deletions Modules/Sources/AppFeature/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<StackTab.State, StackTab.Action>) -> 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<Path.State, Path.Action>) -> 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
Expand Down Expand Up @@ -406,3 +364,64 @@ extension AppTintColor {
}
)
}

@available(iOS 26.0, *)
extension LiquidTabView {
private func getNavigation() -> Store<PageNavigationFeature.State, PageNavigationFeature.Action>? {
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<StackTab.State, StackTab.Action>
) -> Store<PageNavigationFeature.State, PageNavigationFeature.Action>? {
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<Path.State, Path.Action>
) -> Store<PageNavigationFeature.State, PageNavigationFeature.Action>? {
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
}
}
}
2 changes: 1 addition & 1 deletion Modules/Sources/SharedUI/If.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

public extension View {
@ViewBuilder
func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
func `if`<Content: View>(_ condition: Bool, @ViewBuilder transform: (Self) -> Content) -> some View {
if condition {
transform(self)
} else {
Expand Down
Loading