Return highlighting by focus; move focus to navbar by Down arrow
This commit is contained in:
parent
55c7d32c13
commit
ca8969eb28
|
@ -250,20 +250,27 @@ class _MainScreenState extends State<MainScreen> with SingleTickerProviderStateM
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case 127: // Menu on Android TV
|
case 127: // Menu on Android TV
|
||||||
case 327: // EPG on Hisense TV
|
case 327: // EPG on Hisense TV
|
||||||
navigatorFocusNode.requestFocus();
|
focusToNavbar(navigatorFocusNode);
|
||||||
navigatorFocusNode.focusInDirection(TraversalDirection.down);
|
|
||||||
break;
|
break;
|
||||||
case 22: // LEFT + RIGHT
|
case 22: // LEFT + RIGHT
|
||||||
case 21:
|
case 21:
|
||||||
if (_keyPressed == 21 && keyCode == 22 || _keyPressed == 22 && keyCode == 21) {
|
if (_keyPressed == 21 && keyCode == 22 || _keyPressed == 22 && keyCode == 21) {
|
||||||
navigatorFocusNode.requestFocus();
|
focusToNavbar(navigatorFocusNode);
|
||||||
navigatorFocusNode.focusInDirection(TraversalDirection.down);
|
|
||||||
}
|
}
|
||||||
_keyPressed = keyCode;
|
_keyPressed = keyCode;
|
||||||
Future.delayed(Duration(milliseconds: 100), () => {
|
Future.delayed(Duration(milliseconds: 100), () => {
|
||||||
_keyPressed = 0
|
_keyPressed = 0
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case 20: // DOWN
|
||||||
|
// If it's bottom row, go to navigation bar
|
||||||
|
var row = FocusManager.instance.primaryFocus.parent;
|
||||||
|
var column = row.parent;
|
||||||
|
|
||||||
|
if (column.children.last == row) {
|
||||||
|
focusToNavbar(navigatorFocusNode);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 19: // UP
|
case 19: // UP
|
||||||
if (navigatorFocusNode.hasFocus) {
|
if (navigatorFocusNode.hasFocus) {
|
||||||
rootFocusNode.focusInDirection(TraversalDirection.up);
|
rootFocusNode.focusInDirection(TraversalDirection.up);
|
||||||
|
@ -287,6 +294,11 @@ class _MainScreenState extends State<MainScreen> with SingleTickerProviderStateM
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void focusToNavbar(FocusScopeNode navigatorFocusNode) {
|
||||||
|
navigatorFocusNode.requestFocus();
|
||||||
|
navigatorFocusNode.focusInDirection(TraversalDirection.down); // If player bar is hidden, focus won't be visible, so go down once more
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
FocusScopeNode navigatorFocusNode = FocusScopeNode(); // for bottom navigator
|
FocusScopeNode navigatorFocusNode = FocusScopeNode(); // for bottom navigator
|
||||||
|
|
|
@ -135,7 +135,6 @@ class ArtistTile extends StatelessWidget {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 150,
|
width: 150,
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
onLongPress: onHold,
|
onLongPress: onHold,
|
||||||
|
@ -246,7 +245,6 @@ class PlaylistCardTile extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
color: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
height: 180.0,
|
height: 180.0,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
|
@ -293,7 +291,6 @@ class SmartTrackListTile extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
height: 200.0,
|
height: 200.0,
|
||||||
color: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
onLongPress: onHold,
|
onLongPress: onHold,
|
||||||
|
@ -364,7 +361,6 @@ class AlbumCard extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
color: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
onLongPress: onHold,
|
onLongPress: onHold,
|
||||||
|
|
Loading…
Reference in New Issue