diff options
| author | Akshay Nair <phenax5@gmail.com> | 2020-06-21 23:07:33 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2020-06-21 23:07:33 +0530 |
| commit | f41510dc4e54a8c15c58a4d7ca5ecc5c023b2285 (patch) | |
| tree | bea7eae674157e07fd90ee2b98924a538d19ba07 /lib/main.dart | |
| parent | 0ec3ce0089cee442d8a8152befeea5213c412b14 (diff) | |
| download | daft-launcher-f41510dc4e54a8c15c58a4d7ca5ecc5c023b2285.tar.gz daft-launcher-f41510dc4e54a8c15c58a4d7ca5ecc5c023b2285.zip | |
Implements node focus in/out
Diffstat (limited to '')
| -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, ), ], ), |
