feat: focus navigation for movie detail sections

close #464
This commit is contained in:
edde746
2026-02-16 02:17:10 +01:00
parent 53c94b14cc
commit 23c4c400f0
4 changed files with 657 additions and 474 deletions
+25
View File
@@ -0,0 +1,25 @@
import 'package:flutter/widgets.dart';
/// Scroll a horizontal list to center the item at the given index.
///
/// Assumes items are laid out with [leadingPadding] before the first item,
/// and each item occupies [itemExtent] pixels (including per-item padding).
void scrollListToIndex(
ScrollController controller,
int index, {
required double itemExtent,
double leadingPadding = 12.0,
bool animate = true,
}) {
if (!controller.hasClients || itemExtent <= 0) return;
final viewport = controller.position.viewportDimension;
final targetCenter = leadingPadding + (index * itemExtent) + (itemExtent / 2);
final desiredOffset = (targetCenter - (viewport / 2)).clamp(0.0, controller.position.maxScrollExtent);
if (animate) {
controller.animateTo(desiredOffset, duration: const Duration(milliseconds: 150), curve: Curves.easeOut);
} else {
controller.jumpTo(desiredOffset);
}
}