24 changed files with 711 additions and 19 deletions
@ -0,0 +1,53 @@ |
|||||||
|
/* |
||||||
|
* Copyright (c) 2023. Open Mobile Platform LLC. |
||||||
|
* License: Proprietary. |
||||||
|
*/ |
||||||
|
import 'package:flutter/widgets.dart'; |
||||||
|
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; |
||||||
|
import 'package:flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora.dart'; |
||||||
|
import 'package:scoped_model/scoped_model.dart'; |
||||||
|
|
||||||
|
/// Model for [FlutterKeyboardVisibilityPage] |
||||||
|
class FlutterKeyboardVisibilityModel extends Model { |
||||||
|
/// Get [ScopedModel] |
||||||
|
static FlutterKeyboardVisibilityModel of(BuildContext context) => |
||||||
|
ScopedModel.of<FlutterKeyboardVisibilityModel>(context); |
||||||
|
|
||||||
|
final _controller = KeyboardVisibilityController(); |
||||||
|
final _controllerAurora = FlutterKeyboardVisibilityAurora(); |
||||||
|
|
||||||
|
/// Error |
||||||
|
String? _error; |
||||||
|
|
||||||
|
/// Public error |
||||||
|
String? get error => _error; |
||||||
|
|
||||||
|
/// Public is error |
||||||
|
bool get isError => _error != null; |
||||||
|
|
||||||
|
/// Stream change visibility |
||||||
|
Stream<bool> onChangeKeyboard() async* { |
||||||
|
try { |
||||||
|
yield _controller.isVisible; |
||||||
|
await for (final state in _controller.onChange) { |
||||||
|
yield state; |
||||||
|
} |
||||||
|
} catch (e) { |
||||||
|
_error = e.toString(); |
||||||
|
notifyListeners(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// Stream change height |
||||||
|
Stream<double> onChangeKeyboardHeight() async* { |
||||||
|
try { |
||||||
|
yield await _controllerAurora.height; |
||||||
|
await for (final state in _controllerAurora.onChangeHeight) { |
||||||
|
yield state; |
||||||
|
} |
||||||
|
} catch (e) { |
||||||
|
_error = e.toString(); |
||||||
|
notifyListeners(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
/* |
||||||
|
* Copyright (c) 2023. Open Mobile Platform LLC. |
||||||
|
* License: Proprietary. |
||||||
|
*/ |
||||||
|
import 'package:flutter_example_packages/base/package/package_page.dart'; |
||||||
|
import 'package:get_it/get_it.dart'; |
||||||
|
|
||||||
|
import 'page.dart'; |
||||||
|
import 'model.dart'; |
||||||
|
|
||||||
|
/// Package values |
||||||
|
final packageFlutterKeyboardVisibility = PackagePage( |
||||||
|
key: 'flutter_keyboard_visibility', |
||||||
|
descEN: ''' |
||||||
|
React to keyboard visibility changes. |
||||||
|
''', |
||||||
|
descRU: ''' |
||||||
|
Реагировать на изменения видимости клавиатуры. |
||||||
|
''', |
||||||
|
version: '5.4.1', |
||||||
|
isPlatformDependent: true, |
||||||
|
page: () => FlutterKeyboardVisibilityPage(), |
||||||
|
init: () { |
||||||
|
GetIt.instance.registerFactory<FlutterKeyboardVisibilityModel>( |
||||||
|
() => FlutterKeyboardVisibilityModel()); |
||||||
|
}, |
||||||
|
); |
@ -0,0 +1,108 @@ |
|||||||
|
/* |
||||||
|
* Copyright (c) 2023. Open Mobile Platform LLC. |
||||||
|
* License: Proprietary. |
||||||
|
*/ |
||||||
|
import 'package:flutter/material.dart'; |
||||||
|
import 'package:flutter_example_packages/base/di/app_di.dart'; |
||||||
|
import 'package:flutter_example_packages/base/package/package.dart'; |
||||||
|
import 'package:flutter_example_packages/packages/flutter_keyboard_visibility/model.dart'; |
||||||
|
import 'package:flutter_example_packages/widgets/base/export.dart'; |
||||||
|
import 'package:flutter_example_packages/widgets/blocks/block_alert.dart'; |
||||||
|
import 'package:flutter_example_packages/widgets/blocks/block_info_package.dart'; |
||||||
|
import 'package:flutter_example_packages/widgets/blocks/block_item.dart'; |
||||||
|
import 'package:flutter_example_packages/widgets/layouts/block_layout.dart'; |
||||||
|
import 'package:flutter_example_packages/widgets/texts/export.dart'; |
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; |
||||||
|
|
||||||
|
import 'package.dart'; |
||||||
|
|
||||||
|
class FlutterKeyboardVisibilityPage extends AppStatefulWidget { |
||||||
|
FlutterKeyboardVisibilityPage({ |
||||||
|
super.key, |
||||||
|
}); |
||||||
|
|
||||||
|
final Package package = packageFlutterKeyboardVisibility; |
||||||
|
|
||||||
|
@override |
||||||
|
State<FlutterKeyboardVisibilityPage> createState() => |
||||||
|
_FlutterKeyboardVisibilityPageState(); |
||||||
|
} |
||||||
|
|
||||||
|
class _FlutterKeyboardVisibilityPageState |
||||||
|
extends AppState<FlutterKeyboardVisibilityPage> { |
||||||
|
double _keyboardHeight = 0; |
||||||
|
final model = getIt<FlutterKeyboardVisibilityModel>(); |
||||||
|
|
||||||
|
@override |
||||||
|
void initState() { |
||||||
|
super.initState(); |
||||||
|
model.onChangeKeyboardHeight().listen((height) { |
||||||
|
setState(() { |
||||||
|
_keyboardHeight = height; |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@override |
||||||
|
Widget buildWide( |
||||||
|
BuildContext context, |
||||||
|
MediaQueryData media, |
||||||
|
AppLocalizations l10n, |
||||||
|
) { |
||||||
|
return BlockLayout<FlutterKeyboardVisibilityModel>( |
||||||
|
model: model, |
||||||
|
title: widget.package.key, |
||||||
|
builder: (context, child, model) { |
||||||
|
return SingleChildScrollView( |
||||||
|
padding: EdgeInsets.only(bottom: _keyboardHeight), |
||||||
|
child: Padding( |
||||||
|
padding: const EdgeInsets.all(20), |
||||||
|
child: Column( |
||||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||||
|
children: [ |
||||||
|
BlockInfoPackage(widget.package), |
||||||
|
BlockAlert(model.error), |
||||||
|
if (!model.isError) |
||||||
|
Column( |
||||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||||
|
children: [ |
||||||
|
TextField( |
||||||
|
decoration: InputDecoration( |
||||||
|
hintText: l10n.flutterKeyboardVisibilityField, |
||||||
|
), |
||||||
|
), |
||||||
|
const SizedBox(height: 20), |
||||||
|
SizedBox( |
||||||
|
width: 140, |
||||||
|
child: ElevatedButton( |
||||||
|
onPressed: () => FocusScope.of(context).unfocus(), |
||||||
|
child: TextBodyLarge( |
||||||
|
l10n.flutterKeyboardVisibilityButton, |
||||||
|
color: Colors.white, |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
const SizedBox(height: 20), |
||||||
|
BlockItem( |
||||||
|
title: l10n.flutterKeyboardVisibilityTitleHeight, |
||||||
|
desc: l10n.flutterKeyboardVisibilityDescHeight, |
||||||
|
value: _keyboardHeight, |
||||||
|
builder: (value) => value.toInt().toString(), |
||||||
|
), |
||||||
|
const SizedBox(height: 20), |
||||||
|
BlockItem( |
||||||
|
title: l10n.flutterKeyboardVisibilityTitle, |
||||||
|
desc: l10n.flutterKeyboardVisibilityDesc, |
||||||
|
stream: model.onChangeKeyboard(), |
||||||
|
builder: (value) => value.toString().toUpperCase(), |
||||||
|
), |
||||||
|
], |
||||||
|
), |
||||||
|
], |
||||||
|
), |
||||||
|
), |
||||||
|
); |
||||||
|
}, |
||||||
|
); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
# Miscellaneous |
||||||
|
*.class |
||||||
|
*.log |
||||||
|
*.pyc |
||||||
|
*.swp |
||||||
|
.DS_Store |
||||||
|
.atom/ |
||||||
|
.buildlog/ |
||||||
|
.history |
||||||
|
.svn/ |
||||||
|
migrate_working_dir/ |
||||||
|
|
||||||
|
# IntelliJ related |
||||||
|
*.iml |
||||||
|
*.ipr |
||||||
|
*.iws |
||||||
|
.idea/ |
||||||
|
|
||||||
|
# The .vscode folder contains launch configuration and tasks you configure in |
||||||
|
# VS Code which you may wish to be included in version control, so this line |
||||||
|
# is commented out by default. |
||||||
|
#.vscode/ |
||||||
|
|
||||||
|
# Flutter/Dart/Pub related |
||||||
|
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. |
||||||
|
/pubspec.lock |
||||||
|
**/doc/api/ |
||||||
|
.dart_tool/ |
||||||
|
.packages |
||||||
|
build/ |
@ -0,0 +1,30 @@ |
|||||||
|
# This file tracks properties of this Flutter project. |
||||||
|
# Used by Flutter tool to assess capabilities and perform upgrades etc. |
||||||
|
# |
||||||
|
# This file should be version controlled. |
||||||
|
|
||||||
|
version: |
||||||
|
revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
channel: aurora |
||||||
|
|
||||||
|
project_type: plugin |
||||||
|
|
||||||
|
# Tracks metadata for the flutter migrate command |
||||||
|
migration: |
||||||
|
platforms: |
||||||
|
- platform: root |
||||||
|
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
- platform: aurora |
||||||
|
create_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
base_revision: 135454af32477f815a7525073027a3ff9eff1bfd |
||||||
|
|
||||||
|
# User provided section |
||||||
|
|
||||||
|
# List of Local paths (relative to this file) that should be |
||||||
|
# ignored by the migrate tool. |
||||||
|
# |
||||||
|
# Files that are not part of the templates will be ignored by default. |
||||||
|
unmanaged_files: |
||||||
|
- 'lib/main.dart' |
||||||
|
- 'ios/Runner.xcodeproj/project.pbxproj' |
@ -0,0 +1,22 @@ |
|||||||
|
{ |
||||||
|
"configurations": [ |
||||||
|
{ |
||||||
|
"name": "Linux", |
||||||
|
"includePath": [ |
||||||
|
"${workspaceFolder}/**", |
||||||
|
"/home/keygenqt/AuroraPlatformSDK/targets/AuroraOS-4.0.2-armv7hl.default/usr/lib", |
||||||
|
"/home/keygenqt/AuroraPlatformSDK/targets/AuroraOS-4.0.2-armv7hl.default/usr/include", |
||||||
|
"/home/keygenqt/AuroraPlatformSDK/targets/AuroraOS-4.0.2-armv7hl.default/usr/include/flutter-embedder", |
||||||
|
"/home/keygenqt/AuroraPlatformSDK/targets/AuroraOS-4.0.2-armv7hl.default/usr/include/flutter-embedder/flutter" |
||||||
|
], |
||||||
|
"defines": [ |
||||||
|
"__ARM_PCS_VFP" |
||||||
|
], |
||||||
|
"compilerPath": "/usr/bin/g++", |
||||||
|
"cStandard": "c17", |
||||||
|
"cppStandard": "c++17", |
||||||
|
"intelliSenseMode": "clang-x64" |
||||||
|
} |
||||||
|
], |
||||||
|
"version": 4 |
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
{ |
||||||
|
"files.associations": { |
||||||
|
"variant": "cpp", |
||||||
|
"array": "cpp", |
||||||
|
"atomic": "cpp", |
||||||
|
"bit": "cpp", |
||||||
|
"*.tcc": "cpp", |
||||||
|
"cctype": "cpp", |
||||||
|
"clocale": "cpp", |
||||||
|
"cmath": "cpp", |
||||||
|
"compare": "cpp", |
||||||
|
"concepts": "cpp", |
||||||
|
"cstdarg": "cpp", |
||||||
|
"cstddef": "cpp", |
||||||
|
"cstdint": "cpp", |
||||||
|
"cstdio": "cpp", |
||||||
|
"cstdlib": "cpp", |
||||||
|
"cwchar": "cpp", |
||||||
|
"cwctype": "cpp", |
||||||
|
"deque": "cpp", |
||||||
|
"list": "cpp", |
||||||
|
"map": "cpp", |
||||||
|
"string": "cpp", |
||||||
|
"unordered_map": "cpp", |
||||||
|
"vector": "cpp", |
||||||
|
"exception": "cpp", |
||||||
|
"algorithm": "cpp", |
||||||
|
"functional": "cpp", |
||||||
|
"iterator": "cpp", |
||||||
|
"memory": "cpp", |
||||||
|
"memory_resource": "cpp", |
||||||
|
"numeric": "cpp", |
||||||
|
"random": "cpp", |
||||||
|
"string_view": "cpp", |
||||||
|
"system_error": "cpp", |
||||||
|
"tuple": "cpp", |
||||||
|
"type_traits": "cpp", |
||||||
|
"utility": "cpp", |
||||||
|
"initializer_list": "cpp", |
||||||
|
"iosfwd": "cpp", |
||||||
|
"iostream": "cpp", |
||||||
|
"istream": "cpp", |
||||||
|
"limits": "cpp", |
||||||
|
"new": "cpp", |
||||||
|
"numbers": "cpp", |
||||||
|
"ostream": "cpp", |
||||||
|
"stdexcept": "cpp", |
||||||
|
"streambuf": "cpp", |
||||||
|
"typeinfo": "cpp", |
||||||
|
"chrono": "cpp", |
||||||
|
"codecvt": "cpp", |
||||||
|
"ctime": "cpp", |
||||||
|
"ratio": "cpp", |
||||||
|
"iomanip": "cpp", |
||||||
|
"semaphore": "cpp", |
||||||
|
"sstream": "cpp", |
||||||
|
"stop_token": "cpp", |
||||||
|
"thread": "cpp" |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
# flutter_keyboard_visibility_aurora |
||||||
|
|
||||||
|
The Aurora implementation of [flutter_keyboard_visibility](https://pub.dev/packages/flutter_keyboard_visibility). |
||||||
|
|
||||||
|
## Usage |
||||||
|
This package is not an _endorsed_ implementation of `flutter_keyboard_visibility`. |
||||||
|
Therefore, you have to include `flutter_local_notifications_aurora` alongside `flutter_keyboard_visibility` as dependencies in your `pubspec.yaml` file. |
||||||
|
|
||||||
|
**pubspec.yaml** |
||||||
|
|
||||||
|
```yaml |
||||||
|
dependencies: |
||||||
|
flutter_keyboard_visibility: 5.4.1 |
||||||
|
flutter_keyboard_visibility_aurora: |
||||||
|
path: # path to folder with plugin |
||||||
|
``` |
||||||
|
|
||||||
|
***.dart** |
||||||
|
|
||||||
|
```dart |
||||||
|
/// Default plugin component |
||||||
|
final _controller = KeyboardVisibilityController(); |
||||||
|
|
||||||
|
/// Custom platform component with keyboard height |
||||||
|
final _controllerAurora = FlutterKeyboardVisibilityAurora(); |
||||||
|
|
||||||
|
/// Stream change visibility |
||||||
|
Stream<bool> onChangeKeyboard() async* { |
||||||
|
yield _controller.isVisible; |
||||||
|
|
||||||
|
await for (final state in _controller.onChange) { |
||||||
|
yield state; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// Stream change height |
||||||
|
Stream<int> onChangeKeyboardHeight() async* { |
||||||
|
yield await _controllerAurora.height; |
||||||
|
|
||||||
|
await for (final state in _controllerAurora.onChangeHeight) { |
||||||
|
yield state; |
||||||
|
} |
||||||
|
} |
||||||
|
``` |
||||||
|
|
@ -0,0 +1 @@ |
|||||||
|
include: package:flutter_lints/flutter.yaml |
@ -0,0 +1,23 @@ |
|||||||
|
cmake_minimum_required(VERSION 3.10) |
||||||
|
|
||||||
|
set(PROJECT_NAME flutter_keyboard_visibility_aurora) |
||||||
|
set(PLUGIN_NAME flutter_keyboard_visibility_aurora_platform_plugin) |
||||||
|
|
||||||
|
project(${PROJECT_NAME} LANGUAGES CXX) |
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17) |
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON) |
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-psabi") |
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3") |
||||||
|
|
||||||
|
find_package(PkgConfig REQUIRED) |
||||||
|
pkg_check_modules(FlutterEmbedder REQUIRED IMPORTED_TARGET flutter-embedder) |
||||||
|
|
||||||
|
add_library(${PLUGIN_NAME} SHARED flutter_keyboard_visibility_aurora_plugin.cpp) |
||||||
|
|
||||||
|
set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) |
||||||
|
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::FlutterEmbedder) |
||||||
|
|
||||||
|
target_include_directories(${PLUGIN_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) |
||||||
|
target_compile_definitions(${PLUGIN_NAME} PRIVATE PLUGIN_IMPL) |
@ -0,0 +1,83 @@ |
|||||||
|
#include <flutter_keyboard_visibility_aurora/flutter_keyboard_visibility_aurora_plugin.h> |
||||||
|
#include <flutter/method-channel.h> |
||||||
|
#include <flutter/platform-events.h> |
||||||
|
#include <flutter/platform-methods.h> |
||||||
|
#include <thread> |
||||||
|
|
||||||
|
FlutterKeyboardVisibilityAuroraPlugin::FlutterKeyboardVisibilityAuroraPlugin() |
||||||
|
{ |
||||||
|
PlatformEvents::SubscribeKeyboardVisibilityChanged( |
||||||
|
[this](bool state) |
||||||
|
{ |
||||||
|
if (this->m_sendEventVisibility) |
||||||
|
{ |
||||||
|
EventChannel("flutter_keyboard_visibility_aurora_state", MethodCodecType::Standard) |
||||||
|
.SendEvent(state); |
||||||
|
} |
||||||
|
|
||||||
|
if (this->m_sendEventHeight) |
||||||
|
{ |
||||||
|
EventChannel("flutter_keyboard_visibility_aurora_height", MethodCodecType::Standard) |
||||||
|
.SendEvent(PlatformMethods::GetKeyboardHeight()); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void FlutterKeyboardVisibilityAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) |
||||||
|
{ |
||||||
|
registrar.RegisterMethodChannel("flutter_keyboard_visibility_aurora", |
||||||
|
MethodCodecType::Standard, |
||||||
|
[this](const MethodCall &call) |
||||||
|
{ this->onMethodCall(call); }); |
||||||
|
|
||||||
|
registrar.RegisterEventChannel( |
||||||
|
"flutter_keyboard_visibility_aurora_state", |
||||||
|
MethodCodecType::Standard, |
||||||
|
[this](const Encodable &) |
||||||
|
{ |
||||||
|
this->m_sendEventVisibility = true; |
||||||
|
return EventResponse(); |
||||||
|
}, |
||||||
|
[this](const Encodable &) |
||||||
|
{ |
||||||
|
this->m_sendEventVisibility = false; |
||||||
|
return EventResponse(); |
||||||
|
}); |
||||||
|
|
||||||
|
registrar.RegisterEventChannel( |
||||||
|
"flutter_keyboard_visibility_aurora_height", |
||||||
|
MethodCodecType::Standard, |
||||||
|
[this](const Encodable &) |
||||||
|
{ |
||||||
|
this->m_sendEventHeight = true; |
||||||
|
return EventResponse(); |
||||||
|
}, |
||||||
|
[this](const Encodable &) |
||||||
|
{ |
||||||
|
this->m_sendEventHeight = false; |
||||||
|
return EventResponse(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void FlutterKeyboardVisibilityAuroraPlugin::onMethodCall(const MethodCall &call) |
||||||
|
{ |
||||||
|
const auto &method = call.GetMethod(); |
||||||
|
|
||||||
|
if (method == "getKeyboardHeight") |
||||||
|
{ |
||||||
|
onGetKeyboardHeight(call); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
unimplemented(call); |
||||||
|
} |
||||||
|
|
||||||
|
void FlutterKeyboardVisibilityAuroraPlugin::onGetKeyboardHeight(const MethodCall &call) |
||||||
|
{ |
||||||
|
call.SendSuccessResponse(PlatformMethods::GetKeyboardHeight()); |
||||||
|
} |
||||||
|
|
||||||
|
void FlutterKeyboardVisibilityAuroraPlugin::unimplemented(const MethodCall &call) |
||||||
|
{ |
||||||
|
call.SendSuccessResponse(nullptr); |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
#ifndef FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_H |
||||||
|
#define FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_H |
||||||
|
|
||||||
|
#include <flutter/plugin-interface.h> |
||||||
|
#include <flutter_keyboard_visibility_aurora/globals.h> |
||||||
|
|
||||||
|
class PLUGIN_EXPORT FlutterKeyboardVisibilityAuroraPlugin final : public PluginInterface |
||||||
|
{ |
||||||
|
public: |
||||||
|
FlutterKeyboardVisibilityAuroraPlugin(); |
||||||
|
void RegisterWithRegistrar(PluginRegistrar ®istrar) override; |
||||||
|
|
||||||
|
private: |
||||||
|
bool m_sendEventVisibility = false; |
||||||
|
bool m_sendEventHeight = false; |
||||||
|
|
||||||
|
void onMethodCall(const MethodCall &call); |
||||||
|
void onGetKeyboardHeight(const MethodCall &call); |
||||||
|
void unimplemented(const MethodCall &call); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif /* FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_H */ |
@ -0,0 +1,10 @@ |
|||||||
|
#ifndef FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_GLOBALS_H |
||||||
|
#define FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_GLOBALS_H |
||||||
|
|
||||||
|
#ifdef PLUGIN_IMPL |
||||||
|
#define PLUGIN_EXPORT __attribute__((visibility("default"))) |
||||||
|
#else |
||||||
|
#define PLUGIN_EXPORT |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* FLUTTER_PLUGIN_FLUTTER_KEYBOARD_VISIBILITY_AURORA_PLUGIN_GLOBALS_H */ |
@ -0,0 +1,26 @@ |
|||||||
|
import 'package:flutter_keyboard_visibility_platform_interface/flutter_keyboard_visibility_platform_interface.dart'; |
||||||
|
|
||||||
|
import 'flutter_keyboard_visibility_aurora_platform_interface.dart'; |
||||||
|
|
||||||
|
class FlutterKeyboardVisibilityAurora |
||||||
|
extends FlutterKeyboardVisibilityPlatform { |
||||||
|
/// Factory method that initializes the FlutterKeyboardVisibility plugin |
||||||
|
/// platform with an instance of the plugin for Aurora OS. |
||||||
|
static void registerWith() { |
||||||
|
FlutterKeyboardVisibilityPlatform.instance = |
||||||
|
FlutterKeyboardVisibilityAurora(); |
||||||
|
} |
||||||
|
|
||||||
|
/// Emits changes to keyboard visibility from the platform. |
||||||
|
@override |
||||||
|
Stream<bool> get onChange => |
||||||
|
FlutterKeyboardVisibilityAuroraPlatform.instance.onChangeVisibility(); |
||||||
|
|
||||||
|
/// Emits changes to keyboard height from the platform. |
||||||
|
Stream<double> get onChangeHeight => |
||||||
|
FlutterKeyboardVisibilityAuroraPlatform.instance.onChangeHeight(); |
||||||
|
|
||||||
|
/// Get keyboard height. |
||||||
|
Future<double> get height => |
||||||
|
FlutterKeyboardVisibilityAuroraPlatform.instance.getKeyboardHeight(); |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
import 'package:flutter/services.dart'; |
||||||
|
|
||||||
|
import 'flutter_keyboard_visibility_aurora_platform_interface.dart'; |
||||||
|
|
||||||
|
/// An implementation of [FlutterKeyboardVisibilityAuroraPlatform] that uses method channels. |
||||||
|
class MethodChannelFlutterKeyboardVisibilityAurora |
||||||
|
extends FlutterKeyboardVisibilityAuroraPlatform { |
||||||
|
final methodChannel = |
||||||
|
const MethodChannel('flutter_keyboard_visibility_aurora'); |
||||||
|
|
||||||
|
@override |
||||||
|
Future<double> getKeyboardHeight() async { |
||||||
|
return await methodChannel.invokeMethod<double>('getKeyboardHeight') ?? 0.0; |
||||||
|
} |
||||||
|
|
||||||
|
@override |
||||||
|
Stream<bool> onChangeVisibility() async* { |
||||||
|
await for (final event |
||||||
|
in const EventChannel('flutter_keyboard_visibility_aurora_state') |
||||||
|
.receiveBroadcastStream()) { |
||||||
|
yield event == true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@override |
||||||
|
Stream<double> onChangeHeight() async* { |
||||||
|
await for (final event |
||||||
|
in const EventChannel('flutter_keyboard_visibility_aurora_height') |
||||||
|
.receiveBroadcastStream()) { |
||||||
|
yield event as double; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; |
||||||
|
|
||||||
|
import 'flutter_keyboard_visibility_aurora_method_channel.dart'; |
||||||
|
|
||||||
|
abstract class FlutterKeyboardVisibilityAuroraPlatform extends PlatformInterface { |
||||||
|
/// Constructs a FlutterKeyboardVisibilityAuroraPlatform. |
||||||
|
FlutterKeyboardVisibilityAuroraPlatform() : super(token: _token); |
||||||
|
|
||||||
|
static final Object _token = Object(); |
||||||
|
|
||||||
|
static FlutterKeyboardVisibilityAuroraPlatform _instance = MethodChannelFlutterKeyboardVisibilityAurora(); |
||||||
|
|
||||||
|
/// The default instance of [FlutterKeyboardVisibilityAuroraPlatform] to use. |
||||||
|
/// |
||||||
|
/// Defaults to [MethodChannelFlutterKeyboardVisibilityAurora]. |
||||||
|
static FlutterKeyboardVisibilityAuroraPlatform get instance => _instance; |
||||||
|
|
||||||
|
/// Platform-specific implementations should set this with their own |
||||||
|
/// platform-specific class that extends [FlutterKeyboardVisibilityAuroraPlatform] when |
||||||
|
/// they register themselves. |
||||||
|
static set instance(FlutterKeyboardVisibilityAuroraPlatform instance) { |
||||||
|
PlatformInterface.verifyToken(instance, _token); |
||||||
|
_instance = instance; |
||||||
|
} |
||||||
|
|
||||||
|
Future<double> getKeyboardHeight() { |
||||||
|
throw UnimplementedError('getKeyboardHeight() has not been implemented.'); |
||||||
|
} |
||||||
|
|
||||||
|
Stream<bool> onChangeVisibility() { |
||||||
|
throw UnimplementedError('onChangeVisibility() has not been implemented.'); |
||||||
|
} |
||||||
|
|
||||||
|
Stream<double> onChangeHeight() { |
||||||
|
throw UnimplementedError('onChangeHeight() has not been implemented.'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
name: flutter_keyboard_visibility_aurora |
||||||
|
description: A new Flutter plugin project. |
||||||
|
version: 0.0.1 |
||||||
|
|
||||||
|
environment: |
||||||
|
sdk: '>=2.18.6 <3.0.0' |
||||||
|
flutter: ">=3.0.0" |
||||||
|
|
||||||
|
dependencies: |
||||||
|
flutter: |
||||||
|
sdk: flutter |
||||||
|
plugin_platform_interface: ^2.0.2 |
||||||
|
flutter_keyboard_visibility_platform_interface: ^2.0.0 |
||||||
|
|
||||||
|
dev_dependencies: |
||||||
|
flutter_test: |
||||||
|
sdk: flutter |
||||||
|
flutter_lints: ^2.0.0 |
||||||
|
|
||||||
|
flutter: |
||||||
|
plugin: |
||||||
|
platforms: |
||||||
|
aurora: |
||||||
|
dartPluginClass: FlutterKeyboardVisibilityAurora |
||||||
|
pluginClass: FlutterKeyboardVisibilityAuroraPlugin |
Loading…
Reference in new issue