-
Notifications
You must be signed in to change notification settings - Fork 52
[keyboard_detection_tizen] Introduce keyboard_detection_tizen #1020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Miscellaneous | ||
| *.class | ||
| *.log | ||
| *.pyc | ||
| *.swp | ||
| .DS_Store | ||
| .atom/ | ||
| .buildlog/ | ||
| .history | ||
| .svn/ | ||
|
|
||
| # IntelliJ related | ||
| *.iml | ||
| *.ipr | ||
| *.iws | ||
| .idea/ | ||
|
|
||
| # Flutter/Dart/Pub related | ||
| **/doc/api/ | ||
| .dart_tool/ | ||
| .flutter-plugins | ||
| .flutter-plugins-dependencies | ||
| .packages | ||
| .pub-cache/ | ||
| .pub/ | ||
| build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 0.1.0 | ||
|
|
||
| * Initial release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Copyright (c) 2026 Samsung Electronics Co., Ltd. All rights reserved. | ||
|
|
||
| Redistribution and use in source and binary forms, with or without modification, | ||
| are permitted provided that the following conditions are met: | ||
|
|
||
| * Redistributions of source code must retain the above copyright | ||
| notice, this list of conditions and the following disclaimer. | ||
| * Redistributions in binary form must reproduce the above | ||
| copyright notice, this list of conditions and the following | ||
| disclaimer in the documentation and/or other materials provided | ||
| with the distribution. | ||
| * Neither the name of the copyright holder nor the names of the | ||
| contributors may be used to endorse or promote products derived | ||
| from this software without specific prior written permission. | ||
|
|
||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
| ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
| ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # keyboard_detection_tizen | ||
|
|
||
| A Tizen-specific Flutter plugin that detects software keyboard (input panel) | ||
| visibility and size on Tizen devices. The public API mirrors the | ||
| [`keyboard_detection`](https://pub.dev/packages/keyboard_detection) package. | ||
|
|
||
| The original `keyboard_detection` package detects keyboard visibility from | ||
| `MediaQuery.viewInsets.bottom`, which is not populated on Tizen. This plugin | ||
| listens to the `tizen/internal/inputpanel` event channel exposed by the | ||
| flutter-tizen embedder instead, and reads the keyboard geometry (height, | ||
| width, position) from the same channel. | ||
|
|
||
| > **Warning** | ||
| > Requires flutter-tizen `3.41.9-tizen.1.0.0` or later. Earlier versions | ||
| > of the embedder do not publish geometry on the | ||
| > `tizen/internal/inputpanel` channel, so the controller will stay in | ||
| > `KeyboardState.unknown`. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```yaml | ||
| dependencies: | ||
| keyboard_detection_tizen: ^0.1.0 | ||
| ``` | ||
|
|
||
| ```dart | ||
| import 'package:keyboard_detection_tizen/keyboard_detection_tizen.dart'; | ||
|
|
||
| final controller = KeyboardDetectionController( | ||
| onChanged: (state) => debugPrint('keyboard: $state'), | ||
| ); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| body: Column( | ||
| children: [ | ||
| const TextField(), | ||
| StreamBuilder<KeyboardState>( | ||
| stream: controller.stream, | ||
| builder: (_, snapshot) => Text( | ||
| 'state: ${snapshot.data ?? KeyboardState.unknown} ' | ||
| 'size: ${controller.size}', | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ## Limitations | ||
|
|
||
| - The Tizen input panel channel emits `show` / `hide` / `will_show` only. | ||
| `KeyboardState.hiding` is therefore never reached on Tizen. | ||
| - Geometry values are physical pixels reported by `ecore_imf`. Convert with | ||
| `MediaQueryData.devicePixelRatio` if you need logical pixels. | ||
| - Floating / split keyboards are not supported. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Miscellaneous | ||
| *.class | ||
| *.log | ||
| *.pyc | ||
| *.swp | ||
| .DS_Store | ||
| .atom/ | ||
| .buildlog/ | ||
| .history | ||
| .svn/ | ||
|
|
||
| # IntelliJ related | ||
| *.iml | ||
| *.ipr | ||
| *.iws | ||
| .idea/ | ||
|
|
||
| # Flutter/Dart/Pub related | ||
| **/doc/api/ | ||
| .dart_tool/ | ||
| .flutter-plugins | ||
| .flutter-plugins-dependencies | ||
| .packages | ||
| .pub-cache/ | ||
| .pub/ | ||
| /build/ | ||
|
|
||
| # Symbolication related | ||
| app.*.symbols | ||
|
|
||
| # Obfuscation related | ||
| app.*.map.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # keyboard_detection_tizen_example | ||
|
|
||
| Demonstrates how to use the `keyboard_detection_tizen` plugin. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen). |
46 changes: 46 additions & 0 deletions
46
...ages/keyboard_detection_tizen/example/integration_test/keyboard_detection_tizen_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:integration_test/integration_test.dart'; | ||
| import 'package:keyboard_detection_tizen/keyboard_detection_tizen.dart'; | ||
|
|
||
| void main() { | ||
| IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
|
||
| const String channelName = 'tizen/internal/inputpanel'; | ||
| const StandardMethodCodec codec = StandardMethodCodec(); | ||
|
|
||
| Future<void> emit(WidgetTester tester, Map<String, Object?> payload) async { | ||
| final ByteData data = codec.encodeSuccessEnvelope(payload); | ||
| await tester.binding.defaultBinaryMessenger.handlePlatformMessage( | ||
| channelName, | ||
| data, | ||
| (_) {}, | ||
| ); | ||
| } | ||
|
|
||
| testWidgets('reports visible on show event', (WidgetTester tester) async { | ||
| final KeyboardDetectionController controller = | ||
| KeyboardDetectionController(); | ||
| await emit(tester, <String, Object?>{'state': 'show'}); | ||
| await tester.pump(); | ||
| expect(controller.state, KeyboardState.visible); | ||
| expect(controller.stateAsBool(), isTrue); | ||
| await controller.dispose(); | ||
| }); | ||
|
|
||
| testWidgets('reports hidden on hide event', (WidgetTester tester) async { | ||
| final KeyboardDetectionController controller = | ||
| KeyboardDetectionController(); | ||
| await emit(tester, <String, Object?>{'state': 'show'}); | ||
| await tester.pump(); | ||
| await emit(tester, <String, Object?>{'state': 'hide'}); | ||
| await tester.pump(); | ||
| expect(controller.state, KeyboardState.hidden); | ||
| expect(controller.stateAsBool(), isFalse); | ||
| await controller.dispose(); | ||
| }); | ||
| } |
110 changes: 110 additions & 0 deletions
110
packages/keyboard_detection_tizen/example/lib/main.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // Copyright 2026 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| // ignore_for_file: public_member_api_docs | ||
|
|
||
| import 'package:flutter/material.dart'; | ||
| import 'package:keyboard_detection_tizen/keyboard_detection_tizen.dart'; | ||
|
|
||
| void main() { | ||
| runApp(const MyApp()); | ||
| } | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| const MyApp({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MaterialApp( | ||
| title: 'keyboard_detection_tizen example', | ||
| theme: ThemeData(primarySwatch: Colors.blue), | ||
| home: const HomePage(), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class HomePage extends StatefulWidget { | ||
| const HomePage({super.key}); | ||
|
|
||
| @override | ||
| State<HomePage> createState() => _HomePageState(); | ||
| } | ||
|
|
||
| class _HomePageState extends State<HomePage> { | ||
| late final KeyboardDetectionController _controller; | ||
|
|
||
| @override | ||
| void initState() { | ||
| super.initState(); | ||
| _controller = KeyboardDetectionController( | ||
| onChanged: (KeyboardState state) { | ||
| debugPrint('keyboard_detection_tizen: $state'); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| @override | ||
| void dispose() { | ||
| _controller.dispose(); | ||
| super.dispose(); | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| appBar: AppBar(title: const Text('Keyboard Detection')), | ||
| body: SafeArea( | ||
| child: Padding( | ||
| padding: const EdgeInsets.all(24), | ||
| child: Column( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: <Widget>[ | ||
| StreamBuilder<KeyboardState>( | ||
| stream: _controller.stream, | ||
| initialData: _controller.state, | ||
| builder: (BuildContext _, AsyncSnapshot<KeyboardState> snap) { | ||
| final KeyboardState s = snap.data ?? KeyboardState.unknown; | ||
| return Column( | ||
| key: const Key('status'), | ||
| children: <Widget>[ | ||
| Text( | ||
| 'state: ${s.name}', | ||
| key: const Key('state-text'), | ||
| style: Theme.of(context).textTheme.titleMedium, | ||
| ), | ||
| const SizedBox(height: 8), | ||
| Text( | ||
| 'visible: ${_controller.stateAsBool() ?? "unknown"}', | ||
| key: const Key('visible-text'), | ||
| ), | ||
| const SizedBox(height: 8), | ||
| Text( | ||
| 'width: ${_controller.width.toStringAsFixed(1)} ' | ||
| '/ size(height): ${_controller.size.toStringAsFixed(1)} ', | ||
| key: const Key('size-text'), | ||
| ), | ||
| const SizedBox(height: 8), | ||
| Text( | ||
| 'position: ' | ||
| '(${_controller.position.dx.toStringAsFixed(1)}, ' | ||
| '${_controller.position.dy.toStringAsFixed(1)})', | ||
| key: const Key('position-text'), | ||
| ), | ||
| ], | ||
| ); | ||
| }, | ||
| ), | ||
| const SizedBox(height: 32), | ||
| const TextField( | ||
| decoration: InputDecoration( | ||
| labelText: 'Tap here to open keyboard', | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: keyboard_detection_tizen_example | ||
| description: Demonstrates how to use the keyboard_detection_tizen plugin. | ||
| publish_to: "none" | ||
|
|
||
| environment: | ||
| sdk: ">=3.1.0 <4.0.0" | ||
| flutter: ">=3.13.0" | ||
|
|
||
| dependencies: | ||
| flutter: | ||
| sdk: flutter | ||
| keyboard_detection_tizen: | ||
| path: ../ | ||
|
|
||
| dev_dependencies: | ||
| flutter_driver: | ||
| sdk: flutter | ||
| flutter_test: | ||
| sdk: flutter | ||
| integration_test: | ||
| sdk: flutter | ||
| integration_test_tizen: | ||
| path: ../../integration_test/ | ||
|
|
||
| flutter: | ||
| uses-material-design: true |
3 changes: 3 additions & 0 deletions
3
packages/keyboard_detection_tizen/example/test_driver/integration_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import 'package:integration_test/integration_test_driver.dart'; | ||
|
|
||
| Future<void> main() => integrationDriver(); |
12 changes: 12 additions & 0 deletions
12
packages/keyboard_detection_tizen/example/tizen/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| flutter/ | ||
| .vs/ | ||
| *.user | ||
| bin/ | ||
| obj/ | ||
|
|
||
| # Tizen Core CLI (tz) related files | ||
| tizen_dotnet_project.yaml | ||
| *.csproj.backup | ||
|
|
||
| # Flutter-tizen dependency information file | ||
| .app.deps.json |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.