Skip to content

Commit 5d5b96b

Browse files
committed
Fix tabViewBottomAccessory not hiding on iOS 26.1+
1 parent 5bb6252 commit 5d5b96b

File tree

2 files changed

+78
-59
lines changed

2 files changed

+78
-59
lines changed

Modules/Sources/AppFeature/AppView.swift

Lines changed: 77 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -138,67 +138,25 @@ struct LiquidTabView: View {
138138
}
139139
.tabBarMinimizeBehavior(store.appSettings.hideTabBarOnScroll ? .onScrollDown : .never)
140140
.if(store.appSettings.experimentalFloatingNavigation) { content in
141-
content
142-
.tabViewBottomAccessory {
143-
BottomAccessory()
144-
}
145-
}
146-
}
147-
}
148-
149-
@ViewBuilder
150-
private func BottomAccessory() -> some View {
151-
switch store.selectedTab {
152-
case .articles:
153-
Page(for: store.scope(state: \.articlesTab, action: \.articlesTab))
154-
case .favorites:
155-
Page(for: store.scope(state: \.favoritesTab, action: \.favoritesTab))
156-
case .forum:
157-
Page(for: store.scope(state: \.forumTab, action: \.forumTab))
158-
case .profile:
159-
switch store.scope(state: \.profileFlow, action: \.profileFlow).case {
160-
case let .loggedIn(store), let .loggedOut(store):
161-
Page(for: store)
162-
}
163-
}
164-
}
165-
166-
@ViewBuilder
167-
private func Page(for tab: Store<StackTab.State, StackTab.Action>) -> some View {
168-
if tab.path.isEmpty {
169-
_Page(for: tab.scope(state: \.root, action: \.root))
170-
} else if let id = tab.path.ids.last {
171-
if let path = tab.scope(state: \.path[id: id], action: \.path[id: id]) {
172-
_Page(for: path)
141+
if #available(iOS 26.1, *) {
142+
let isEnabled = getNavigation()?.state.count ?? 0 > 1
143+
content
144+
.tabViewBottomAccessory(isEnabled: isEnabled) {
145+
if let navigationStore = getNavigation() {
146+
PageNavigation(store: navigationStore)
147+
}
148+
}
149+
} else {
150+
content
151+
.tabViewBottomAccessory {
152+
if let navigationStore = getNavigation() {
153+
PageNavigation(store: navigationStore)
154+
}
155+
}
156+
}
173157
}
174158
}
175159
}
176-
177-
@ViewBuilder
178-
private func _Page(for store: Store<Path.State, Path.Action>) -> some View {
179-
switch store.case {
180-
case let .favorites(store):
181-
PageNavigation(store: store.scope(state: \.favorites.pageNavigation, action: \.favorites.pageNavigation))
182-
case let .forum(path):
183-
switch path.case {
184-
case let .forum(store):
185-
PageNavigation(store: store.scope(state: \.pageNavigation, action: \.pageNavigation))
186-
case let .topic(store):
187-
PageNavigation(store: store.scope(state: \.pageNavigation, action: \.pageNavigation))
188-
default:
189-
EmptyView()
190-
}
191-
case let .profile(path):
192-
switch path.case {
193-
case let .history(store):
194-
PageNavigation(store: store.scope(state: \.pageNavigation, action: \.pageNavigation))
195-
default:
196-
EmptyView()
197-
}
198-
default:
199-
EmptyView()
200-
}
201-
}
202160
}
203161

204162
// MARK: - Old Tab View
@@ -406,3 +364,64 @@ extension AppTintColor {
406364
}
407365
)
408366
}
367+
368+
@available(iOS 26.0, *)
369+
extension LiquidTabView {
370+
private func getNavigation() -> Store<PageNavigationFeature.State, PageNavigationFeature.Action>? {
371+
switch store.selectedTab {
372+
case .articles:
373+
return getPage(for: store.scope(state: \.articlesTab, action: \.articlesTab))
374+
case .favorites:
375+
return getPage(for: store.scope(state: \.favoritesTab, action: \.favoritesTab))
376+
case .forum:
377+
return getPage(for: store.scope(state: \.forumTab, action: \.forumTab))
378+
case .profile:
379+
switch store.scope(state: \.profileFlow, action: \.profileFlow).case {
380+
case let .loggedIn(store), let .loggedOut(store):
381+
return getPage(for: store)
382+
}
383+
}
384+
}
385+
386+
private func getPage(
387+
for tab: Store<StackTab.State, StackTab.Action>
388+
) -> Store<PageNavigationFeature.State, PageNavigationFeature.Action>? {
389+
if tab.path.isEmpty {
390+
return getFeature(for: tab.scope(state: \.root, action: \.root))
391+
} else if let id = tab.path.ids.last, let path = tab.scope(state: \.path[id: id], action: \.path[id: id]) {
392+
return getFeature(for: path)
393+
} else {
394+
return nil
395+
}
396+
}
397+
398+
private func getFeature(
399+
for store: Store<Path.State, Path.Action>
400+
) -> Store<PageNavigationFeature.State, PageNavigationFeature.Action>? {
401+
switch store.case {
402+
case let .favorites(store):
403+
return store.scope(state: \.favorites.pageNavigation, action: \.favorites.pageNavigation)
404+
405+
case let .forum(path):
406+
switch path.case {
407+
case let .forum(store):
408+
return store.scope(state: \.pageNavigation, action: \.pageNavigation)
409+
case let .topic(store):
410+
return store.scope(state: \.pageNavigation, action: \.pageNavigation)
411+
default:
412+
return nil
413+
}
414+
415+
case let .profile(path):
416+
switch path.case {
417+
case let .history(store):
418+
return store.scope(state: \.pageNavigation, action: \.pageNavigation)
419+
default:
420+
return nil
421+
}
422+
423+
default:
424+
return nil
425+
}
426+
}
427+
}

Modules/Sources/SharedUI/If.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SwiftUI
99

1010
public extension View {
1111
@ViewBuilder
12-
func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
12+
func `if`<Content: View>(_ condition: Bool, @ViewBuilder transform: (Self) -> Content) -> some View {
1313
if condition {
1414
transform(self)
1515
} else {

0 commit comments

Comments
 (0)