Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

[infra_ui][focus] Impl auto unfocus widget for infra ui

Jaylen Biane41579bc652d
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
+ <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
+ <classpathentry kind="output" path="bin/default"/>
+</classpath>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>flowy_infra_ui</name>
+ <comment>Project flowy_infra_ui created by Buildship.</comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1626576261667</id>
+ <name></name>
+ <type>30</type>
+ <matcher>
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
+ <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>android</name>
+ <comment>Project android created by Buildship.</comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1626576261654</id>
+ <name></name>
+ <type>30</type>
+ <matcher>
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
+ <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
+ <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
+ <classpathentry kind="output" path="bin/default"/>
+</classpath>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>app</name>
+ <comment>Project app created by Buildship.</comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1626576261660</id>
+ <name></name>
+ <type>30</type>
+ <matcher>
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
+ <arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
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