From 1a22b1eb816682b003949ffa0e3cd59dbeb35b34 Mon Sep 17 00:00:00 2001 From: Gautier Date: Thu, 20 Jun 2024 09:10:40 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=96=20=200.3.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++--- example/pubspec.lock | 4 ++-- lib/anchored/anchored_helper_widget.dart | 11 ++++------ lib/helper_orchestrator.dart | 19 +++++++++++----- lib/services/element_finder.dart | 8 +++---- pubspec.lock | 28 ++++++++++++------------ pubspec.yaml | 2 +- test/screen_variants.dart | 7 ++++-- 8 files changed, 45 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index f94e19c..0b70528 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ A set of amazing onboarding widgets for your flutter applications. ## Install package add in your pubspec.yaml dependencies -```pal-widgets: 0.2.0``` +```pal-widgets: 0.3.0``` ---- @@ -56,7 +56,6 @@ Text( You can now show an anchored helper using ```dart final helper = AnchoredHelper( - anchorKeyId: 'text1', title: const Text('Title lorem pitume'), description: const Text('Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum'),, bgColor: Colors.blue, @@ -78,7 +77,6 @@ HelperOrchestrator.of(context).showAnchoredHelper('text1', helper); | Property | description | Required | |--------------------|----------------------------------------------|-------------| -| anchorKeyId | The reference to the [Key] created by [HelperOrchestrator] |:white_check_mark:| | title | A Text widget to show as title | | | description | A Text widget to show as description | | | bgColor | A Color as Overlayed background | :white_check_mark: | @@ -97,4 +95,4 @@ There is two Hole Anchor widget factories : - ```AnchoredRectHoleHelper.anchorFactory``` : creates a rectangle hole on strict widget bounds ## Any question? -Contact us on [our twitter](https://twitter.com/PalFlutter) or email gautier[@@]pal-plugin.tech +Contact us on [our twitter](https://twitter.com/PalFlutter) diff --git a/example/pubspec.lock b/example/pubspec.lock index 244a185..2e0e646 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: "direct main" description: name: cupertino_icons - sha256: "486b7bc707424572cdf7bd7e812a0c146de3fd47ecadf070254cc60383f21dd8" + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.8" fake_async: dependency: transitive description: diff --git a/lib/anchored/anchored_helper_widget.dart b/lib/anchored/anchored_helper_widget.dart index d8d54b6..3d7614a 100644 --- a/lib/anchored/anchored_helper_widget.dart +++ b/lib/anchored/anchored_helper_widget.dart @@ -32,7 +32,6 @@ class AnchorHelperWrapper extends InheritedWidget { /// You are free to add a positiv button / negativ button or an onTap function /// on the anchor. class AnchoredHelper extends StatefulWidget { - /// A [Text] widget to show as title final Text? title; @@ -157,7 +156,7 @@ class _AnchoredHelperState extends State // print("anchor: ${anchor.offset} ${anchor.size}: ${anchor.rect}"); return GestureDetector( onTap: () async { - if(widget.onTapBackground != null) { + if (widget.onTapBackground != null) { HapticFeedback.selectionClick(); await fadeAnimController.reverse(); widget.onTapBackground!.call(); @@ -190,9 +189,7 @@ class _AnchoredHelperState extends State child: LayoutBuilder( builder: (context, constraints) => Padding( padding: const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0 - ), + horizontal: 16.0, vertical: 8.0), child: ConstrainedBox( constraints: BoxConstraints( minHeight: constraints.maxHeight, @@ -202,7 +199,7 @@ class _AnchoredHelperState extends State crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - if(widget.title != null) + if (widget.title != null) Padding( padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), child: PopAnimation( @@ -212,7 +209,7 @@ class _AnchoredHelperState extends State child: widget.title!, ), ), - if(widget.description != null) + if (widget.description != null) Padding( padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), child: PopAnimation( diff --git a/lib/helper_orchestrator.dart b/lib/helper_orchestrator.dart index 987c01a..7312460 100644 --- a/lib/helper_orchestrator.dart +++ b/lib/helper_orchestrator.dart @@ -31,8 +31,8 @@ class HelperOrchestrator extends StatefulWidget { final GlobalKey? navigatorKey; const HelperOrchestrator({ - Key? key, - required this.child, + Key? key, + required this.child, this.navigatorKey, }) : super(key: key); @@ -89,7 +89,7 @@ class HelperOrchestratorState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - if(widget.navigatorKey != null) { + if (widget.navigatorKey != null) { _elementFinder = ElementFinder(navigatorKey: widget.navigatorKey); } else { _elementFinder = ElementFinder(buildContext: context); @@ -123,7 +123,11 @@ class HelperOrchestratorState extends State { /// ```dart /// HelperOrchestrator.of(context).generateKey('myKeyId') /// ``` - Future showAnchoredHelper(String anchorKeyId, AnchoredHelper helper, {HelperAlignment? align,}) async { + Future showAnchoredHelper( + String anchorKeyId, + AnchoredHelper helper, { + HelperAlignment? align, + }) async { try { //final key = getAnchorKey(anchorKeyId) as ValueKey; final anchor = await findAnchor(anchorKeyId, align: align); @@ -147,7 +151,10 @@ class HelperOrchestratorState extends State { /// containing the key. /// /// this requires an [anchorKeyId] to search within our keys - Future findAnchor(String anchorKeyId, {HelperAlignment? align,}) async { + Future findAnchor( + String anchorKeyId, { + HelperAlignment? align, + }) async { final element = _elementFinder! // .searchChildElementByKey(getAnchorKey(anchorKeyId)); if (element == null || element.bounds == null) { @@ -156,7 +163,7 @@ class HelperOrchestratorState extends State { } final anchorSize = element.bounds!.size; final currentPos = element.offset!; - if(align != null) { + if (align != null) { return Anchor( size: anchorSize, offset: currentPos, diff --git a/lib/services/element_finder.dart b/lib/services/element_finder.dart index 4fbb5d2..9056a8b 100644 --- a/lib/services/element_finder.dart +++ b/lib/services/element_finder.dart @@ -41,8 +41,8 @@ class ElementFinder { // this method scan all child recursively to find a widget having a key == searchedKey ElementModel? searchChildElement(String? key) { ElementModel? result; - context.visitChildElements((element) => result = - _searchChildElement(context.findRenderObject(), element, key)); + context.visitChildElements((element) => + result = _searchChildElement(context.findRenderObject(), element, key)); if (result == null) { return ElementModel.empty(); } @@ -77,8 +77,8 @@ class ElementFinder { case HelperAlignment.left: return Rect.fromLTWH(0, 0, objectX, layerRect.height); case HelperAlignment.right: - return Rect.fromLTWH(objectEndX, 0, layerRect.width - objectEndX, - layerRect.height); + return Rect.fromLTWH( + objectEndX, 0, layerRect.width - objectEndX, layerRect.height); } } diff --git a/pubspec.lock b/pubspec.lock index 0dfbba1..e309098 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -71,26 +71,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -119,10 +119,10 @@ packages: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" path: dependency: transitive description: @@ -180,10 +180,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" vector_math: dependency: transitive description: @@ -196,10 +196,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" sdks: - dart: ">=3.2.0-0 <4.0.0" - flutter: ">=1.17.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/pubspec.yaml b/pubspec.yaml index 13e5d12..71785a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pal_widgets description: A set of amazing onboarding widgets for your flutter applications. -version: 0.2.0 +version: 0.3.0 repository: https://github.com/Apparence-io/pal-widgets environment: diff --git a/test/screen_variants.dart b/test/screen_variants.dart index d9f6adf..0fd8f6d 100644 --- a/test/screen_variants.dart +++ b/test/screen_variants.dart @@ -36,7 +36,10 @@ extension ScreenSizeManager on WidgetTester { double pixelDensity = 1}) async { final size = Size(width, height); await binding.setSurfaceSize(size); - binding.window.physicalSizeTestValue = size; - binding.window.devicePixelRatioTestValue = pixelDensity; + view.physicalSize = size; + view.devicePixelRatio = pixelDensity; + // Old code + // binding.window.physicalSizeTestValue = size; + // binding.window.devicePixelRatioTestValue = pixelDensity; } }