Android TV support - search screen
This commit is contained in:
parent
f91fe8f216
commit
daee0c03e0
@ -1,5 +1,6 @@
|
|||||||
import 'package:connectivity/connectivity.dart';
|
import 'package:connectivity/connectivity.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/src/services/keyboard_key.dart';
|
||||||
import 'package:freezer/api/cache.dart';
|
import 'package:freezer/api/cache.dart';
|
||||||
import 'package:freezer/api/download.dart';
|
import 'package:freezer/api/download.dart';
|
||||||
import 'package:freezer/api/player.dart';
|
import 'package:freezer/api/player.dart';
|
||||||
@ -121,6 +122,7 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var textFielFocusNode = FocusNode();
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: FreezerAppBar('Search'.i18n),
|
appBar: FreezerAppBar('Search'.i18n),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
@ -134,11 +136,22 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment(1.0, 0.0),
|
alignment: Alignment(1.0, 0.0),
|
||||||
children: [
|
children: [
|
||||||
TextField(
|
RawKeyboardListener(
|
||||||
|
focusNode: FocusNode(),
|
||||||
|
onKey: (event) { // For Android TV: quit search textfield
|
||||||
|
if (event.runtimeType.toString() == 'RawKeyUpEvent') {
|
||||||
|
LogicalKeyboardKey key = event.data.logicalKey;
|
||||||
|
if (key == LogicalKeyboardKey.arrowDown) {
|
||||||
|
textFielFocusNode.unfocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: TextField(
|
||||||
onChanged: (String s) {
|
onChanged: (String s) {
|
||||||
setState(() => _query = s);
|
setState(() => _query = s);
|
||||||
_loadSuggestions();
|
_loadSuggestions();
|
||||||
},
|
},
|
||||||
|
focusNode: textFielFocusNode,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Search or paste URL'.i18n,
|
labelText: 'Search or paste URL'.i18n,
|
||||||
fillColor: Theme.of(context).bottomAppBarColor,
|
fillColor: Theme.of(context).bottomAppBarColor,
|
||||||
@ -152,6 +165,7 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
),
|
),
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
onSubmitted: (String s) => _submit(context, query: s),
|
onSubmitted: (String s) => _submit(context, query: s),
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
Loading…
Reference in New Issue
Block a user