mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-15 10:15:58 -07:00
feat: Android TV support (#503)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
7ab8c015b9
commit
c299492d6d
168 changed files with 12019 additions and 3073 deletions
|
|
@ -64,25 +64,28 @@ class _NavigationBodyState extends ConsumerState<NavigationBody> {
|
|||
child: widget.child,
|
||||
);
|
||||
|
||||
return switch (AdaptiveLayout.layoutOf(context)) {
|
||||
ViewSize.phone => paddedChild(),
|
||||
ViewSize.tablet => hasOverlay
|
||||
? SideNavigationBar(
|
||||
currentIndex: widget.currentIndex,
|
||||
destinations: widget.destinations,
|
||||
currentLocation: widget.currentLocation,
|
||||
child: paddedChild(),
|
||||
scaffoldKey: widget.drawerKey,
|
||||
)
|
||||
: paddedChild(),
|
||||
ViewSize.desktop => SideNavigationBar(
|
||||
currentIndex: widget.currentIndex,
|
||||
destinations: widget.destinations,
|
||||
currentLocation: widget.currentLocation,
|
||||
child: paddedChild(),
|
||||
scaffoldKey: widget.drawerKey,
|
||||
)
|
||||
};
|
||||
return FocusTraversalGroup(
|
||||
policy: GlobalFallbackTraversalPolicy(fallbackNode: navBarNode),
|
||||
child: switch (AdaptiveLayout.layoutOf(context)) {
|
||||
ViewSize.phone => paddedChild(),
|
||||
ViewSize.tablet => hasOverlay
|
||||
? SideNavigationBar(
|
||||
currentIndex: widget.currentIndex,
|
||||
destinations: widget.destinations,
|
||||
currentLocation: widget.currentLocation,
|
||||
child: paddedChild(),
|
||||
scaffoldKey: widget.drawerKey,
|
||||
)
|
||||
: paddedChild(),
|
||||
ViewSize.desktop || ViewSize.television => SideNavigationBar(
|
||||
currentIndex: widget.currentIndex,
|
||||
destinations: widget.destinations,
|
||||
currentLocation: widget.currentLocation,
|
||||
child: paddedChild(),
|
||||
scaffoldKey: widget.drawerKey,
|
||||
)
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MediaQueryData semiNestedPadding(BuildContext context, bool hasOverlay) {
|
||||
|
|
@ -92,3 +95,28 @@ class _NavigationBodyState extends ConsumerState<NavigationBody> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
FocusNode? lastMainFocus;
|
||||
|
||||
class GlobalFallbackTraversalPolicy extends ReadingOrderTraversalPolicy {
|
||||
final FocusNode fallbackNode;
|
||||
|
||||
GlobalFallbackTraversalPolicy({required this.fallbackNode}) : super();
|
||||
|
||||
@override
|
||||
bool inDirection(FocusNode currentNode, TraversalDirection direction) {
|
||||
lastMainFocus = null;
|
||||
final handled = super.inDirection(currentNode, direction);
|
||||
if (!handled && direction == TraversalDirection.left) {
|
||||
lastMainFocus = currentNode;
|
||||
|
||||
if (fallbackNode.canRequestFocus && fallbackNode.context?.mounted == true) {
|
||||
final cb = FocusTraversalPolicy.defaultTraversalRequestFocusCallback;
|
||||
cb(fallbackNode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue