diff options
Diffstat (limited to 'lib/main.dart')
| -rw-r--r-- | lib/main.dart | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/main.dart b/lib/main.dart index fa48706..f7f3c06 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -36,6 +36,9 @@ class MyAppState extends StreamState<MyApp> { stream$: Stream.periodic(Duration(seconds: 1), (_x) => DateTime.now()).asBroadcastStream(), value: DateTime.now(), ); + + FocusNode searchFieldFocus = FocusNode(); + void initState() { super.initState(); @@ -51,6 +54,11 @@ class MyAppState extends StreamState<MyApp> { initStateValue(dateTime); } + void dispose() { + searchFieldFocus.dispose(); + super.dispose(); + } + void openApp(Application app) { DeviceApps.openApp(app.packageName); } @@ -103,8 +111,13 @@ class MyAppState extends StreamState<MyApp> { onWillPop: () => Future.value(false), child: PageView( controller: PageController(keepPage: true), - onPageChanged: (_x) { - SystemChannels.textInput.invokeMethod('TextInput.hide'); + onPageChanged: (x) { + if (x == 1) { + searchFieldFocus.requestFocus(); + } else { + searchFieldFocus.unfocus(); + //SystemChannels.textInput.invokeMethod('TextInput.hide'); + } }, children: [ HomeView( @@ -117,6 +130,7 @@ class MyAppState extends StreamState<MyApp> { appList: applications.value, openApp: openApp, openOptionsMenu: openOptionsMenu, + searchFieldFocus: searchFieldFocus, ), ], ), |
