Skip to content

Commit

Permalink
Merge branch 'documentation' into resolve-conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
bensonarafat authored Oct 15, 2024
2 parents 16776cd + f031599 commit fd3264c
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: # [bensonarafat]
github: [bensonarafat]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
82 changes: 73 additions & 9 deletions lib/src/bubble_shape.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class BubbleShape extends ShapeBorder {
required this.preferredDirection,
required this.target,
required this.borderRadius,
required this.arrowTipRadius,
required this.arrowBaseWidth,
required this.arrowTipDistance,
required this.borderColor,
Expand All @@ -24,6 +25,7 @@ class BubbleShape extends ShapeBorder {
final double arrowBaseWidth;
final double arrowTipDistance;
final double borderRadius;
final double arrowTipRadius;
final Color borderColor;
final double borderWidth;
final double? left, top, right, bottom;
Expand Down Expand Up @@ -93,7 +95,24 @@ class BubbleShape extends ShapeBorder {
),
rect.top,
)
..lineTo(target.dx, target.dy + arrowTipDistance) // up to arrow tip
// up to arrow tip where the curve starts
..lineTo(
target.dx + arrowTipRadius / sqrt(2), //sin and cos 45 = 1/root(2)
target.dy +
arrowTipDistance -
(arrowTipRadius - arrowTipRadius / sqrt(2)))

//arc for the tip
..arcToPoint(
Offset(
target.dx - arrowTipRadius / sqrt(2),
target.dy +
arrowTipDistance -
(arrowTipRadius - arrowTipRadius / sqrt(2))),
radius: Radius.circular(arrowTipRadius),
clockwise: false)

// down /
..lineTo(
max(
min(
Expand All @@ -103,8 +122,7 @@ class BubbleShape extends ShapeBorder {
rect.left + topLeftRadius,
),
rect.top,
) // down /

)
..lineTo(rect.left + topLeftRadius, rect.top)
..arcToPoint(
Offset(rect.left, rect.top + topLeftRadius),
Expand All @@ -130,10 +148,23 @@ class BubbleShape extends ShapeBorder {
rect.right - bottomRightRadius),
rect.bottom)

// up to arrow tip \
..lineTo(target.dx, target.dy - arrowTipDistance)
// down to arrow tip curvature start\
..lineTo(
target.dx + arrowTipRadius / sqrt(2), //sin and cos 45 = 1/root(2)
target.dy -
arrowTipDistance +
(arrowTipRadius - arrowTipRadius / sqrt(2)))

// down /
//arc for the tip
..arcToPoint(
Offset(
target.dx - arrowTipRadius / sqrt(2),
target.dy -
arrowTipDistance +
(arrowTipRadius - arrowTipRadius / sqrt(2))),
radius: Radius.circular(arrowTipRadius))

// up /
..lineTo(
max(
min(target.dx - arrowBaseWidth / 2,
Expand All @@ -155,8 +186,25 @@ class BubbleShape extends ShapeBorder {
min(target.dy - arrowBaseWidth / 2,
rect.bottom - bottomRightRadius - arrowBaseWidth),
rect.top + topRightRadius))

// right to arrow tip to the start point of the arc \
..lineTo(
target.dx - arrowTipDistance, target.dy) // right to arrow tip \
target.dx -
arrowTipDistance +
(arrowTipRadius - arrowTipRadius / sqrt(2)),
target.dy - arrowTipRadius / sqrt(2))

//arc for the tip
..arcToPoint(
Offset(
target.dx -
arrowTipDistance +
(arrowTipRadius - arrowTipRadius / sqrt(2)),
target.dy + arrowTipRadius / sqrt(2),
),
radius: Radius.circular(arrowTipRadius),
)

// left /
..lineTo(
rect.right,
Expand All @@ -181,8 +229,23 @@ class BubbleShape extends ShapeBorder {
rect.bottom - bottomLeftRadius - arrowBaseWidth),
rect.top + topLeftRadius))

//left to arrow tip /
..lineTo(target.dx + arrowTipDistance, target.dy)
//left to arrow tip till curve start/

..lineTo(
target.dx +
arrowTipDistance -
(arrowTipRadius - arrowTipRadius / sqrt(2)),
target.dy - arrowTipRadius / sqrt(2))

//arc for the tip
..arcToPoint(
Offset(
target.dx +
arrowTipDistance -
(arrowTipRadius - arrowTipRadius / sqrt(2)),
target.dy + arrowTipRadius / sqrt(2)),
radius: Radius.circular(arrowTipRadius),
clockwise: false)

// right \
..lineTo(
Expand Down Expand Up @@ -288,6 +351,7 @@ class BubbleShape extends ShapeBorder {
preferredDirection: preferredDirection,
target: target,
borderRadius: borderRadius,
arrowTipRadius: arrowTipRadius,
arrowBaseWidth: arrowBaseWidth,
arrowTipDistance: arrowTipDistance,
borderColor: borderColor,
Expand Down
17 changes: 11 additions & 6 deletions lib/src/super_tooltip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ class SuperTooltip extends StatefulWidget {
/// The distance between the arrow tip and the target widget.
///
/// Defaults to `2.0`.
final double arrowTipRadius;

final double arrowTipDistance;

/// The border radius of the tooltip.
Expand Down Expand Up @@ -365,6 +367,7 @@ class SuperTooltip extends StatefulWidget {
this.fadeOutDuration = const Duration(milliseconds: 0),
this.arrowLength = 20.0,
this.arrowBaseWidth = 20.0,
this.arrowTipRadius = 0.0,
this.arrowTipDistance = 2.0,
this.touchThroughAreaShape = ClipAreaShape.oval,
this.touchThroughAreaCornerRadius = 5.0,
Expand Down Expand Up @@ -475,13 +478,13 @@ class _SuperTooltipState extends State<SuperTooltip>
link: _layerLink,
child: GestureDetector(
onTap: () {
if (widget.toggleOnTap && _superTooltipController!.isVisible) {
_superTooltipController!.hideTooltip();
} else {
if (widget.showOnTap) {
_superTooltipController!.showTooltip();
}
if (widget.toggleOnTap && _superTooltipController!.isVisible) {
_superTooltipController!.hideTooltip();
} else {
if (widget.showOnTap) {
_superTooltipController!.showTooltip();
}
}
},
onLongPress: widget.onLongPress,
child: widget.child,
Expand Down Expand Up @@ -660,6 +663,7 @@ class _SuperTooltipState extends State<SuperTooltip>
Material(
color: Colors.transparent,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (widget.hideTooltipOnTap)
_superTooltipController!.hideTooltip();
Expand Down Expand Up @@ -697,6 +701,7 @@ class _SuperTooltipState extends State<SuperTooltip>
shape: BubbleShape(
arrowBaseWidth: widget.arrowBaseWidth,
arrowTipDistance: widget.arrowTipDistance,
arrowTipRadius: widget.arrowTipRadius,
borderColor: widget.borderColor,
borderRadius: widget.borderRadius,
borderWidth: widget.borderWidth,
Expand Down

0 comments on commit fd3264c

Please sign in to comment.