feat: open sidenav with left

This commit is contained in:
edde746
2026-01-25 01:43:10 +01:00
parent 0fc2708a51
commit 9d37443e4e
18 changed files with 397 additions and 145 deletions
+10 -2
View File
@@ -47,6 +47,10 @@ class HubSection extends StatefulWidget {
/// Used to navigate focus to the tab bar.
final VoidCallback? onNavigateUp;
/// Called when the user presses LEFT while at the leftmost item (index 0).
/// Used to navigate focus to the sidebar.
final VoidCallback? onNavigateToSidebar;
const HubSection({
super.key,
required this.hub,
@@ -58,6 +62,7 @@ class HubSection extends StatefulWidget {
this.onVerticalNavigation,
this.onBack,
this.onNavigateUp,
this.onNavigateToSidebar,
});
@override
@@ -225,15 +230,18 @@ class HubSectionState extends State<HubSection> {
final itemCount = widget.hub.items.length;
if (itemCount == 0) return KeyEventResult.ignored;
// Left: move to previous item, ALWAYS consume to prevent escape
// Left: move to previous item, or navigate to sidebar at left edge
if (key.isLeftKey) {
if (_focusedIndex > 0) {
_focusedIndex--;
HubFocusMemory.setForHub(widget.hub.hubKey, _focusedIndex);
_scrollToIndex(_focusedIndex);
setState(() {});
} else if (widget.onNavigateToSidebar != null) {
// At leftmost item: navigate to sidebar
widget.onNavigateToSidebar!();
}
// At leftmost item: do nothing, but consume event to prevent focus escape
// Always consume to prevent focus escape
return KeyEventResult.handled;
}