Keep the video info carousel aligned across window resizes

The carousel's lazy stack kept the old widths of cards it had laid out
off-screen, so after a resize (tab bar to split view sidebar on iPad,
rotation) every later card sat at a stale offset and the current card
landed beside the viewport. The stack now takes a new identity per
card width, and the existing re-snap aligns the current card.

Swapping between the tab bar and the sidebar also rebuilds the page,
which reset the carousel to the video it was opened on. The page's
position and continuation-loaded videos now live on its queue context,
fresh for every push, so a rebuilt page resumes where it was.
This commit is contained in:
Arkadiusz Fal
2026-10-14 08:22:58 +02:00
parent 97288b4497
commit fd6a97ce5c
3 changed files with 33 additions and 2 deletions

View File

@@ -67,6 +67,13 @@ final class NavigationRouter {
/// Pushes a destination onto the selected section's stack.
func push(_ destination: NavigationDestination) {
var destination = destination
// A row hands out the same context on every tap until it re-renders,
// so a page pushed again must not inherit the earlier page's position.
if case .video(let source, var queueContext?) = destination {
queueContext.pageState = VideoInfoPageState()
destination = .video(source, queueContext: queueContext)
}
stacks[selection.id, default: []].append(destination)
}