mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[infra_ui] Refactor platform interface to infra_ui scope and remove keyboard interface
This commit is contained in:
parent
cb3ed0a308
commit
5e6c014226
@ -8,5 +8,5 @@ import Foundation
|
|||||||
import flowy_infra_ui
|
import flowy_infra_ui
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FlowyInfraUiPlugin.register(with: registry.registrar(forPlugin: "FlowyInfraUiPlugin"))
|
FlowyInfraUIPlugin.register(with: registry.registrar(forPlugin: "FlowyInfraUIPlugin"))
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,20 @@ packages:
|
|||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "0.0.1"
|
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:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -177,6 +191,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
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:
|
provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <flowy_infra_ui/flowy_infra_ui_plugin.h>
|
#include <flowy_infra_ui/flowy_infra_u_i_plugin.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
FlowyInfraUiPluginRegisterWithRegistrar(
|
FlowyInfraUIPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("FlowyInfraUiPlugin"));
|
registry->GetRegistrarForPlugin("FlowyInfraUIPlugin"));
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# keyboard_platform_interface
|
# flowy_infra_ui_platform_interface
|
||||||
|
|
||||||
A new Flutter package project.
|
A new Flutter package project.
|
||||||
|
|
@ -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<bool> get onKeyboardVisibilityChange {
|
||||||
|
throw UnimplementedError('`onKeyboardChange` should be overrided by subclass.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getPlatformVersion() {
|
||||||
|
throw UnimplementedError('`getPlatformVersion` should be overrided by subclass.');
|
||||||
|
}
|
||||||
|
}
|
@ -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<bool> _onKeyboardVisibilityChange =
|
||||||
|
_keyboardChannel.receiveBroadcastStream().map((event) => event as bool);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<bool> get onKeyboardVisibilityChange => _onKeyboardVisibilityChange;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> getPlatformVersion() async {
|
||||||
|
String? version = await _methodChannel.invokeMethod<String>(INFRA_UI_METHOD_GET_PLATFORM_VERSION);
|
||||||
|
return version ?? 'unknow';
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
name: keyboard_platform_interface
|
name: flowy_infra_ui_platform_interface
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
homepage:
|
homepage:
|
||||||
@ -10,7 +10,7 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
plugin_platform_interface: ^2.0.0
|
plugin_platform_interface: ^2.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
@ -18,4 +18,4 @@ dev_dependencies:
|
|||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^1.0.0
|
flutter_lints: ^1.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
@ -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() {}
|
@ -1,4 +1,4 @@
|
|||||||
# keyboard_web
|
# flowy_infra_ui_web
|
||||||
|
|
||||||
A new Flutter package project.
|
A new Flutter package project.
|
||||||
|
|
@ -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<bool> get onKeyboardVisibilityChange async* {
|
||||||
|
// suppose that keyboard won't show in web side
|
||||||
|
yield false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String?> getPlatformVersion() async {
|
||||||
|
return 'Web: unknow version';
|
||||||
|
}
|
||||||
|
}
|
@ -50,6 +50,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
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:
|
flutter:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -79,13 +86,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.3"
|
version: "0.6.3"
|
||||||
keyboard_platform_interface:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
path: "../keyboard_platform_interface"
|
|
||||||
relative: true
|
|
||||||
source: path
|
|
||||||
version: "0.0.1"
|
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
@ -1,7 +1,8 @@
|
|||||||
name: keyboard_web
|
name: flowy_infra_ui_web
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
homepage:
|
homepage:
|
||||||
|
publish_to: none
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
@ -11,8 +12,8 @@ dependencies:
|
|||||||
flutter_web_plugins:
|
flutter_web_plugins:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
keyboard_platform_interface:
|
flowy_infra_ui_platform_interface:
|
||||||
path: ../keyboard_platform_interface
|
path: ../flowy_infra_ui_platform_interface
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@ -23,5 +24,5 @@ flutter:
|
|||||||
plugin:
|
plugin:
|
||||||
platforms:
|
platforms:
|
||||||
web:
|
web:
|
||||||
pluginClass: KeyboardPlugin
|
pluginClass: FlowyInfraUIPlugin
|
||||||
fileName: keyboard_web
|
fileName: flowy_infra_ui_web.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() {}
|
@ -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<bool> get onKeyboardChange {
|
|
||||||
throw UnimplementedError('`onKeyboardChange` should be overrided by subclass.');
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<bool> _onKeyboardChange = _keyboardChannel.receiveBroadcastStream().map((event) => event as bool);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Stream<bool> get onKeyboardChange => _onKeyboardChange;
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
import 'package:keyboard_platform_interface/keyboard_platform_interface.dart';
|
|
||||||
|
|
||||||
void main() {}
|
|
@ -1,7 +0,0 @@
|
|||||||
library keyboard_web;
|
|
||||||
|
|
||||||
/// A Calculator.
|
|
||||||
class Calculator {
|
|
||||||
/// Returns [value] plus 1.
|
|
||||||
int addOne(int value) => value + 1;
|
|
||||||
}
|
|
@ -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);
|
|
||||||
});
|
|
||||||
}
|
|
@ -85,6 +85,20 @@ packages:
|
|||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "0.0.1"
|
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:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -103,7 +117,7 @@ packages:
|
|||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
flutter_web_plugins:
|
flutter_web_plugins:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
@ -163,6 +177,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
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:
|
provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -11,8 +11,7 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_web_plugins:
|
|
||||||
sdk: flutter
|
|
||||||
# Thirdparty packages
|
# Thirdparty packages
|
||||||
textstyle_extensions: '2.0.0-nullsafety'
|
textstyle_extensions: '2.0.0-nullsafety'
|
||||||
dartz: '0.10.0-nullsafety.2'
|
dartz: '0.10.0-nullsafety.2'
|
||||||
@ -20,6 +19,13 @@ dependencies:
|
|||||||
styled_widget: '>=0.3.1'
|
styled_widget: '>=0.3.1'
|
||||||
equatable: '>=2.0.2'
|
equatable: '>=2.0.2'
|
||||||
animations: ^2.0.0
|
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 packages
|
||||||
flowy_infra:
|
flowy_infra:
|
||||||
path: ../flowy_infra
|
path: ../flowy_infra
|
||||||
@ -34,13 +40,12 @@ flutter:
|
|||||||
platforms:
|
platforms:
|
||||||
android:
|
android:
|
||||||
package: com.example.flowy_infra_ui
|
package: com.example.flowy_infra_ui
|
||||||
pluginClass: FlowyInfraUiPlugin
|
pluginClass: FlowyInfraUIPlugin
|
||||||
ios:
|
ios:
|
||||||
pluginClass: FlowyInfraUiPlugin
|
pluginClass: FlowyInfraUIPlugin
|
||||||
macos:
|
macos:
|
||||||
pluginClass: FlowyInfraUiPlugin
|
pluginClass: FlowyInfraUIPlugin
|
||||||
windows:
|
windows:
|
||||||
pluginClass: FlowyInfraUiPlugin
|
pluginClass: FlowyInfraUIPlugin
|
||||||
web:
|
web:
|
||||||
pluginClass: FlowyInfraUiWeb
|
default_package: flowy_infra_ui_web
|
||||||
fileName: flowy_infra_ui_web.dart
|
|
Loading…
Reference in New Issue
Block a user