Fix horizontal content extending behind sidebar on iPad

Modified HorizontalCells to conditionally apply edgesIgnoringSafeArea based on navigation style. In sidebar mode (iPad), content now respects safe areas and won't overlap with the sidebar. In tab mode (iPhone), content maintains full-width scrolling behavior.
This commit is contained in:
Arkadiusz Fal
2025-11-15 12:04:01 +01:00
parent adf282d0e2
commit 1fc609057e

View File

@@ -5,6 +5,7 @@ struct HorizontalCells: View {
var items = [ContentItem]()
@Environment(\.loadMoreContentHandler) private var loadMoreContentHandler
@Environment(\.navigationStyle) private var navigationStyle
@Default(.channelOnThumbnail) private var channelOnThumbnail
@@ -33,7 +34,7 @@ struct HorizontalCells: View {
#endif
}
.frame(height: cellHeight)
.edgesIgnoringSafeArea(.horizontal)
.modifier(ConditionalEdgeIgnoringSafeArea(navigationStyle: navigationStyle))
.animation(nil, value: contentItems.count)
}
@@ -57,6 +58,18 @@ struct HorizontalCells: View {
}
}
struct ConditionalEdgeIgnoringSafeArea: ViewModifier {
let navigationStyle: NavigationStyle
func body(content: Content) -> some View {
if navigationStyle == .tab {
content.edgesIgnoringSafeArea(.horizontal)
} else {
content
}
}
}
struct HorizontalCells_Previews: PreviewProvider {
static var previews: some View {
HorizontalCells(items: ContentItem.array(of: Video.allFixtures))