From fd663dc14ec4b2b0452d1e6b7a694ddb8b132f99 Mon Sep 17 00:00:00 2001 From: Ingrid Wang Date: Thu, 31 Aug 2023 11:58:57 -0400 Subject: [PATCH 1/2] Add option to tap tooltip to hide --- lib/src/super_tooltip.dart | 80 +++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/lib/src/super_tooltip.dart b/lib/src/super_tooltip.dart index 03cf885..53c3607 100644 --- a/lib/src/super_tooltip.dart +++ b/lib/src/super_tooltip.dart @@ -48,6 +48,7 @@ class SuperTooltip extends StatefulWidget { final double touchThroughAreaCornerRadius; final EdgeInsetsGeometry overlayDimensions; final EdgeInsetsGeometry bubbleDimensions; + final bool hideTooltipOnTap; //filter final bool showDropBoxFilter; @@ -107,6 +108,7 @@ class SuperTooltip extends StatefulWidget { this.borderRadius = 10.0, this.overlayDimensions = const EdgeInsets.all(10), this.bubbleDimensions = const EdgeInsets.all(10), + this.hideTooltipOnTap = false, this.sigmaX = 5.0, this.sigmaY = 5.0, this.showDropBoxFilter = false, @@ -329,46 +331,52 @@ class _SuperTooltipState extends State children: [ Material( color: Colors.transparent, - child: Container( - key: SuperTooltip.bubbleKey, - margin: SuperUtils.getTooltipMargin( - arrowLength: widget.arrowLength, - arrowTipDistance: widget.arrowTipDistance, - closeButtonSize: closeButtonSize, - preferredDirection: preferredDirection, - showCloseButton: showCloseButton, - ), - padding: SuperUtils.getTooltipPadding( - closeButtonSize: closeButtonSize, - showCloseButton: showCloseButton, - ), - decoration: ShapeDecoration( - color: backgroundColor, - shadows: hasShadow - ? [ - BoxShadow( - blurRadius: shadowBlurRadius, - spreadRadius: shadowSpreadRadius, - color: shadowColor, - ), - ] - : null, - shape: BubbleShape( - arrowBaseWidth: widget.arrowBaseWidth, + child: GestureDetector( + onTap: () { + if (widget.hideTooltipOnTap) + _superTooltipController!.hideTooltip(); + }, + child: Container( + key: SuperTooltip.bubbleKey, + margin: SuperUtils.getTooltipMargin( + arrowLength: widget.arrowLength, arrowTipDistance: widget.arrowTipDistance, - borderColor: widget.borderColor, - borderRadius: widget.borderRadius, - borderWidth: widget.borderWidth, - bottom: bottom, - left: left, + closeButtonSize: closeButtonSize, preferredDirection: preferredDirection, - right: right, - target: target, - top: top, - bubbleDimensions: widget.bubbleDimensions, + showCloseButton: showCloseButton, + ), + padding: SuperUtils.getTooltipPadding( + closeButtonSize: closeButtonSize, + showCloseButton: showCloseButton, + ), + decoration: ShapeDecoration( + color: backgroundColor, + shadows: hasShadow + ? [ + BoxShadow( + blurRadius: shadowBlurRadius, + spreadRadius: shadowSpreadRadius, + color: shadowColor, + ), + ] + : null, + shape: BubbleShape( + arrowBaseWidth: widget.arrowBaseWidth, + arrowTipDistance: widget.arrowTipDistance, + borderColor: widget.borderColor, + borderRadius: widget.borderRadius, + borderWidth: widget.borderWidth, + bottom: bottom, + left: left, + preferredDirection: preferredDirection, + right: right, + target: target, + top: top, + bubbleDimensions: widget.bubbleDimensions, + ), ), + child: widget.content, ), - child: widget.content, ), ), _buildCloseButton(), From 76abe8de4091f96ba49662e5e72376725264324e Mon Sep 17 00:00:00 2001 From: Ingrid Wang Date: Thu, 31 Aug 2023 11:59:22 -0400 Subject: [PATCH 2/2] Fix typo in touchThroughArea --- lib/src/super_tooltip.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/super_tooltip.dart b/lib/src/super_tooltip.dart index 53c3607..afd1c34 100644 --- a/lib/src/super_tooltip.dart +++ b/lib/src/super_tooltip.dart @@ -43,7 +43,7 @@ class SuperTooltip extends StatefulWidget { final double borderWidth; final bool? showBarrier; final Color? barrierColor; - final Rect? touchThrougArea; + final Rect? touchThroughArea; final ClipAreaShape touchThroughAreaShape; final double touchThroughAreaCornerRadius; final EdgeInsetsGeometry overlayDimensions; @@ -103,7 +103,7 @@ class SuperTooltip extends StatefulWidget { this.arrowTipDistance = 2.0, this.touchThroughAreaShape = ClipAreaShape.oval, this.touchThroughAreaCornerRadius = 5.0, - this.touchThrougArea, + this.touchThroughArea, this.borderWidth = 0.0, this.borderRadius = 10.0, this.overlayDimensions = const EdgeInsets.all(10), @@ -272,7 +272,7 @@ class _SuperTooltipState extends State shape: ShapeOverlay( clipAreaCornerRadius: widget.touchThroughAreaCornerRadius, clipAreaShape: widget.touchThroughAreaShape, - clipRect: widget.touchThrougArea, + clipRect: widget.touchThroughArea, barrierColor: barrierColor, overlayDimensions: widget.overlayDimensions, ),