I'm working on vertical paging, using TabView. I put player code in TabView and rotate it to show vertical paging, but UI breaks.
- Vertical Pager
struct EpisodeVerticalPager: View {
let episodes: [Episode]
@Binding var selectedEpisode: Int
@Binding var currentPlayer: SimplePlayer?
@Binding var showControls: Bool
var body: some View {
GeometryReader { geo in
TabView(selection: $selectedEpisode) {
ForEach(episodes, id: \.id) { ep in
EpisodePage(
ep: ep,
currentPlayer: $currentPlayer,
showControls: $showControls
)
.tag(ep.id ?? 0)
.frame(width: geo.size.width, height: geo.size.height)
}
}
.tabViewStyle(.page(indexDisplayMode: .never))
.frame(width: geo.size.height, height: geo.size.width)
.rotationEffect(.degrees(90)) // rotate content back
.ignoresSafeArea()
}
}
}
struct EpisodePage: View {
let ep: Episode
@Binding var currentPlayer: SimplePlayer?
@Binding var showControls: Bool
var body: some View {
ZStack {
if let p = currentPlayer {
VerticalPlayerView(player: p, showControls: $showControls)
.rotationEffect(.degrees(-90))
} else {
Color.black
.ignoresSafeArea()
.overlay {
ProgressView()
.progressViewStyle(CircularProgressViewStyle(tint: .white))
}
}
}
}
}
- Image
