aboutsummaryrefslogtreecommitdiff
path: root/lib/main.dart
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-06-21 23:10:29 +0530
committerGitHub <noreply@github.com>2020-06-21 23:10:29 +0530
commit8a1f84014949be194c5303ef7cdd10876f42a838 (patch)
tree0510f0d9756063e30f834af53e6f0476e8b3959b /lib/main.dart
parentc3a864ede61187256c1d5b726e41bb5243b0c7e2 (diff)
parent94dbc54db0a9ac9e563a3cc1ce3263ebda5add16 (diff)
downloaddaft-launcher-8a1f84014949be194c5303ef7cdd10876f42a838.tar.gz
daft-launcher-8a1f84014949be194c5303ef7cdd10876f42a838.zip
Merge pull request #2 from phenax/feature/keyboard_focus0.0.2
Keyboard focus
Diffstat (limited to 'lib/main.dart')
-rw-r--r--lib/main.dart18
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,
),
],
),