From e41579bc652d2cfac62897eb747abda89b5fab83 Mon Sep 17 00:00:00 2001 From: Jaylen Bian Date: Sun, 18 Jul 2021 10:55:18 +0800 Subject: [PATCH] [infra_ui][focus] Impl auto unfocus widget for infra ui --- .../flowy_infra_ui/.vscode/launch.json | 11 ++++++ .../flowy_infra_ui/android/.classpath | 6 ++++ .../packages/flowy_infra_ui/android/.project | 34 +++++++++++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ .../flowy_infra_ui/example/android/.project | 28 +++++++++++++++ .../org.eclipse.buildship.core.prefs | 13 +++++++ .../example/android/app/.classpath | 6 ++++ .../example/android/app/.project | 34 +++++++++++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ .../lib/src/focus/auto_unfocus_overlay.dart | 26 ++++++++++++++ .../lib/src/keyboard/keyboard_.dart | 0 11 files changed, 162 insertions(+) create mode 100644 app_flowy/packages/flowy_infra_ui/.vscode/launch.json create mode 100644 app_flowy/packages/flowy_infra_ui/android/.classpath create mode 100644 app_flowy/packages/flowy_infra_ui/android/.project create mode 100644 app_flowy/packages/flowy_infra_ui/android/.settings/org.eclipse.buildship.core.prefs create mode 100644 app_flowy/packages/flowy_infra_ui/example/android/.project create mode 100644 app_flowy/packages/flowy_infra_ui/example/android/.settings/org.eclipse.buildship.core.prefs create mode 100644 app_flowy/packages/flowy_infra_ui/example/android/app/.classpath create mode 100644 app_flowy/packages/flowy_infra_ui/example/android/app/.project create mode 100644 app_flowy/packages/flowy_infra_ui/example/android/app/.settings/org.eclipse.buildship.core.prefs create mode 100644 app_flowy/packages/flowy_infra_ui/lib/src/focus/auto_unfocus_overlay.dart create mode 100644 app_flowy/packages/flowy_infra_ui/lib/src/keyboard/keyboard_.dart diff --git a/app_flowy/packages/flowy_infra_ui/.vscode/launch.json b/app_flowy/packages/flowy_infra_ui/.vscode/launch.json new file mode 100644 index 0000000000..ba345105b4 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Infra UI Example", + "type": "dart", + "request": "launch", + "program": "example/lib/main.dart" + }, + ] +} \ No newline at end of file diff --git a/app_flowy/packages/flowy_infra_ui/android/.classpath b/app_flowy/packages/flowy_infra_ui/android/.classpath new file mode 100644 index 0000000000..4a04201ca2 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/android/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/app_flowy/packages/flowy_infra_ui/android/.project b/app_flowy/packages/flowy_infra_ui/android/.project new file mode 100644 index 0000000000..77aded223a --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/android/.project @@ -0,0 +1,34 @@ + + + flowy_infra_ui + Project flowy_infra_ui created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + + + 1626576261667 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/app_flowy/packages/flowy_infra_ui/android/.settings/org.eclipse.buildship.core.prefs b/app_flowy/packages/flowy_infra_ui/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000000..e8895216fd --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/app_flowy/packages/flowy_infra_ui/example/android/.project b/app_flowy/packages/flowy_infra_ui/example/android/.project new file mode 100644 index 0000000000..b06fea48c8 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/example/android/.project @@ -0,0 +1,28 @@ + + + android + Project android created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + + + 1626576261654 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/app_flowy/packages/flowy_infra_ui/example/android/.settings/org.eclipse.buildship.core.prefs b/app_flowy/packages/flowy_infra_ui/example/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000000..25e4212285 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/example/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,13 @@ +arguments= +auto.sync=false +build.scans.enabled=false +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) +connection.project.dir= +eclipse.preferences.version=1 +gradle.user.home= +java.home=/Library/Java/JavaVirtualMachines/jdk11.0.5-zulu.jdk/Contents/Home +jvm.arguments= +offline.mode=false +override.workspace.settings=true +show.console.view=true +show.executions.view=true diff --git a/app_flowy/packages/flowy_infra_ui/example/android/app/.classpath b/app_flowy/packages/flowy_infra_ui/example/android/app/.classpath new file mode 100644 index 0000000000..4a04201ca2 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/example/android/app/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/app_flowy/packages/flowy_infra_ui/example/android/app/.project b/app_flowy/packages/flowy_infra_ui/example/android/app/.project new file mode 100644 index 0000000000..df522843d5 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/example/android/app/.project @@ -0,0 +1,34 @@ + + + app + Project app created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + + + 1626576261660 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/app_flowy/packages/flowy_infra_ui/example/android/app/.settings/org.eclipse.buildship.core.prefs b/app_flowy/packages/flowy_infra_ui/example/android/app/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000000..b1886adb46 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/example/android/app/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir=.. +eclipse.preferences.version=1 diff --git a/app_flowy/packages/flowy_infra_ui/lib/src/focus/auto_unfocus_overlay.dart b/app_flowy/packages/flowy_infra_ui/lib/src/focus/auto_unfocus_overlay.dart new file mode 100644 index 0000000000..45faebc07d --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/lib/src/focus/auto_unfocus_overlay.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; + +class AutoUnfocus extends StatelessWidget { + const AutoUnfocus({ + Key? key, + required this.child, + }) : super(key: key); + + final Widget child; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => _unfocusWidget(context), + child: child, + ); + } + + void _unfocusWidget(BuildContext context) { + final focusing = FocusScope.of(context); + + if (!focusing.hasPrimaryFocus && focusing.hasFocus) { + FocusManager.instance.primaryFocus?.unfocus(); + } + } +} diff --git a/app_flowy/packages/flowy_infra_ui/lib/src/keyboard/keyboard_.dart b/app_flowy/packages/flowy_infra_ui/lib/src/keyboard/keyboard_.dart new file mode 100644 index 0000000000..e69de29bb2