From 5495cee73ae6199f729eb6ee69a4ebd3bbe9de35 Mon Sep 17 00:00:00 2001 From: Ujas Majithiya <76939001+ujas-m-simformsolutions@users.noreply.github.com> Date: Wed, 22 Mar 2023 15:01:24 +0530 Subject: [PATCH] feat: :sparkles: Add callback when barrier has been clicked (#359) --- CHANGELOG.md | 5 +++-- README.md | 1 + example/lib/main.dart | 2 ++ lib/src/showcase.dart | 9 +++++++++ pubspec.yaml | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c8297d0..8cead863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ -## (Unreleased) +## [2.0.3] (Unreleased) - Feature [#148](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/148) Add feasibility to add `textDirection` of `title` and `description`. +- Feature [#272](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/272) - Add barrier click callback. ## [2.0.2] -- Fixed [#335](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/335) - Fixed flutter inspector makes screen grey +- Fixed [#335](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/335) - Flutter inspector makes screen grey - Fixed [#346](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/346) - Dont respond to any clicks in target. ## [2.0.1] diff --git a/README.md b/README.md index d7547025..3923de2a 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,7 @@ WidgetsBinding.instance.addPostFrameCallback((_) => | onTargetClick | VoidCallback? | | Triggers when target widget is being clicked | ✅ | ✅ | | onTargetDoubleTap | VoidCallback? | | Triggers when target widget is being double clicked | ✅ | ✅ | | onTargetLongPress | VoidCallback? | | Triggers when target widget is being long pressed | ✅ | ✅ | +| onBarrierClick | VoidCallback? | | Triggers when barrier is clicked | ✅ | ✅ | | tooltipPosition | TooltipPosition? | | Defines vertical position of tooltip respective to Target widget | ✅ | ✅ | | titlePadding | EdgeInsets? | EdgeInsets.zero | Padding to title | ✅ | | | descriptionPadding | EdgeInsets? | EdgeInsets.zero | Padding to description | ✅ | | diff --git a/example/lib/main.dart b/example/lib/main.dart index a4323db0..9abcaf5d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -182,6 +182,8 @@ class _MailPageState extends State { key: _one, description: 'Tap to see menu options', disableDefaultTargetGestures: true, + onBarrierClick: () => + debugPrint('Barrier clicked'), child: GestureDetector( onTap: () => debugPrint('menu button clicked'), diff --git a/lib/src/showcase.dart b/lib/src/showcase.dart index 7c00583c..ee574a07 100644 --- a/lib/src/showcase.dart +++ b/lib/src/showcase.dart @@ -238,6 +238,12 @@ class Showcase extends StatefulWidget { /// Provides text direction of tooltip description. final TextDirection? descriptionTextDirection; + /// Provides a callback when barrier has been clicked. + /// + /// Note-: Even if barrier interactions are disabled, this handler + /// will still provide a callback. + final VoidCallback? onBarrierClick; + const Showcase({ required this.key, required this.description, @@ -281,6 +287,7 @@ class Showcase extends StatefulWidget { this.descriptionPadding, this.titleTextDirection, this.descriptionTextDirection, + this.onBarrierClick, }) : height = null, width = null, container = null, @@ -317,6 +324,7 @@ class Showcase extends StatefulWidget { this.onTargetDoubleTap, this.disableDefaultTargetGestures = false, this.tooltipPosition, + this.onBarrierClick, }) : showArrow = false, onToolTipClick = null, scaleAnimationDuration = const Duration(milliseconds: 300), @@ -486,6 +494,7 @@ class _ShowcaseState extends State { if (!showCaseWidgetState.disableBarrierInteraction) { _nextIfAny(); } + widget.onBarrierClick?.call(); }, child: ClipPath( clipper: RRectClipper( diff --git a/pubspec.yaml b/pubspec.yaml index 885a6157..8522dd93 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: showcaseview description: A Flutter package to Showcase/Highlight widgets step by step. -version: 2.0.2 +version: 2.0.3 homepage: https://github.com/simformsolutions/flutter_showcaseview issue_tracker: https://github.com/simformsolutions/flutter_showcaseview/issues