diff --git a/quill_native_bridge/CHANGELOG.md b/quill_native_bridge/CHANGELOG.md index 43a4567..9db13c8 100644 --- a/quill_native_bridge/CHANGELOG.md +++ b/quill_native_bridge/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 11.0.1 + +- Adds `isAppleSafari` method to check whether the current web app is running on Safari browser. + ## 11.0.0 - Improves `README.md`. Adds more details to `README.md`. diff --git a/quill_native_bridge/README.md b/quill_native_bridge/README.md index 09fba88..20b61f5 100644 --- a/quill_native_bridge/README.md +++ b/quill_native_bridge/README.md @@ -18,6 +18,7 @@ For details about the plugin architecture, refer to the [README of the repo](../ | **openGalleryApp** | ✅ | ✅ | ✅ | ✅ | ⚪ | ⚪ | | **saveImageToGallery** | ✅ | ✅ | ✅ | ❌ | ⚪ | ⚪ | | **saveImage** | ⚪ | ⚪ | ✅ | ✅ | ✅ | ✅ | +| **isAppleSafari** | ⚪ | ⚪ | ⚪ | ⚪ | ⚪ | ✅ | - `⚪`: Not applicable, not expected, or unsupported on this platform (e.g., checking **iOS simulator** on **Android**, saving images to the gallery on the web, or retrieving GIFs on desktop/web). - `❌`: The plugin doesn't currently implement it. @@ -110,6 +111,12 @@ final Uint8List imageBytes = ...; // Load the image bytes await QuillNativeBridge().saveImage(imageBytes, options: ImageSaveOptions(name: 'ExampleImageName', fileExtension: 'png')); // Doesn't work on mobile platforms ``` +**To check whether the current web app is running on a browser**: + +```dart +await QuillNativeBridge().isAppleBrowser(); // Returns false on non-web platforms. +``` + ## 🔧 Setup Certain functionalities require a platform-specific configuration. diff --git a/quill_native_bridge/example/lib/main.dart b/quill_native_bridge/example/lib/main.dart index 278d7cb..f0864d6 100644 --- a/quill_native_bridge/example/lib/main.dart +++ b/quill_native_bridge/example/lib/main.dart @@ -123,6 +123,14 @@ class Buttons extends StatelessWidget { label: const Text('Save image'), icon: const Icon(Icons.image), ), + ElevatedButton.icon( + onPressed: () => _onButtonPressed( + QuillNativeBridgeFeature.isAppleSafari, + context: context, + ), + label: const Text('Is Safari'), + icon: const Icon(Icons.apple), + ), ], ); } @@ -370,6 +378,18 @@ Future _onButtonPressed( } scaffoldMessenger.showText('The image has been saved at: $imagePath.'); break; + case QuillNativeBridgeFeature.isAppleSafari: + if (!kIsWeb) { + scaffoldMessenger.showText( + 'Checking whether the browser is Safari is only supported on the web.'); + return; + } + if (quillNativeBridge.isAppleSafari()) { + scaffoldMessenger.showText("You're running this app on Safari browser"); + } else { + scaffoldMessenger + .showText("You're not running this app on Safari browser"); + } } } diff --git a/quill_native_bridge/example/pubspec.lock b/quill_native_bridge/example/pubspec.lock index 9770fee..82517b2 100644 --- a/quill_native_bridge/example/pubspec.lock +++ b/quill_native_bridge/example/pubspec.lock @@ -5,23 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" + sha256: dc27559385e905ad30838356c5f5d574014ba39872d732111cd07ac0beff4c57 url: "https://pub.dev" source: hosted - version: "76.0.0" - _macros: - dependency: transitive - description: dart - source: sdk - version: "0.3.3" + version: "80.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" + sha256: "192d1c5b944e7e53b24b5586db760db934b177d4147c42fbca8c8c5f1eb8d11e" url: "https://pub.dev" source: hosted - version: "6.11.0" + version: "7.3.0" archive: dependency: transitive description: @@ -34,10 +29,10 @@ packages: dependency: transitive description: name: args - sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 url: "https://pub.dev" source: hosted - version: "2.6.0" + version: "2.7.0" async: dependency: transitive description: @@ -58,50 +53,50 @@ packages: dependency: transitive description: name: build - sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + sha256: cef23f1eda9b57566c81e2133d196f8e3df48f244b317368d65c5943d91148f0 url: "https://pub.dev" source: hosted - version: "2.4.1" + version: "2.4.2" build_config: dependency: transitive description: name: build_config - sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" build_daemon: dependency: transitive description: name: build_daemon - sha256: "79b2aef6ac2ed00046867ed354c88778c9c0f029df8a20fe10b5436826721ef9" + sha256: "8e928697a82be082206edb0b9c99c5a4ad6bc31c9e9b8b2f291ae65cd4a25daa" url: "https://pub.dev" source: hosted - version: "4.0.2" + version: "4.0.4" build_resolvers: dependency: transitive description: name: build_resolvers - sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + sha256: b9e4fda21d846e192628e7a4f6deda6888c36b5b69ba02ff291a01fd529140f0 url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.4.4" build_runner: dependency: "direct dev" description: name: build_runner - sha256: "028819cfb90051c6b5440c7e574d1896f8037e3c96cf17aaeb054c9311cfbf4d" + sha256: "058fe9dce1de7d69c4b84fada934df3e0153dd000758c4d65964d0166779aa99" url: "https://pub.dev" source: hosted - version: "2.4.13" + version: "2.4.15" build_runner_core: dependency: transitive description: name: build_runner_core - sha256: f8126682b87a7282a339b871298cc12009cb67109cfa1614d6436fb0289193e0 + sha256: "22e3aa1c80e0ada3722fe5b63fd43d9c8990759d0a2cf489c8c5d7b2bdebc021" url: "https://pub.dev" source: hosted - version: "7.3.2" + version: "8.0.0" built_collection: dependency: transitive description: @@ -114,18 +109,18 @@ packages: dependency: transitive description: name: built_value - sha256: c7913a9737ee4007efedaffc968c049fd0f3d0e49109e778edc10de9426005cb + sha256: ea90e81dc4a25a043d9bee692d20ed6d1c4a1662a28c03a96417446c093ed6b4 url: "https://pub.dev" source: hosted - version: "8.9.2" + version: "8.9.5" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.0" checked_yaml: dependency: transitive description: @@ -154,10 +149,10 @@ packages: dependency: transitive description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.19.1" convert: dependency: transitive description: @@ -186,10 +181,10 @@ packages: dependency: transitive description: name: dart_style - sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab" + sha256: "27eb0ae77836989a3bc541ce55595e8ceee0992807f14511552a898ddd0d88ac" url: "https://pub.dev" source: hosted - version: "2.3.7" + version: "3.0.1" fake_async: dependency: transitive description: @@ -202,10 +197,10 @@ packages: dependency: transitive description: name: ffi - sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" file: dependency: transitive description: @@ -234,10 +229,10 @@ packages: dependency: transitive description: name: file_selector_windows - sha256: "8f5d2f6590d51ecd9179ba39c64f722edc15226cc93dcc8698466ad36a4a85a4" + sha256: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b" url: "https://pub.dev" source: hosted - version: "0.9.3+3" + version: "0.9.3+4" fixnum: dependency: transitive description: @@ -291,10 +286,10 @@ packages: dependency: transitive description: name: glob - sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.3" graphs: dependency: transitive description: @@ -307,26 +302,26 @@ packages: dependency: transitive description: name: http - sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.3.0" http_multi_server: dependency: transitive description: name: http_multi_server - sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 url: "https://pub.dev" source: hosted - version: "3.2.1" + version: "3.2.2" http_parser: dependency: transitive description: name: http_parser - sha256: "76d306a1c3afb33fe82e2bbacad62a61f409b5634c915fceb0d799de1a913360" + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" url: "https://pub.dev" source: hosted - version: "4.1.1" + version: "4.1.2" image: dependency: transitive description: @@ -360,10 +355,10 @@ packages: dependency: transitive description: name: js - sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc" url: "https://pub.dev" source: hosted - version: "0.7.1" + version: "0.7.2" json_annotation: dependency: transitive description: @@ -400,10 +395,10 @@ packages: dependency: transitive description: name: lints - sha256: "4a16b3f03741e1252fda5de3ce712666d010ba2122f8e912c94f9f7b90e1a4c3" + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "5.1.1" logging: dependency: transitive description: @@ -412,22 +407,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" - macros: - dependency: transitive - description: - name: macros - sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" - url: "https://pub.dev" - source: hosted - version: "0.1.3-main.0" matcher: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.17" material_color_utilities: dependency: transitive description: @@ -440,10 +427,10 @@ packages: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.16.0" mime: dependency: transitive description: @@ -456,18 +443,18 @@ packages: dependency: "direct dev" description: name: mockito - sha256: "6841eed20a7befac0ce07df8116c8b8233ed1f4486a7647c7fc5a02ae6163917" + sha256: f99d8d072e249f719a5531735d146d8cf04c580d93920b04de75bef6dfb2daf6 url: "https://pub.dev" source: hosted - version: "5.4.4" + version: "5.4.5" package_config: dependency: transitive description: name: package_config - sha256: "92d4488434b520a62570293fbd33bb556c7d49230791c1b4bbd973baf6d2dc67" + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.2.0" path: dependency: transitive description: @@ -480,10 +467,10 @@ packages: dependency: transitive description: name: petitparser - sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646" url: "https://pub.dev" source: hosted - version: "6.0.2" + version: "6.1.0" platform: dependency: transitive description: @@ -520,18 +507,18 @@ packages: dependency: transitive description: name: pub_semver - sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd" + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.2.0" pubspec_parse: dependency: transitive description: name: pubspec_parse - sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8 + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.5.0" quill_native_bridge: dependency: "direct main" description: @@ -573,7 +560,7 @@ packages: path: "../../quill_native_bridge_platform_interface" relative: true source: path - version: "0.0.1+1" + version: "0.0.2+1" quill_native_bridge_web: dependency: "direct overridden" description: @@ -600,10 +587,10 @@ packages: dependency: transitive description: name: shelf_web_socket - sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67 + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.0" sky_engine: dependency: transitive description: flutter @@ -613,50 +600,50 @@ packages: dependency: transitive description: name: source_gen - sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + sha256: "35c8150ece9e8c8d263337a265153c3329667640850b9304861faea59fc98f6b" url: "https://pub.dev" source: hosted - version: "1.5.0" + version: "2.0.0" source_span: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.10.1" stack_trace: dependency: transitive description: name: stack_trace - sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" stream_transform: dependency: transitive description: name: stream_transform - sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - sha256: "0bd04f5bb74fcd6ff0606a888a30e917af9bd52820b178eaa464beb11dca84b6" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" sync_http: dependency: transitive description: @@ -669,18 +656,18 @@ packages: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.2" test_api: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.7.4" timing: dependency: transitive description: @@ -725,18 +712,18 @@ packages: dependency: transitive description: name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + sha256: "69da27e49efa56a15f8afe8f4438c4ec02eff0a117df1b22ea4aad194fe1c104" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" web: dependency: transitive description: name: web - sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" web_socket: dependency: transitive description: @@ -749,10 +736,10 @@ packages: dependency: transitive description: name: web_socket_channel - sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f" + sha256: "0b8e2457400d8a859b7b2030786835a28a8e80836ef64402abef392ff4f1d0e5" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" webdriver: dependency: transitive description: @@ -765,10 +752,10 @@ packages: dependency: transitive description: name: win32 - sha256: "8b338d4486ab3fbc0ba0db9f9b4f5239b6697fcee427939a40e720cbb9ee0a69" + sha256: dc6ecaa00a7c708e5b4d10ee7bec8c270e9276dfcab1783f57e9962d7884305f url: "https://pub.dev" source: hosted - version: "5.9.0" + version: "5.12.0" xml: dependency: transitive description: @@ -781,10 +768,10 @@ packages: dependency: transitive description: name: yaml - sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce url: "https://pub.dev" source: hosted - version: "3.1.2" + version: "3.1.3" sdks: - dart: ">=3.7.0-0 <4.0.0" + dart: ">=3.7.0 <4.0.0" flutter: ">=3.24.0" diff --git a/quill_native_bridge/lib/quill_native_bridge.dart b/quill_native_bridge/lib/quill_native_bridge.dart index 725c2ef..ccdb08e 100644 --- a/quill_native_bridge/lib/quill_native_bridge.dart +++ b/quill_native_bridge/lib/quill_native_bridge.dart @@ -207,4 +207,7 @@ class QuillNativeBridge { required ImageSaveOptions options, }) => _platform.saveImage(imageBytes, options: options); + + /// Returns whether the current browser is Safari on the web. + bool isAppleSafari() => _platform.isAppleSafari(); } diff --git a/quill_native_bridge/pubspec.yaml b/quill_native_bridge/pubspec.yaml index b1627f0..e344ded 100644 --- a/quill_native_bridge/pubspec.yaml +++ b/quill_native_bridge/pubspec.yaml @@ -1,6 +1,6 @@ name: quill_native_bridge description: "An internal Flutter plugin for flutter_quill package to access platform-specific APIs" -version: 11.0.0 +version: 11.0.1 homepage: https://github.com/FlutterQuill/quill-native-bridge/tree/main/quill_native_bridge repository: https://github.com/FlutterQuill/quill-native-bridge/tree/main/quill_native_bridge issue_tracker: https://github.com/FlutterQuill/quill-native-bridge/issues @@ -15,8 +15,8 @@ dependencies: flutter: sdk: flutter quill_native_bridge_android: ^0.0.1 - quill_native_bridge_platform_interface: ^0.0.1 - quill_native_bridge_web: ^0.0.1 + quill_native_bridge_platform_interface: ^0.0.2+1 + quill_native_bridge_web: ^0.0.2 quill_native_bridge_windows: ^0.0.1 quill_native_bridge_linux: ^0.0.1 quill_native_bridge_ios: ^0.0.1 @@ -25,7 +25,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - mockito: ^5.4.4 + mockito: ^5.4.5 build_runner: ^2.4.13 plugin_platform_interface: ^2.1.8 diff --git a/quill_native_bridge/test/quill_native_bridge_test.dart b/quill_native_bridge/test/quill_native_bridge_test.dart index 1c33922..9209b40 100644 --- a/quill_native_bridge/test/quill_native_bridge_test.dart +++ b/quill_native_bridge/test/quill_native_bridge_test.dart @@ -245,4 +245,21 @@ void main() { }); }, ); + + group('isAppleSafari', () { + test('calls isAppleSafari from the platform API', () { + when(mockQuillNativeBridgePlatform.isAppleSafari()).thenReturn(false); + plugin.isAppleSafari(); + verify(mockQuillNativeBridgePlatform.isAppleSafari()).called(1); + verifyNoMoreInteractions(mockQuillNativeBridgePlatform); + }); + + test('delegates to isAppleSafari from the platform API', () { + for (final bool isAppleSafariValue in {true, false}) { + when(mockQuillNativeBridgePlatform.isAppleSafari()) + .thenReturn(isAppleSafariValue); + expect(plugin.isAppleSafari(), isAppleSafariValue); + } + }); + }); } diff --git a/quill_native_bridge/test/quill_native_bridge_test.mocks.dart b/quill_native_bridge/test/quill_native_bridge_test.mocks.dart index 9b9084c..eb4e19c 100644 --- a/quill_native_bridge/test/quill_native_bridge_test.mocks.dart +++ b/quill_native_bridge/test/quill_native_bridge_test.mocks.dart @@ -1,4 +1,4 @@ -// Mocks generated by Mockito 5.4.4 from annotations +// Mocks generated by Mockito 5.4.5 from annotations // in quill_native_bridge/test/quill_native_bridge_test.dart. // Do not manually edit this file. @@ -24,6 +24,7 @@ import 'package:quill_native_bridge_platform_interface/src/types/image_save_resu // ignore_for_file: deprecated_member_use_from_same_package // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: must_be_immutable // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types @@ -31,13 +32,8 @@ import 'package:quill_native_bridge_platform_interface/src/types/image_save_resu class _FakeImageSaveResult_0 extends _i1.SmartFake implements _i2.ImageSaveResult { - _FakeImageSaveResult_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeImageSaveResult_0(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } /// A class which mocks [QuillNativeBridgePlatform]. @@ -52,37 +48,25 @@ class MockQuillNativeBridgePlatform extends _i1.Mock @override _i4.Future isSupported(_i5.QuillNativeBridgeFeature? feature) => (super.noSuchMethod( - Invocation.method( - #isSupported, - [feature], - ), + Invocation.method(#isSupported, [feature]), returnValue: _i4.Future.value(false), ) as _i4.Future); @override _i4.Future isIOSSimulator() => (super.noSuchMethod( - Invocation.method( - #isIOSSimulator, - [], - ), + Invocation.method(#isIOSSimulator, []), returnValue: _i4.Future.value(false), ) as _i4.Future); @override _i4.Future getClipboardHtml() => (super.noSuchMethod( - Invocation.method( - #getClipboardHtml, - [], - ), + Invocation.method(#getClipboardHtml, []), returnValue: _i4.Future.value(), ) as _i4.Future); @override _i4.Future copyHtmlToClipboard(String? html) => (super.noSuchMethod( - Invocation.method( - #copyHtmlToClipboard, - [html], - ), + Invocation.method(#copyHtmlToClipboard, [html]), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @@ -90,47 +74,32 @@ class MockQuillNativeBridgePlatform extends _i1.Mock @override _i4.Future copyImageToClipboard(_i6.Uint8List? imageBytes) => (super.noSuchMethod( - Invocation.method( - #copyImageToClipboard, - [imageBytes], - ), + Invocation.method(#copyImageToClipboard, [imageBytes]), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @override _i4.Future<_i6.Uint8List?> getClipboardImage() => (super.noSuchMethod( - Invocation.method( - #getClipboardImage, - [], - ), + Invocation.method(#getClipboardImage, []), returnValue: _i4.Future<_i6.Uint8List?>.value(), ) as _i4.Future<_i6.Uint8List?>); @override _i4.Future<_i6.Uint8List?> getClipboardGif() => (super.noSuchMethod( - Invocation.method( - #getClipboardGif, - [], - ), + Invocation.method(#getClipboardGif, []), returnValue: _i4.Future<_i6.Uint8List?>.value(), ) as _i4.Future<_i6.Uint8List?>); @override _i4.Future> getClipboardFiles() => (super.noSuchMethod( - Invocation.method( - #getClipboardFiles, - [], - ), + Invocation.method(#getClipboardFiles, []), returnValue: _i4.Future>.value([]), ) as _i4.Future>); @override _i4.Future openGalleryApp() => (super.noSuchMethod( - Invocation.method( - #openGalleryApp, - [], - ), + Invocation.method(#openGalleryApp, []), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @@ -156,19 +125,22 @@ class MockQuillNativeBridgePlatform extends _i1.Mock required _i7.ImageSaveOptions? options, }) => (super.noSuchMethod( - Invocation.method( - #saveImage, - [imageBytes], - {#options: options}, - ), - returnValue: - _i4.Future<_i2.ImageSaveResult>.value(_FakeImageSaveResult_0( - this, - Invocation.method( - #saveImage, - [imageBytes], - {#options: options}, + Invocation.method(#saveImage, [imageBytes], {#options: options}), + returnValue: _i4.Future<_i2.ImageSaveResult>.value( + _FakeImageSaveResult_0( + this, + Invocation.method( + #saveImage, + [imageBytes], + {#options: options}, + ), ), - )), + ), ) as _i4.Future<_i2.ImageSaveResult>); + + @override + bool isAppleSafari() => (super.noSuchMethod( + Invocation.method(#isAppleSafari, []), + returnValue: false, + ) as bool); } diff --git a/quill_native_bridge_platform_interface/CHANGELOG.md b/quill_native_bridge_platform_interface/CHANGELOG.md index 65f04e6..a43a931 100644 --- a/quill_native_bridge_platform_interface/CHANGELOG.md +++ b/quill_native_bridge_platform_interface/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. +## 0.0.2+1 + +- Adds missing `isAppleSafari` enum item to `QuillNativeBridgeFeature`. + +## 0.0.2 + +- Adds `isAppleSafari` to check whether the current platform is Apple Safari. + ## 0.0.1+1 - Adds `internal.dart`. diff --git a/quill_native_bridge_platform_interface/lib/quill_native_bridge_platform_interface.dart b/quill_native_bridge_platform_interface/lib/quill_native_bridge_platform_interface.dart index 2b3ab47..8c9862a 100644 --- a/quill_native_bridge_platform_interface/lib/quill_native_bridge_platform_interface.dart +++ b/quill_native_bridge_platform_interface/lib/quill_native_bridge_platform_interface.dart @@ -122,4 +122,7 @@ abstract class QuillNativeBridgePlatform extends PlatformInterface { throw UnimplementedError( 'saveImage() has not been implemented.', ); + + /// Returns whether the current browser is Safari on the web. + bool isAppleSafari() => false; } diff --git a/quill_native_bridge_platform_interface/lib/src/platform_feature.dart b/quill_native_bridge_platform_interface/lib/src/platform_feature.dart index d197089..96ac746 100644 --- a/quill_native_bridge_platform_interface/lib/src/platform_feature.dart +++ b/quill_native_bridge_platform_interface/lib/src/platform_feature.dart @@ -9,5 +9,6 @@ enum QuillNativeBridgeFeature { getClipboardFiles, openGalleryApp, saveImageToGallery, - saveImage; + saveImage, + isAppleSafari; } diff --git a/quill_native_bridge_platform_interface/pubspec.yaml b/quill_native_bridge_platform_interface/pubspec.yaml index d38bf0e..96e1a5e 100644 --- a/quill_native_bridge_platform_interface/pubspec.yaml +++ b/quill_native_bridge_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: quill_native_bridge_platform_interface description: "A common platform interface for the quill_native_bridge plugin." -version: 0.0.1+1 +version: 0.0.2+1 homepage: https://github.com/FlutterQuill/quill-native-bridge/tree/main/quill_native_bridge_platform_interface repository: https://github.com/FlutterQuill/quill-native-bridge/tree/main/quill_native_bridge_platform_interface issue_tracker: https://github.com/FlutterQuill/quill-native-bridge/issues diff --git a/quill_native_bridge_platform_interface/test/quill_native_bridge_platform_interface.dart b/quill_native_bridge_platform_interface/test/quill_native_bridge_platform_interface.dart index 2407454..19c07e2 100644 --- a/quill_native_bridge_platform_interface/test/quill_native_bridge_platform_interface.dart +++ b/quill_native_bridge_platform_interface/test/quill_native_bridge_platform_interface.dart @@ -84,6 +84,11 @@ class MockQuillNativeBridgePlatform Future openGalleryApp() async { _galleryAppOpened = true; } + + var isSafari = false; + + @override + bool isAppleSafari() => isSafari; } void main() { @@ -199,4 +204,14 @@ void main() { expect(fakePlatform._galleryAppOpened, true); }, ); + test( + 'isAppleSafari', + () async { + fakePlatform.isSafari = true; + expect(fakePlatform.isAppleSafari(), true); + + fakePlatform.isSafari = false; + expect(fakePlatform.isAppleSafari(), false); + }, + ); } diff --git a/quill_native_bridge_web/CHANGELOG.md b/quill_native_bridge_web/CHANGELOG.md index aca4496..bdcc494 100644 --- a/quill_native_bridge_web/CHANGELOG.md +++ b/quill_native_bridge_web/CHANGELOG.md @@ -2,9 +2,10 @@ All notable changes to this project will be documented in this file. -## NEXT +## 0.0.2 - Creates the anchor element (``) in a type-safe way using `HTMLAnchorElement` without casting in `saveImage`. +- Adds support for `isAppleSafari`. ## 0.0.1 diff --git a/quill_native_bridge_web/lib/quill_native_bridge_web.dart b/quill_native_bridge_web/lib/quill_native_bridge_web.dart index 89e74c2..27e6289 100644 --- a/quill_native_bridge_web/lib/quill_native_bridge_web.dart +++ b/quill_native_bridge_web/lib/quill_native_bridge_web.dart @@ -37,6 +37,8 @@ class QuillNativeBridgeWeb extends QuillNativeBridgePlatform { return false; case QuillNativeBridgeFeature.saveImage: return true; + case QuillNativeBridgeFeature.isAppleSafari: + return true; } // Without this default, adding a new item to the enum will be a breaking change. // ignore: dead_code @@ -159,4 +161,8 @@ class QuillNativeBridgeWeb extends QuillNativeBridgePlatform { return ImageSaveResult.web(blobUrl: url); } + + // https://github.com/flutter/packages/blob/main/packages/cross_file/lib/src/web_helpers/web_helpers.dart#L35-L37 + @override + bool isAppleSafari() => window.navigator.vendor == 'Apple Computer, Inc.'; } diff --git a/quill_native_bridge_web/pubspec.yaml b/quill_native_bridge_web/pubspec.yaml index 64bb848..8649a32 100644 --- a/quill_native_bridge_web/pubspec.yaml +++ b/quill_native_bridge_web/pubspec.yaml @@ -1,6 +1,6 @@ name: quill_native_bridge_web description: "Web platform implementation of quill_native_bridge" -version: 0.0.1 +version: 0.0.2 homepage: https://github.com/FlutterQuill/quill-native-bridge/tree/main/quill_native_bridge_web repository: https://github.com/FlutterQuill/quill-native-bridge/tree/main/quill_native_bridge_web issue_tracker: https://github.com/FlutterQuill/quill-native-bridge/issues?q=is%3Aissue+is%3Aopen+label%3A%22platform-web%22 @@ -17,7 +17,7 @@ dependencies: flutter_web_plugins: sdk: flutter web: ^1.0.0 - quill_native_bridge_platform_interface: ^0.0.1+1 + quill_native_bridge_platform_interface: ^0.0.2+1 dev_dependencies: flutter_test: