Skip to content

Commit

Permalink
Added decoration builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourav-Sonkar committed Jul 18, 2024
1 parent 8c1fffe commit 5eb2d3e
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions lib/src/super_tooltip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import 'shape_overlay.dart';
import 'super_tooltip_controller.dart';
import 'tooltip_position_delegate.dart';

typedef DecorationBuilder = Decoration Function(
Offset target,
);

class SuperTooltip extends StatefulWidget {
final Widget content;
final TooltipDirection popupDirection;
Expand All @@ -34,7 +38,7 @@ class SuperTooltip extends StatefulWidget {
final Color borderColor;
final BoxConstraints constraints;
final Color? backgroundColor;
final Decoration? decoration;
final DecorationBuilder? decorationBuilder;
final double elevation;
final Duration fadeInDuration;
final Duration fadeOutDuration;
Expand Down Expand Up @@ -101,7 +105,7 @@ class SuperTooltip extends StatefulWidget {
//
//
//
this.decoration,
this.decorationBuilder,
this.child,
this.borderColor = Colors.black,
this.constraints = const BoxConstraints(
Expand Down Expand Up @@ -216,7 +220,7 @@ class _SuperTooltipState extends State<SuperTooltip>
child: GestureDetector(
onTap: () {
if (widget.toggleOnTap && _superTooltipController!.isVisible) {
_superTooltipController!.hideTooltip();
_superTooltipController!.hideTooltip();
} else {
_superTooltipController!.showTooltip();
}
Expand Down Expand Up @@ -398,34 +402,35 @@ class _SuperTooltipState extends State<SuperTooltip>
closeButtonType: closeButtonType,
showCloseButton: showCloseButton,
),
decoration: widget.decoration ??
ShapeDecoration(
color: backgroundColor,
shadows: hasShadow
? <BoxShadow>[
BoxShadow(
blurRadius: shadowBlurRadius,
spreadRadius: shadowSpreadRadius,
color: shadowColor,
offset: shadowOffset,
),
]
: 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,
decoration: widget.decorationBuilder != null
? widget.decorationBuilder!(target)
: ShapeDecoration(
color: backgroundColor,
shadows: hasShadow
? <BoxShadow>[
BoxShadow(
blurRadius: shadowBlurRadius,
spreadRadius: shadowSpreadRadius,
color: shadowColor,
offset: shadowOffset,
),
]
: 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,
),
),
Expand Down

0 comments on commit 5eb2d3e

Please sign in to comment.