mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-09-11 19:17:43 +03:00
[infra_ui] Integrate keyboard detector to example proj
This commit is contained in:
parent
5e6c014226
commit
54fd744899
@ -15,8 +15,8 @@ import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
import io.flutter.plugin.common.MethodChannel.Result;
|
||||
|
||||
/** FlowyInfraUiPlugin */
|
||||
public class FlowyInfraUiPlugin implements FlutterPlugin, ActivityAware, MethodCallHandler {
|
||||
/** FlowyInfraUIPlugin */
|
||||
public class FlowyInfraUIPlugin implements FlutterPlugin, ActivityAware, MethodCallHandler {
|
||||
|
||||
// MARK: - Constant
|
||||
public static final String INFRA_UI_METHOD_CHANNEL_NAME = "flowy_infra_ui_method";
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.example.flowy_infra_ui
|
||||
|
||||
import androidx.annotation.NonNull
|
||||
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||
import io.flutter.plugin.common.MethodChannel.Result
|
||||
|
||||
/** FlowyInfraUiPlugin */
|
||||
class FlowyInfraUiPlugin: FlutterPlugin, MethodCallHandler {
|
||||
/// The MethodChannel that will the communication between Flutter and native Android
|
||||
///
|
||||
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
|
||||
/// when the Flutter Engine is detached from the Activity
|
||||
private lateinit var channel : MethodChannel
|
||||
|
||||
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flowy_infra_ui")
|
||||
channel.setMethodCallHandler(this)
|
||||
}
|
||||
|
||||
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
|
||||
if (call.method == "getPlatformVersion") {
|
||||
result.success("Android ${android.os.Build.VERSION.RELEASE}")
|
||||
} else {
|
||||
result.notImplemented()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
|
||||
channel.setMethodCallHandler(null)
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.example.flowy_infra_ui_example
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity: FlutterActivity() {
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
PODS:
|
||||
- flowy_infra_ui (0.0.1):
|
||||
- Flutter
|
||||
- Flutter (1.0.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- flowy_infra_ui (from `.symlinks/plugins/flowy_infra_ui/ios`)
|
||||
- Flutter (from `Flutter`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
flowy_infra_ui:
|
||||
:path: ".symlinks/plugins/flowy_infra_ui/ios"
|
||||
Flutter:
|
||||
:path: Flutter
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
flowy_infra_ui: 146c88346fd55d2ee6a41ae35059a5bf095cfbb3
|
||||
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
|
||||
|
||||
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
|
||||
|
||||
COCOAPODS: 1.9.3
|
@ -9,7 +9,6 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
73D88840D6ADB1B9C000C539 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA749E34E8D549849F119B5B /* Pods_Runner.framework */; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
@ -33,7 +32,6 @@
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
3CA8F348EBCAB0B9417EC70D /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
@ -44,9 +42,6 @@
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
BD462F555277405D97D69F24 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
|
||||
C010FCE60C748638851A2DFA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
CA749E34E8D549849F119B5B /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -54,32 +49,12 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
73D88840D6ADB1B9C000C539 /* Pods_Runner.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
2A04BAC54BC6D85A998F0000 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CA749E34E8D549849F119B5B /* Pods_Runner.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8F8024933033E730415889FC /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C010FCE60C748638851A2DFA /* Pods-Runner.debug.xcconfig */,
|
||||
BD462F555277405D97D69F24 /* Pods-Runner.release.xcconfig */,
|
||||
3CA8F348EBCAB0B9417EC70D /* Pods-Runner.profile.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -97,8 +72,6 @@
|
||||
9740EEB11CF90186004384FC /* Flutter */,
|
||||
97C146F01CF9000F007C117D /* Runner */,
|
||||
97C146EF1CF9000F007C117D /* Products */,
|
||||
8F8024933033E730415889FC /* Pods */,
|
||||
2A04BAC54BC6D85A998F0000 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
@ -132,14 +105,12 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
|
||||
buildPhases = (
|
||||
653DE1EFE700467C4AF71781 /* [CP] Check Pods Manifest.lock */,
|
||||
9740EEB61CF901F6004384FC /* Run Script */,
|
||||
97C146EA1CF9000F007C117D /* Sources */,
|
||||
97C146EB1CF9000F007C117D /* Frameworks */,
|
||||
97C146EC1CF9000F007C117D /* Resources */,
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||
C71338FE5F010950C936DB01 /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -212,28 +183,6 @@
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
653DE1EFE700467C4AF71781 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -248,24 +197,6 @@
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
|
||||
};
|
||||
C71338FE5F010950C936DB01 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/flowy_infra_ui/flowy_infra_ui.framework",
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flowy_infra_ui.framework",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
|
@ -4,7 +4,4 @@
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:flowy_infra_ui/flowy_infra_ui_web.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../home/demo_item.dart';
|
||||
|
||||
@ -25,21 +26,33 @@ class KeyboardScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _KeyboardScreenState extends State<KeyboardScreen> {
|
||||
bool _isKeyboardVisible = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Keyboard Visibility Demo'),
|
||||
),
|
||||
body: GestureDetector(
|
||||
onTap: () => _dismissKeyboard(context),
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 36),
|
||||
child: Center(
|
||||
child: TextField(
|
||||
style: const TextStyle(fontSize: 20),
|
||||
controller: TextEditingController(text: 'Test'),
|
||||
body: KeyboardVisibilityDetector(
|
||||
onKeyboardVisibilityChange: (isKeyboardVisible) {
|
||||
setState(() => _isKeyboardVisible = isKeyboardVisible);
|
||||
},
|
||||
child: GestureDetector(
|
||||
onTap: () => _dismissKeyboard(context),
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 36),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Text('Keyboard Visible: $_isKeyboardVisible'),
|
||||
TextField(
|
||||
style: const TextStyle(fontSize: 20),
|
||||
controller: TextEditingController(text: 'Test'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -199,7 +199,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
provider:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: provider
|
||||
url: "https://pub.dartlang.org"
|
||||
|
@ -13,8 +13,11 @@ dependencies:
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
cupertino_icons: ^1.0.2
|
||||
<<<<<<< HEAD
|
||||
provider: ^5.0.0
|
||||
>>>>>>> [infra_ui][keyboard] (WIP) Add demo proj for infra ui
|
||||
=======
|
||||
>>>>>>> [infra_ui] Integrate keyboard detector to example proj
|
||||
flowy_infra_ui:
|
||||
path: ../
|
||||
|
||||
|
@ -18,12 +18,7 @@ void main() {
|
||||
// Verify that platform version is retrieved.
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
<<<<<<< HEAD
|
||||
(Widget widget) =>
|
||||
widget is Text && widget.data!.startsWith('Running on:'),
|
||||
=======
|
||||
(Widget widget) => widget is Text && widget.data!.startsWith('Running on:'),
|
||||
>>>>>>> [infra_ui][keyboard] Bump infra_ui to 1.20.0 and fix compiling issues
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
@ -3,7 +3,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import '../flowy_infra_ui_platform_interface.dart';
|
||||
|
||||
// ignore: constant_identifier_names
|
||||
// ignore_for_file: 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';
|
||||
|
@ -1,5 +1,6 @@
|
||||
library flowy_infra_ui_web;
|
||||
|
||||
import 'dart:html' as html show window;
|
||||
import 'package:flowy_infra_ui_platform_interface/flowy_infra_ui_platform_interface.dart';
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
|
||||
@ -18,6 +19,7 @@ class FlowyInfraUIPlugin extends FlowyInfraUIPlatform {
|
||||
|
||||
@override
|
||||
Future<String?> getPlatformVersion() async {
|
||||
return 'Web: unknow version';
|
||||
final version = html.window.navigator.userAgent;
|
||||
return Future.value(version);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface FlowyInfraUIPlugin : NSObject<FlutterPlugin>
|
||||
@end
|
@ -1,4 +1,4 @@
|
||||
#import "FlowyInfraUiPlugin.h"
|
||||
#import "FlowyInfraUIPlugin.h"
|
||||
#if __has_include(<flowy_infra_ui/flowy_infra_ui-Swift.h>)
|
||||
#import <flowy_infra_ui/flowy_infra_ui-Swift.h>
|
||||
#else
|
||||
@ -8,8 +8,8 @@
|
||||
#import "flowy_infra_ui-Swift.h"
|
||||
#endif
|
||||
|
||||
@implementation FlowyInfraUiPlugin
|
||||
@implementation FlowyInfraUIPlugin
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
||||
[SwiftFlowyInfraUiPlugin registerWithRegistrar:registrar];
|
||||
[SwiftFlowyInfraUIPlugin registerWithRegistrar:registrar];
|
||||
}
|
||||
@end
|
@ -1,4 +0,0 @@
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface FlowyInfraUiPlugin : NSObject<FlutterPlugin>
|
||||
@end
|
@ -1,7 +1,7 @@
|
||||
import Flutter
|
||||
import UIKit
|
||||
|
||||
public class SwiftFlowyInfraUiPlugin: NSObject, FlutterPlugin {
|
||||
public class SwiftFlowyInfraUIPlugin: NSObject, FlutterPlugin {
|
||||
|
||||
enum Constant {
|
||||
static let infraUIMethodChannelName = "flowy_infra_ui_method"
|
||||
@ -11,7 +11,7 @@ public class SwiftFlowyInfraUiPlugin: NSObject, FlutterPlugin {
|
||||
}
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let instance = SwiftFlowyInfraUiPlugin()
|
||||
let instance = SwiftFlowyInfraUIPlugin()
|
||||
|
||||
let methodChannel = FlutterMethodChannel(
|
||||
name: Constant.infraUIMethodChannelName,
|
@ -1,13 +1,2 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class FlowyInfraUi {
|
||||
static const MethodChannel _channel = MethodChannel('flowy_infra_ui');
|
||||
|
||||
static Future<String?> get platformVersion async {
|
||||
final String? version = await _channel.invokeMethod('getPlatformVersion');
|
||||
return version;
|
||||
}
|
||||
}
|
||||
// Keyboard
|
||||
export 'src/keyboard/keyboard_visibility_detector.dart';
|
||||
|
@ -1,44 +1,2 @@
|
||||
import 'dart:async';
|
||||
// In order to *not* need this ignore, consider extracting the "web" version
|
||||
// of your plugin as a separate package, instead of inlining it in the same
|
||||
// package as the core of your plugin.
|
||||
// ignore: avoid_web_libraries_in_flutter
|
||||
import 'dart:html' as html show window;
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
|
||||
/// A web implementation of the FlowyInfraUi plugin.
|
||||
class FlowyInfraUiWeb {
|
||||
static void registerWith(Registrar registrar) {
|
||||
final MethodChannel channel = MethodChannel(
|
||||
'flowy_infra_ui',
|
||||
const StandardMethodCodec(),
|
||||
registrar,
|
||||
);
|
||||
|
||||
final pluginInstance = FlowyInfraUiWeb();
|
||||
channel.setMethodCallHandler(pluginInstance.handleMethodCall);
|
||||
}
|
||||
|
||||
/// Handles method calls over the MethodChannel of this plugin.
|
||||
/// Note: Check the "federated" architecture for a new way of doing this:
|
||||
/// https://flutter.dev/go/federated-plugins
|
||||
Future<dynamic> handleMethodCall(MethodCall call) async {
|
||||
switch (call.method) {
|
||||
case 'getPlatformVersion':
|
||||
return getPlatformVersion();
|
||||
default:
|
||||
throw PlatformException(
|
||||
code: 'Unimplemented',
|
||||
details: 'flowy_infra_ui for web doesn\'t implement \'${call.method}\'',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a [String] containing the version of the platform.
|
||||
Future<String> getPlatformVersion() {
|
||||
final version = html.window.navigator.userAgent;
|
||||
return Future.value(version);
|
||||
}
|
||||
}
|
||||
// Keyboard
|
||||
export 'src/keyboard/keyboard_visibility_detector.dart';
|
||||
|
@ -0,0 +1,73 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flowy_infra_ui_platform_interface/flowy_infra_ui_platform_interface.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class KeyboardVisibilityDetector extends StatefulWidget {
|
||||
const KeyboardVisibilityDetector({
|
||||
Key? key,
|
||||
required this.child,
|
||||
this.onKeyboardVisibilityChange,
|
||||
}) : super(key: key);
|
||||
|
||||
final Widget child;
|
||||
final void Function(bool)? onKeyboardVisibilityChange;
|
||||
|
||||
static bool isKeyboardVisible(BuildContext context) {
|
||||
return context.read<_KeyboardVisibilityDetectorInheritedWidget>().isKeyboardVisible;
|
||||
}
|
||||
|
||||
@override
|
||||
_KeyboardVisibilityDetectorState createState() => _KeyboardVisibilityDetectorState();
|
||||
}
|
||||
|
||||
class _KeyboardVisibilityDetectorState extends State<KeyboardVisibilityDetector> {
|
||||
FlowyInfraUIPlatform get _platform => FlowyInfraUIPlatform.instance;
|
||||
|
||||
bool isObserving = false;
|
||||
bool isKeyboardVisible = false;
|
||||
late StreamSubscription _keyboardSubscription;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_keyboardSubscription = _platform.onKeyboardVisibilityChange.listen((newValue) {
|
||||
setState(() {
|
||||
isKeyboardVisible = newValue;
|
||||
if (widget.onKeyboardVisibilityChange != null) {
|
||||
widget.onKeyboardVisibilityChange!(newValue);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_keyboardSubscription.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _KeyboardVisibilityDetectorInheritedWidget(
|
||||
isKeyboardVisible: isKeyboardVisible,
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _KeyboardVisibilityDetectorInheritedWidget extends InheritedWidget {
|
||||
const _KeyboardVisibilityDetectorInheritedWidget({
|
||||
Key? key,
|
||||
required this.isKeyboardVisible,
|
||||
required Widget child,
|
||||
}) : super(key: key, child: child);
|
||||
|
||||
final bool isKeyboardVisible;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(_KeyboardVisibilityDetectorInheritedWidget oldWidget) {
|
||||
return isKeyboardVisible != oldWidget.isKeyboardVisible;
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
import Cocoa
|
||||
import FlutterMacOS
|
||||
|
||||
public class FlowyInfraUiPlugin: NSObject, FlutterPlugin {
|
||||
public class FlowyInfraUIPlugin: NSObject, FlutterPlugin {
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let channel = FlutterMethodChannel(name: "flowy_infra_ui", binaryMessenger: registrar.messenger)
|
||||
let instance = FlowyInfraUiPlugin()
|
||||
let instance = FlowyInfraUIPlugin()
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
library keyboard_web;
|
||||
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
import 'package:keyboard_platform_interface/keyboard_platform_interface.dart';
|
||||
|
||||
class KeyboardPlugin extends KeyboardPlatform {
|
||||
static void registerWith(Registrar registrar) {
|
||||
KeyboardPlatform.instance = KeyboardPlugin();
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<bool> get onKeyboardChange async* {
|
||||
// suppose that keyboard won't show in web side
|
||||
yield false;
|
||||
}
|
||||
}
|
@ -16,13 +16,13 @@
|
||||
|
||||
namespace {
|
||||
|
||||
class FlowyInfraUiPlugin : public flutter::Plugin {
|
||||
class FlowyInfraUIPlugin : public flutter::Plugin {
|
||||
public:
|
||||
static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar);
|
||||
|
||||
FlowyInfraUiPlugin();
|
||||
FlowyInfraUIPlugin();
|
||||
|
||||
virtual ~FlowyInfraUiPlugin();
|
||||
virtual ~FlowyInfraUIPlugin();
|
||||
|
||||
private:
|
||||
// Called when a method is called on this plugin's channel from Dart.
|
||||
@ -32,14 +32,14 @@ class FlowyInfraUiPlugin : public flutter::Plugin {
|
||||
};
|
||||
|
||||
// static
|
||||
void FlowyInfraUiPlugin::RegisterWithRegistrar(
|
||||
void FlowyInfraUIPlugin::RegisterWithRegistrar(
|
||||
flutter::PluginRegistrarWindows *registrar) {
|
||||
auto channel =
|
||||
std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
|
||||
registrar->messenger(), "flowy_infra_ui",
|
||||
&flutter::StandardMethodCodec::GetInstance());
|
||||
|
||||
auto plugin = std::make_unique<FlowyInfraUiPlugin>();
|
||||
auto plugin = std::make_unique<FlowyInfraUIPlugin>();
|
||||
|
||||
channel->SetMethodCallHandler(
|
||||
[plugin_pointer = plugin.get()](const auto &call, auto result) {
|
||||
@ -49,11 +49,11 @@ void FlowyInfraUiPlugin::RegisterWithRegistrar(
|
||||
registrar->AddPlugin(std::move(plugin));
|
||||
}
|
||||
|
||||
FlowyInfraUiPlugin::FlowyInfraUiPlugin() {}
|
||||
FlowyInfraUIPlugin::FlowyInfraUIPlugin() {}
|
||||
|
||||
FlowyInfraUiPlugin::~FlowyInfraUiPlugin() {}
|
||||
FlowyInfraUIPlugin::~FlowyInfraUIPlugin() {}
|
||||
|
||||
void FlowyInfraUiPlugin::HandleMethodCall(
|
||||
void FlowyInfraUIPlugin::HandleMethodCall(
|
||||
const flutter::MethodCall<flutter::EncodableValue> &method_call,
|
||||
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
|
||||
if (method_call.method_name().compare("getPlatformVersion") == 0) {
|
||||
@ -74,9 +74,9 @@ void FlowyInfraUiPlugin::HandleMethodCall(
|
||||
|
||||
} // namespace
|
||||
|
||||
void FlowyInfraUiPluginRegisterWithRegistrar(
|
||||
void FlowyInfraUIPluginRegisterWithRegistrar(
|
||||
FlutterDesktopPluginRegistrarRef registrar) {
|
||||
FlowyInfraUiPlugin::RegisterWithRegistrar(
|
||||
FlowyInfraUIPlugin::RegisterWithRegistrar(
|
||||
flutter::PluginRegistrarManager::GetInstance()
|
||||
->GetRegistrar<flutter::PluginRegistrarWindows>(registrar));
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void FlowyInfraUiPluginRegisterWithRegistrar(
|
||||
FLUTTER_PLUGIN_EXPORT void FlowyInfraUIPluginRegisterWithRegistrar(
|
||||
FlutterDesktopPluginRegistrarRef registrar);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
Loading…
Reference in New Issue
Block a user