From 5e6c0142260df864c602538b69c5ccfa3ccd928c Mon Sep 17 00:00:00 2001 From: Jaylen Bian Date: Sun, 18 Jul 2021 13:07:32 +0800 Subject: [PATCH] [infra_ui] Refactor platform interface to infra_ui scope and remove keyboard interface --- .../Flutter/GeneratedPluginRegistrant.swift | 2 +- .../flowy_infra_ui/example/pubspec.lock | 21 +++++++++++++++ .../flutter/generated_plugin_registrant.cc | 6 ++--- .../.gitignore | 0 .../.metadata | 0 .../CHANGELOG.md | 0 .../LICENSE | 0 .../README.md | 2 +- .../analysis_options.yaml | 0 .../flowy_infra_ui_platform_interface.dart | 27 +++++++++++++++++++ .../src/method_channel_flowy_infra_ui.dart | 26 ++++++++++++++++++ .../pubspec.lock | 0 .../pubspec.yaml | 6 ++--- ...lowy_infra_ui_platform_interface_test.dart | 5 ++++ .../.gitignore | 0 .../.metadata | 0 .../CHANGELOG.md | 0 .../LICENSE | 0 .../README.md | 2 +- .../analysis_options.yaml | 0 .../lib/flowy_infra_ui_web.dart | 23 ++++++++++++++++ .../pubspec.lock | 14 +++++----- .../pubspec.yaml | 11 ++++---- .../test/flowy_infra_ui_web_test.dart | 5 ++++ .../lib/keyboard_platform_interface.dart | 23 ---------------- .../lib/src/method_channel_keyboard.dart | 17 ------------ .../keyboard_platform_interface_test.dart | 5 ---- .../keyboard_web/lib/keyboard_web.dart | 7 ----- .../keyboard_web/test/keyboard_web_test.dart | 12 --------- .../packages/flowy_infra_ui/pubspec.lock | 23 +++++++++++++++- .../packages/flowy_infra_ui/pubspec.yaml | 21 +++++++++------ 31 files changed, 164 insertions(+), 94 deletions(-) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_platform_interface => flowy_infra_ui_platform_interface}/.gitignore (100%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_platform_interface => flowy_infra_ui_platform_interface}/.metadata (100%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_platform_interface => flowy_infra_ui_platform_interface}/CHANGELOG.md (100%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_platform_interface => flowy_infra_ui_platform_interface}/LICENSE (100%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_platform_interface => flowy_infra_ui_platform_interface}/README.md (92%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_platform_interface => flowy_infra_ui_platform_interface}/analysis_options.yaml (100%) create mode 100644 app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/flowy_infra_ui_platform_interface.dart create mode 100644 app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/src/method_channel_flowy_infra_ui.dart rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_platform_interface => flowy_infra_ui_platform_interface}/pubspec.lock (100%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_platform_interface => flowy_infra_ui_platform_interface}/pubspec.yaml (85%) create mode 100644 app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/test/flowy_infra_ui_platform_interface_test.dart rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_web => flowy_infra_ui_web}/.gitignore (100%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_web => flowy_infra_ui_web}/.metadata (100%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_web => flowy_infra_ui_web}/CHANGELOG.md (100%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_web => flowy_infra_ui_web}/LICENSE (100%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_web => flowy_infra_ui_web}/README.md (95%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_web => flowy_infra_ui_web}/analysis_options.yaml (100%) create mode 100644 app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/lib/flowy_infra_ui_web.dart rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_web => flowy_infra_ui_web}/pubspec.lock (97%) rename app_flowy/packages/flowy_infra_ui/{platform_interface/keyboard_web => flowy_infra_ui_web}/pubspec.yaml (59%) create mode 100644 app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/test/flowy_infra_ui_web_test.dart delete mode 100644 app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/lib/keyboard_platform_interface.dart delete mode 100644 app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/lib/src/method_channel_keyboard.dart delete mode 100644 app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/test/keyboard_platform_interface_test.dart delete mode 100644 app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/lib/keyboard_web.dart delete mode 100644 app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/test/keyboard_web_test.dart diff --git a/app_flowy/packages/flowy_infra_ui/example/macos/Flutter/GeneratedPluginRegistrant.swift b/app_flowy/packages/flowy_infra_ui/example/macos/Flutter/GeneratedPluginRegistrant.swift index fe63258f95..0c920d5387 100644 --- a/app_flowy/packages/flowy_infra_ui/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/app_flowy/packages/flowy_infra_ui/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,5 +8,5 @@ import Foundation import flowy_infra_ui func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - FlowyInfraUiPlugin.register(with: registry.registrar(forPlugin: "FlowyInfraUiPlugin")) + FlowyInfraUIPlugin.register(with: registry.registrar(forPlugin: "FlowyInfraUIPlugin")) } diff --git a/app_flowy/packages/flowy_infra_ui/example/pubspec.lock b/app_flowy/packages/flowy_infra_ui/example/pubspec.lock index bf24d5be0c..7b3e7031d3 100644 --- a/app_flowy/packages/flowy_infra_ui/example/pubspec.lock +++ b/app_flowy/packages/flowy_infra_ui/example/pubspec.lock @@ -99,6 +99,20 @@ packages: relative: true source: path version: "0.0.1" + flowy_infra_ui_platform_interface: + dependency: transitive + description: + path: "../flowy_infra_ui_platform_interface" + relative: true + source: path + version: "0.0.1" + flowy_infra_ui_web: + dependency: transitive + description: + path: "../flowy_infra_ui_web" + relative: true + source: path + version: "0.0.1" flutter: dependency: "direct main" description: flutter @@ -177,6 +191,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" provider: dependency: "direct main" description: diff --git a/app_flowy/packages/flowy_infra_ui/example/windows/flutter/generated_plugin_registrant.cc b/app_flowy/packages/flowy_infra_ui/example/windows/flutter/generated_plugin_registrant.cc index eb5983d9f8..0f8fb4aef5 100644 --- a/app_flowy/packages/flowy_infra_ui/example/windows/flutter/generated_plugin_registrant.cc +++ b/app_flowy/packages/flowy_infra_ui/example/windows/flutter/generated_plugin_registrant.cc @@ -4,9 +4,9 @@ #include "generated_plugin_registrant.h" -#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { - FlowyInfraUiPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlowyInfraUiPlugin")); + FlowyInfraUIPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlowyInfraUIPlugin")); } diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/.gitignore b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/.gitignore similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/.gitignore rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/.gitignore diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/.metadata b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/.metadata similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/.metadata rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/.metadata diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/CHANGELOG.md b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/CHANGELOG.md similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/CHANGELOG.md rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/CHANGELOG.md diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/LICENSE b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/LICENSE similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/LICENSE rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/LICENSE diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/README.md b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/README.md similarity index 92% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/README.md rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/README.md index 19f51139a6..d4b7622cef 100644 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/README.md +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/README.md @@ -1,4 +1,4 @@ -# keyboard_platform_interface +# flowy_infra_ui_platform_interface A new Flutter package project. diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/analysis_options.yaml b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/analysis_options.yaml similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/analysis_options.yaml rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/analysis_options.yaml diff --git a/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/flowy_infra_ui_platform_interface.dart b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/flowy_infra_ui_platform_interface.dart new file mode 100644 index 0000000000..32ac147886 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/flowy_infra_ui_platform_interface.dart @@ -0,0 +1,27 @@ +library flowy_infra_ui_platform_interface; + +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import 'src/method_channel_flowy_infra_ui.dart'; + +abstract class FlowyInfraUIPlatform extends PlatformInterface { + FlowyInfraUIPlatform() : super(token: _token); + + static final Object _token = Object(); + + static FlowyInfraUIPlatform _instance = MethodChannelFlowyInfraUI(); + + static FlowyInfraUIPlatform get instance => _instance; + + static set instance(FlowyInfraUIPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + Stream get onKeyboardVisibilityChange { + throw UnimplementedError('`onKeyboardChange` should be overrided by subclass.'); + } + + Future getPlatformVersion() { + throw UnimplementedError('`getPlatformVersion` should be overrided by subclass.'); + } +} diff --git a/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/src/method_channel_flowy_infra_ui.dart b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/src/method_channel_flowy_infra_ui.dart new file mode 100644 index 0000000000..067636ad8b --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/lib/src/method_channel_flowy_infra_ui.dart @@ -0,0 +1,26 @@ +import 'package:flowy_infra_ui_platform_interface/flowy_infra_ui_platform_interface.dart'; +import 'package:flutter/services.dart'; + +import '../flowy_infra_ui_platform_interface.dart'; + +// ignore: constant_identifier_names +const INFRA_UI_METHOD_CHANNEL_NAME = 'flowy_infra_ui_method'; +const INFRA_UI_KEYBOARD_EVENT_CHANNEL_NAME = 'flowy_infra_ui_event/keyboard'; +const INFRA_UI_METHOD_GET_PLATFORM_VERSION = 'getPlatformVersion'; + +class MethodChannelFlowyInfraUI extends FlowyInfraUIPlatform { + final MethodChannel _methodChannel = const MethodChannel(INFRA_UI_METHOD_CHANNEL_NAME); + final EventChannel _keyboardChannel = const EventChannel(INFRA_UI_KEYBOARD_EVENT_CHANNEL_NAME); + + late final Stream _onKeyboardVisibilityChange = + _keyboardChannel.receiveBroadcastStream().map((event) => event as bool); + + @override + Stream get onKeyboardVisibilityChange => _onKeyboardVisibilityChange; + + @override + Future getPlatformVersion() async { + String? version = await _methodChannel.invokeMethod(INFRA_UI_METHOD_GET_PLATFORM_VERSION); + return version ?? 'unknow'; + } +} diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/pubspec.lock b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/pubspec.lock similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/pubspec.lock rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/pubspec.lock diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/pubspec.yaml b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/pubspec.yaml similarity index 85% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/pubspec.yaml rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/pubspec.yaml index 800a97c674..0b5f8eb74b 100644 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/pubspec.yaml +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/pubspec.yaml @@ -1,4 +1,4 @@ -name: keyboard_platform_interface +name: flowy_infra_ui_platform_interface description: A new Flutter package project. version: 0.0.1 homepage: @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - + plugin_platform_interface: ^2.0.0 dev_dependencies: @@ -18,4 +18,4 @@ dev_dependencies: sdk: flutter flutter_lints: ^1.0.0 -flutter: +flutter: \ No newline at end of file diff --git a/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/test/flowy_infra_ui_platform_interface_test.dart b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/test/flowy_infra_ui_platform_interface_test.dart new file mode 100644 index 0000000000..b351001e1a --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_platform_interface/test/flowy_infra_ui_platform_interface_test.dart @@ -0,0 +1,5 @@ +import 'package:flutter_test/flutter_test.dart'; + +import 'package:flowy_infra_ui_platform_interface/flowy_infra_ui_platform_interface.dart'; + +void main() {} diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/.gitignore b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/.gitignore similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/.gitignore rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/.gitignore diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/.metadata b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/.metadata similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/.metadata rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/.metadata diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/CHANGELOG.md b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/CHANGELOG.md similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/CHANGELOG.md rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/CHANGELOG.md diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/LICENSE b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/LICENSE similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/LICENSE rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/LICENSE diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/README.md b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/README.md similarity index 95% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/README.md rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/README.md index 94b4102a22..b552d83994 100644 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/README.md +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/README.md @@ -1,4 +1,4 @@ -# keyboard_web +# flowy_infra_ui_web A new Flutter package project. diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/analysis_options.yaml b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/analysis_options.yaml similarity index 100% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/analysis_options.yaml rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/analysis_options.yaml diff --git a/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/lib/flowy_infra_ui_web.dart b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/lib/flowy_infra_ui_web.dart new file mode 100644 index 0000000000..98a7864942 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/lib/flowy_infra_ui_web.dart @@ -0,0 +1,23 @@ +library flowy_infra_ui_web; + +import 'package:flowy_infra_ui_platform_interface/flowy_infra_ui_platform_interface.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + +class FlowyInfraUIPlugin extends FlowyInfraUIPlatform { + static void registerWith(Registrar registrar) { + FlowyInfraUIPlatform.instance = FlowyInfraUIPlugin(); + } + + // MARK: - Keyboard + + @override + Stream get onKeyboardVisibilityChange async* { + // suppose that keyboard won't show in web side + yield false; + } + + @override + Future getPlatformVersion() async { + return 'Web: unknow version'; + } +} diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/pubspec.lock b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/pubspec.lock similarity index 97% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/pubspec.lock rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/pubspec.lock index 4508a8bebb..804b67b5b9 100644 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/pubspec.lock +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/pubspec.lock @@ -50,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + flowy_infra_ui_platform_interface: + dependency: "direct main" + description: + path: "../flowy_infra_ui_platform_interface" + relative: true + source: path + version: "0.0.1" flutter: dependency: transitive description: flutter @@ -79,13 +86,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" - keyboard_platform_interface: - dependency: "direct main" - description: - path: "../keyboard_platform_interface" - relative: true - source: path - version: "0.0.1" lints: dependency: transitive description: diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/pubspec.yaml b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/pubspec.yaml similarity index 59% rename from app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/pubspec.yaml rename to app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/pubspec.yaml index 8e1fa906cb..03600f2e5a 100644 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/pubspec.yaml +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/pubspec.yaml @@ -1,7 +1,8 @@ -name: keyboard_web +name: flowy_infra_ui_web description: A new Flutter package project. version: 0.0.1 homepage: +publish_to: none environment: sdk: ">=2.12.0 <3.0.0" @@ -11,8 +12,8 @@ dependencies: flutter_web_plugins: sdk: flutter - keyboard_platform_interface: - path: ../keyboard_platform_interface + flowy_infra_ui_platform_interface: + path: ../flowy_infra_ui_platform_interface dev_dependencies: flutter_test: @@ -23,5 +24,5 @@ flutter: plugin: platforms: web: - pluginClass: KeyboardPlugin - fileName: keyboard_web \ No newline at end of file + pluginClass: FlowyInfraUIPlugin + fileName: flowy_infra_ui_web.dart \ No newline at end of file diff --git a/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/test/flowy_infra_ui_web_test.dart b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/test/flowy_infra_ui_web_test.dart new file mode 100644 index 0000000000..a9de9b8be5 --- /dev/null +++ b/app_flowy/packages/flowy_infra_ui/flowy_infra_ui_web/test/flowy_infra_ui_web_test.dart @@ -0,0 +1,5 @@ +import 'package:flutter_test/flutter_test.dart'; + +import 'package:flowy_infra_ui_web/flowy_infra_ui_web.dart'; + +void main() {} diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/lib/keyboard_platform_interface.dart b/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/lib/keyboard_platform_interface.dart deleted file mode 100644 index 2fd5a82661..0000000000 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/lib/keyboard_platform_interface.dart +++ /dev/null @@ -1,23 +0,0 @@ -library keyboard_platform_interface; - -import 'package:plugin_platform_interface/plugin_platform_interface.dart'; -import 'src/method_channel_keyboard.dart'; - -abstract class KeyboardPlatform extends PlatformInterface { - KeyboardPlatform() : super(token: _token); - - static final Object _token = Object(); - - static KeyboardPlatform _instance = MethodChannelKeyboard(); - - static KeyboardPlatform get instance => _instance; - - static set instance(KeyboardPlatform instance) { - PlatformInterface.verifyToken(instance, _token); - _instance = instance; - } - - Stream get onKeyboardChange { - throw UnimplementedError('`onKeyboardChange` should be overrided by subclass.'); - } -} diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/lib/src/method_channel_keyboard.dart b/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/lib/src/method_channel_keyboard.dart deleted file mode 100644 index f543df69fd..0000000000 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/lib/src/method_channel_keyboard.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'dart:html'; - -import 'package:flutter/services.dart'; - -import '../keyboard_platform_interface.dart'; - -// ignore: constant_identifier_names -const INFRA_UI_KEYBOARD_EVENT_CHANNEL_NAME = "flowy_infra_ui_event/keyboard"; - -class MethodChannelKeyboard extends KeyboardPlatform { - final EventChannel _keyboardChannel = const EventChannel(INFRA_UI_KEYBOARD_EVENT_CHANNEL_NAME); - - late final Stream _onKeyboardChange = _keyboardChannel.receiveBroadcastStream().map((event) => event as bool); - - @override - Stream get onKeyboardChange => _onKeyboardChange; -} diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/test/keyboard_platform_interface_test.dart b/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/test/keyboard_platform_interface_test.dart deleted file mode 100644 index 815becdd47..0000000000 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_platform_interface/test/keyboard_platform_interface_test.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; - -import 'package:keyboard_platform_interface/keyboard_platform_interface.dart'; - -void main() {} diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/lib/keyboard_web.dart b/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/lib/keyboard_web.dart deleted file mode 100644 index ca61d9ed4a..0000000000 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/lib/keyboard_web.dart +++ /dev/null @@ -1,7 +0,0 @@ -library keyboard_web; - -/// A Calculator. -class Calculator { - /// Returns [value] plus 1. - int addOne(int value) => value + 1; -} diff --git a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/test/keyboard_web_test.dart b/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/test/keyboard_web_test.dart deleted file mode 100644 index 095c2544ca..0000000000 --- a/app_flowy/packages/flowy_infra_ui/platform_interface/keyboard_web/test/keyboard_web_test.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; - -import 'package:keyboard_web/keyboard_web.dart'; - -void main() { - test('adds one to input values', () { - final calculator = Calculator(); - expect(calculator.addOne(2), 3); - expect(calculator.addOne(-7), -6); - expect(calculator.addOne(0), 1); - }); -} diff --git a/app_flowy/packages/flowy_infra_ui/pubspec.lock b/app_flowy/packages/flowy_infra_ui/pubspec.lock index db0559ecf9..9b2f5e6a79 100644 --- a/app_flowy/packages/flowy_infra_ui/pubspec.lock +++ b/app_flowy/packages/flowy_infra_ui/pubspec.lock @@ -85,6 +85,20 @@ packages: relative: true source: path version: "0.0.1" + flowy_infra_ui_platform_interface: + dependency: "direct main" + description: + path: flowy_infra_ui_platform_interface + relative: true + source: path + version: "0.0.1" + flowy_infra_ui_web: + dependency: "direct main" + description: + path: flowy_infra_ui_web + relative: true + source: path + version: "0.0.1" flutter: dependency: "direct main" description: flutter @@ -103,7 +117,7 @@ packages: source: sdk version: "0.0.0" flutter_web_plugins: - dependency: "direct main" + dependency: transitive description: flutter source: sdk version: "0.0.0" @@ -163,6 +177,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" provider: dependency: "direct main" description: diff --git a/app_flowy/packages/flowy_infra_ui/pubspec.yaml b/app_flowy/packages/flowy_infra_ui/pubspec.yaml index d1af8afe3d..fec0ebe4a1 100644 --- a/app_flowy/packages/flowy_infra_ui/pubspec.yaml +++ b/app_flowy/packages/flowy_infra_ui/pubspec.yaml @@ -11,8 +11,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_web_plugins: - sdk: flutter + # Thirdparty packages textstyle_extensions: '2.0.0-nullsafety' dartz: '0.10.0-nullsafety.2' @@ -20,6 +19,13 @@ dependencies: styled_widget: '>=0.3.1' equatable: '>=2.0.2' animations: ^2.0.0 + + # Federated Platform Interface + flowy_infra_ui_platform_interface: + path: flowy_infra_ui_platform_interface + flowy_infra_ui_web: + path: flowy_infra_ui_web + # Flowy packages flowy_infra: path: ../flowy_infra @@ -34,13 +40,12 @@ flutter: platforms: android: package: com.example.flowy_infra_ui - pluginClass: FlowyInfraUiPlugin + pluginClass: FlowyInfraUIPlugin ios: - pluginClass: FlowyInfraUiPlugin + pluginClass: FlowyInfraUIPlugin macos: - pluginClass: FlowyInfraUiPlugin + pluginClass: FlowyInfraUIPlugin windows: - pluginClass: FlowyInfraUiPlugin + pluginClass: FlowyInfraUIPlugin web: - pluginClass: FlowyInfraUiWeb - fileName: flowy_infra_ui_web.dart \ No newline at end of file + default_package: flowy_infra_ui_web \ No newline at end of file