-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove device_info_plus and add quill_native_bridge to access …
…platform specific APIs (#2194) * chore(example): update the iOS platform project by Flutter * chore: remove device_info_plus and create quill_native_bridge plugin * chore: add quill_native_bridge from path in pubspec_overrides.yaml.disabled * chore(scripts): add quill_native_bridge in the scripts/packages.dart * ci: add quill_native_bridge in the GitHub workflows * chore: use quill_native_briddge from pub.dev in flutter_quill
- Loading branch information
Showing
25 changed files
with
392 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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
2 changes: 1 addition & 1 deletion
2
example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
This file contains 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 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 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 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 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 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,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/ |
This file contains 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,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 and should not be manually edited. | ||
|
||
version: | ||
revision: "5874a72aa4c779a02553007c47dacbefba2374dc" | ||
channel: "stable" | ||
|
||
project_type: plugin | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc | ||
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc | ||
- platform: ios | ||
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc | ||
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc | ||
|
||
# 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' |
This file contains 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 @@ | ||
## 10.5.14 | ||
|
||
* TODO: This file will be updated soon by GitHub workflow. |
This file contains 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Flutter Quill Team | ||
|
||
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. |
This file contains 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,6 @@ | ||
# 🪶 Quill Native Bridge | ||
|
||
An internal plugin for [`flutter_quill`](https://pub.dev/packages/flutter_quill) package to access platform-specific APIs. | ||
|
||
> [!NOTE] | ||
> **Internal Use Only**: Exclusively for `flutter_quill`. Breaking changes may occur. |
This file contains 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 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
analyzer: | ||
linter: | ||
rules: | ||
always_declare_return_types: true | ||
always_put_required_named_parameters_first: true | ||
annotate_overrides: true | ||
avoid_empty_else: true | ||
avoid_escaping_inner_quotes: true | ||
avoid_print: true | ||
avoid_types_on_closure_parameters: true | ||
avoid_void_async: true | ||
cascade_invocations: true | ||
directives_ordering: true | ||
omit_local_variable_types: true | ||
prefer_const_constructors: true | ||
prefer_const_constructors_in_immutables: true | ||
prefer_const_declarations: true | ||
prefer_final_fields: true | ||
prefer_final_in_for_each: true | ||
prefer_final_locals: true | ||
prefer_initializing_formals: true | ||
prefer_int_literals: true | ||
prefer_interpolation_to_compose_strings: true | ||
prefer_relative_imports: true | ||
prefer_single_quotes: true | ||
sort_constructors_first: true | ||
sort_unnamed_constructors_first: true | ||
unnecessary_lambdas: true | ||
unnecessary_parenthesis: true | ||
unnecessary_string_interpolations: true |
This file contains 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,38 @@ | ||
.idea/ | ||
.vagrant/ | ||
.sconsign.dblite | ||
.svn/ | ||
|
||
.DS_Store | ||
*.swp | ||
profile | ||
|
||
DerivedData/ | ||
build/ | ||
GeneratedPluginRegistrant.h | ||
GeneratedPluginRegistrant.m | ||
|
||
.generated/ | ||
|
||
*.pbxuser | ||
*.mode1v3 | ||
*.mode2v3 | ||
*.perspectivev3 | ||
|
||
!default.pbxuser | ||
!default.mode1v3 | ||
!default.mode2v3 | ||
!default.perspectivev3 | ||
|
||
xcuserdata | ||
|
||
*.moved-aside | ||
|
||
*.pyc | ||
*sync/ | ||
Icon? | ||
.tags* | ||
|
||
/Flutter/Generated.xcconfig | ||
/Flutter/ephemeral/ | ||
/Flutter/flutter_export_environment.sh |
Empty file.
23 changes: 23 additions & 0 deletions
23
quill_native_bridge/ios/Classes/QuillNativeBridgePlugin.swift
This file contains 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,23 @@ | ||
import Flutter | ||
import UIKit | ||
|
||
public class QuillNativeBridgePlugin: NSObject, FlutterPlugin { | ||
public static func register(with registrar: FlutterPluginRegistrar) { | ||
let channel = FlutterMethodChannel(name: "quill_native_bridge", binaryMessenger: registrar.messenger()) | ||
let instance = QuillNativeBridgePlugin() | ||
registrar.addMethodCallDelegate(instance, channel: channel) | ||
} | ||
|
||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { | ||
switch call.method { | ||
case "isIOSSimulator": | ||
#if targetEnvironment(simulator) | ||
result(true) | ||
#else | ||
result(false) | ||
#endif | ||
default: | ||
result(FlutterMethodNotImplemented) | ||
} | ||
} | ||
} |
This file contains 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,29 @@ | ||
# | ||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. | ||
# Run `pod lib lint quill_native_bridge.podspec` to validate before publishing. | ||
# | ||
Pod::Spec.new do |s| | ||
s.name = 'quill_native_bridge' | ||
s.version = '0.0.1' | ||
s.summary = 'A plugin for flutter_quill' | ||
s.description = <<-DESC | ||
An internal plugin for flutter_quill package to access platform-specific APIs. | ||
DESC | ||
s.homepage = 'https://github.com/singerdmx/flutter-quill' | ||
s.license = { :file => '../LICENSE' } | ||
s.author = { 'Flutter Quill' => 'https://github.com/singerdmx/flutter-quill' } | ||
s.source = { :path => '.' } | ||
s.source_files = 'Classes/**/*' | ||
s.dependency 'Flutter' | ||
s.platform = :ios, '12.0' | ||
|
||
# Flutter.framework does not contain a i386 slice. | ||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } | ||
s.swift_version = '5.0' | ||
|
||
# If your plugin requires a privacy manifest, for example if it uses any | ||
# required reason APIs, update the PrivacyInfo.xcprivacy file to describe your | ||
# plugin's privacy impact, and then uncomment this line. For more information, | ||
# see https://developer.apple.com/documentation/bundleresources/privacy_manifest_files | ||
# s.resource_bundles = {'quill_native_bridge_privacy' => ['Resources/PrivacyInfo.xcprivacy']} | ||
end |
This file contains 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,14 @@ | ||
library; | ||
|
||
import 'src/quill_native_bridge_platform_interface.dart'; | ||
|
||
class QuillNativeBridge { | ||
QuillNativeBridge._(); | ||
|
||
/// Check if the app is running on [iOS Simulator](https://developer.apple.com/documentation/xcode/running-your-app-in-simulator-or-on-a-device). | ||
/// | ||
/// This function should only be called when [defaultTargetPlatform] | ||
/// is [TargetPlatform.iOS] and [kIsWeb] is `false`. | ||
static Future<bool> isIOSSimulator() => | ||
QuillNativeBridgePlatform.instance.isIOSSimulator(); | ||
} |
32 changes: 32 additions & 0 deletions
32
quill_native_bridge/lib/src/quill_native_bridge_method_channel.dart
This file contains 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 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
import 'quill_native_bridge_platform_interface.dart'; | ||
|
||
class MethodChannelQuillNativeBridge implements QuillNativeBridgePlatform { | ||
@visibleForTesting | ||
final methodChannel = const MethodChannel('quill_native_bridge'); | ||
|
||
@override | ||
Future<bool> isIOSSimulator() async { | ||
assert(() { | ||
if (kIsWeb || defaultTargetPlatform != TargetPlatform.iOS) { | ||
throw FlutterError( | ||
'isIOSSimulator() method should be called only on iOS.', | ||
); | ||
} | ||
return true; | ||
}()); | ||
final isSimulator = | ||
await methodChannel.invokeMethod<bool>('isIOSSimulator'); | ||
assert(() { | ||
if (isSimulator == null) { | ||
throw FlutterError( | ||
'isSimulator should not be null.', | ||
); | ||
} | ||
return true; | ||
}()); | ||
return isSimulator ?? false; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
quill_native_bridge/lib/src/quill_native_bridge_platform_interface.dart
This file contains 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,31 @@ | ||
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; | ||
|
||
import 'quill_native_bridge_method_channel.dart'; | ||
|
||
abstract class QuillNativeBridgePlatform extends PlatformInterface { | ||
/// Constructs a QuillNativeBridgePlatform. | ||
QuillNativeBridgePlatform() : super(token: _token); | ||
|
||
/// Avoid using `const` when creating the `Object` for `_token` | ||
static final Object _token = Object(); | ||
|
||
static QuillNativeBridgePlatform _instance = MethodChannelQuillNativeBridge(); | ||
|
||
/// The default instance of [QuillNativeBridgePlatform] to use. | ||
/// | ||
/// Defaults to [MethodChannelQuillNativeBridge]. | ||
static QuillNativeBridgePlatform get instance => _instance; | ||
|
||
/// Platform-specific implementations should set this with their own | ||
/// platform-specific class that extends [QuillNativeBridgePlatform] when | ||
/// they register themselves. | ||
static set instance(QuillNativeBridgePlatform instance) { | ||
PlatformInterface.verify(instance, _token); | ||
_instance = instance; | ||
} | ||
|
||
/// Check if the app is running on [iOS Simulator](https://developer.apple.com/documentation/xcode/running-your-app-in-simulator-or-on-a-device). | ||
Future<bool> isIOSSimulator() { | ||
throw UnimplementedError('isIOSSimulator() has not been implemented.'); | ||
} | ||
} |
Oops, something went wrong.