Skip to content
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

[SuperKeyboard] - Created a keyboard plugin #2474

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/pr_validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,47 @@ jobs:
# Run all tests
- run: flutter test

analyze_super_keyboard:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./super_keyboard
steps:
# Checkout the PR branch
- uses: actions/checkout@v3

# Setup Flutter environment
- uses: subosito/flutter-action@v2
with:
channel: "master"

# Download all the packages that the app uses
- run: flutter pub get

# Enforce static analysis
- run: flutter analyze

test_super_keyboard:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./super_keyboard
steps:
# Checkout the PR branch
- uses: actions/checkout@v3

# Setup Flutter environment
- uses: subosito/flutter-action@v2
with:
channel: "master"

# Download all the packages that the app uses
- run: flutter pub get

# Run all tests
- run: flutter test


analyze_super_text_layout:
runs-on: ubuntu-latest
defaults:
Expand Down
29 changes: 29 additions & 0 deletions super_keyboard/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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/
build/
36 changes: 36 additions & 0 deletions super_keyboard/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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 and should not be manually edited.

version:
revision: "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819"
channel: "[user-branch]"

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: android
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: ios
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: web
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819

# 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'
4 changes: 4 additions & 0 deletions super_keyboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## [0.1.0] - [DATE]
Initial release:
* iOS: Reports keyboard closed, opening, open, and closing. No keyboard height.
* Android: Reports keyboard closed, opening, open, and closing, as well as keyboard height.
7 changes: 7 additions & 0 deletions super_keyboard/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2021 Superlist, SuperDeclarative! and the contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
57 changes: 57 additions & 0 deletions super_keyboard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Super Keyboard
A plugin that reports keyboard visibility and size.

## Support Platforms
This plugin supports iOS and Android.

## Unified API
For users that don't care about differences between how iOS and Android report
keyboard information, the easiest way to use `super_keyboard` is through the
unified (lowest common denominator) API.

Build a widget subtree based on the keyboard state:
```dart
@override
Widget build(BuildContext context) {
return SuperKeyboardBuilder(
builder: (context, keyboardState) {
// TODO: do something with the keyboard state.
return const SizedBox();
}
);
}
```

Directly listen for changes to the keyboard state:
```dart
void startListeningToKeyboardState() {
SuperKeyboard.instance.state.addListener(_onKeyboardStateChange);
}

void stopListeningToKeyboardState() {
SuperKeyboard.instance.state.removeListener(_onKeyboardStateChange);
}

void _onKeyboardStateChange(KeyboardState newState) {
// TODO: do something with the new keyboard state.
}
```

Activate logs:
```dart
SuperKeyboard.initLogs();
```

## iOS and Android
Platform-specific APIs are also available. The unified `SuperKeyboard` API
delegates to the platform-specific APIs under the hood.

iOS is available in `SuperKeyboardIOS`.

Android is available in `SuperKeyboardAndroid`.

Per-platform APIs are made available because each platform reports keyboard
state and height in different ways. Those reporting methods may, or may not
be compatible with each in general. Also, one platform might report more
keyboard information than the other. We want to provide the maximum information
possible to users, which can't be done with a lowest common denominator API.
4 changes: 4 additions & 0 deletions super_keyboard/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
9 changes: 9 additions & 0 deletions super_keyboard/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.cxx
68 changes: 68 additions & 0 deletions super_keyboard/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
group = "com.flutterbountyhunters.superkeyboard.super_keyboard"
version = "1.0-SNAPSHOT"

buildscript {
ext.kotlin_version = "1.7.10"
repositories {
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:7.3.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"

android {
if (project.android.hasProperty("namespace")) {
namespace = "com.flutterbountyhunters.superkeyboard.super_keyboard"
}

compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}

sourceSets {
main.java.srcDirs += "src/main/kotlin"
test.java.srcDirs += "src/test/kotlin"
}

defaultConfig {
minSdk = 21
}

dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.mockito:mockito-core:5.0.0")
}

testOptions {
unitTests.all {
useJUnitPlatform()

testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}
1 change: 1 addition & 0 deletions super_keyboard/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'super_keyboard'
3 changes: 3 additions & 0 deletions super_keyboard/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flutterbountyhunters.superkeyboard.super_keyboard">
</manifest>
Loading
Loading