refactor(core): consolidate shared app foundations

This commit is contained in:
edde746
2026-07-12 17:31:12 +02:00
parent a481fc1000
commit 97f7508067
59 changed files with 1244 additions and 919 deletions
+33
View File
@@ -0,0 +1,33 @@
/// Routes vertical D-pad movement between ordered hub rows.
///
/// A valid target and the bottom boundary are consumed. The top boundary can
/// either invoke an explicit focus handoff or propagate to the row's
/// `onNavigateUp` callback.
bool navigateVerticalHubRows({
required int hubCount,
required int hubIndex,
required bool isUp,
required void Function(int targetIndex) requestFocus,
void Function()? onTopBoundary,
void Function()? onBottomBoundary,
bool propagateTopBoundary = false,
}) {
if (hubCount <= 0) return false;
final targetIndex = isUp ? hubIndex - 1 : hubIndex + 1;
if (targetIndex < 0) {
if (onTopBoundary != null) {
onTopBoundary();
return true;
}
return !propagateTopBoundary;
}
if (targetIndex >= hubCount) {
onBottomBoundary?.call();
return true;
}
requestFocus(targetIndex);
return true;
}