Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update from master #117

Merged
merged 19 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# These are supported funding model platforms

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
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: bensonarafat # Replace with a single Buy Me a Coffee username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

# [2.0.8] - 13.07.2024
- Added toggleOnTap option to toggle tooltip
- Remove un-use method
- Fix showClosButton and hideToolTip on Barrier Tap
- expose showowOffset

# [2.0.7] - 28.09.2023
* Fix custom decoration
Expand Down
54 changes: 40 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# super_tooltip
[![Static code analysis](https://github.com/bensonarafat/super_tooltip/actions/workflows/dart.yml/badge.svg)](https://github.com/bensonarafat/super_tooltip/actions/workflows/dart.yml)


`SuperTooltip` It is super flexible and allows you to display ToolTips in the overlay of the screen. It gives you more flexibility over the Flutter standard ```Tooltip```. You have the option to make the whole screen covered with a background color. Tapping on the background closes the Tooltip.
[![Static code analysis](https://github.com/bensonarafat/super_tooltip/actions/workflows/dart.yml/badge.svg)](https://github.com/bensonarafat/super_tooltip/actions/workflows/dart.yml)
[![pub package](https://img.shields.io/pub/v/super_tooltip.svg)](https://pub.dartlang.org/packages/super_tooltip)

`SuperTooltip` It is super flexible and allows you to display ToolTips in the overlay of the screen. It gives you more flexibility over the Flutter standard `Tooltip`. You have the option to make the whole screen covered with a background color. Tapping on the background closes the Tooltip.

<img src="https://github.com/bensonarafat/super_tooltip/blob/master/screenshots/screenshot1.gif?raw=true" width="250"/>


## Installing
## Installing

Run this command:

With Flutter:

```
flutter pub add super_tooltip
```

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

```
Expand All @@ -30,7 +31,8 @@ Now in your Dart code, you can use:
```
import 'package:super_tooltip/super_tooltip.dart';
```
# Getting Started

# Getting Started

You have to make your Widget a `StatefulWidget` and you just need to create a controller to manage state of tooltips, you can do so by defining an instance of a `SuperTooltipController` and pass it through to constructor.

Expand All @@ -47,7 +49,6 @@ You have to make your Widget a `StatefulWidget` and you just need to create a co
}
```


You need to wrap `SuperTooltip` with a `GestureDetector`, `MouseRegion` or `InkWell` that is responsible for showing and hiding the content. Further handling of the tooltip state can be managed explicitly through a controller

```dart
Expand Down Expand Up @@ -114,16 +115,38 @@ SuperTooltip(
//....
),
```

Change Popup direction to `TooltipDirection.right`, `TooltipDirection.left`, `TooltipDirection.bottom` and `TooltipDirection.up`

```dart
SuperTooltip(
popupDirection: TooltipDirection.right,
//...
//...
)
```
<img src="https://github.com/bensonarafat/super_tooltip/blob/master/screenshots/screenshot2.png?raw=true" width="250"/>

## Barrier
## DecorationBuilder

To customize the shape of the popup or apply your own decoration, you can utilize the `decorationBuilder` property. This allows you to access the `target` property and define a custom shape or decoration for the tooltip.

```dart
SuperTooltip(
decorationBuilder:(target){
return ShapeDecoration(
//...
shape: CustomShape(
//...
target: target,
),
);
}
//...
)
```


## Barrier

If you'd like to keep the user from dismissing the tooltip by clicking on the barrier, you can change `showBarrier` to `true` which means pressing on the scrim area will not immediately hide the tooltip.

Expand All @@ -135,18 +158,20 @@ SuperTooltip(
)
```

## Blur
If you'd like to also show blur behind the pop up, you can do that by making the `showDropBoxFilter` to `true` you must also enable `showBarrier` then set `sigmaX` and `sigmaY`
## Blur

If you'd like to also show blur behind the pop up, you can do that by making the `showDropBoxFilter` to `true` you must also enable `showBarrier` then set `sigmaX` and `sigmaY`

```dart
SuperTooltip(
showBarrier: true,
showDropBoxFilter: true,
sigmaX: 10,
sigmaX: 10,
sigmaY: 10,
//...
)
```

<img src="https://github.com/bensonarafat/super_tooltip/blob/master/screenshots/screenshot3.gif?raw=true" width="250"/>

If you'd like to simply react to open or close states, you can pass through `onHide` or `onShow` callbacks to the default constructor.
Expand All @@ -162,7 +187,7 @@ SuperTooltip(
),
```

To hide the tooltip when the user tap the back button. Wrap your `GestureDetector` widget with `WillPopScope` widget passing a callback function to `onWillPop` like the example below
To hide the tooltip when the user tap the back button. Wrap your `GestureDetector` widget with `WillPopScope` widget passing a callback function to `onWillPop` like the example below

```dart
return WillPopScope(
Expand All @@ -176,7 +201,8 @@ To hide the tooltip when the user tap the back button. Wrap your `GestureDetecto
);
```

Create a callback function to dismiss
Create a callback function to dismiss

```dart
Future<bool> _willPopCallback() async {
// If the tooltip is open we don't pop the page on a backbutton press
Expand Down
76 changes: 46 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 All @@ -52,11 +56,13 @@ class SuperTooltip extends StatefulWidget {
final EdgeInsetsGeometry bubbleDimensions;
final bool hideTooltipOnTap;
final bool hideTooltipOnBarrierTap;
final bool toggleOnTap;

//filter
final bool showDropBoxFilter;
final double sigmaX;
final double sigmaY;
final List<BoxShadow>? boxShadows;

SuperTooltip({
Key? key,
Expand Down Expand Up @@ -100,7 +106,7 @@ class SuperTooltip extends StatefulWidget {
//
//
//
this.decoration,
this.decorationBuilder,
this.child,
this.borderColor = Colors.black,
this.constraints = const BoxConstraints(
Expand All @@ -126,6 +132,8 @@ class SuperTooltip extends StatefulWidget {
this.sigmaY = 5.0,
this.showDropBoxFilter = false,
this.hideTooltipOnBarrierTap = true,
this.toggleOnTap = false,
this.boxShadows,
}) : assert(showDropBoxFilter ? showBarrier ?? false : true,
'showDropBoxFilter or showBarrier can\'t be false | null'),
super(key: key);
Expand Down Expand Up @@ -212,7 +220,13 @@ class _SuperTooltipState extends State<SuperTooltip>
return CompositedTransformTarget(
link: _layerLink,
child: GestureDetector(
onTap: _superTooltipController!.showTooltip,
onTap: () {
if (widget.toggleOnTap && _superTooltipController!.isVisible) {
_superTooltipController!.hideTooltip();
} else {
_superTooltipController!.showTooltip();
}
},
onLongPress: widget.onLongPress,
child: widget.child,
),
Expand Down Expand Up @@ -390,34 +404,36 @@ 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
? widget.boxShadows ??
<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
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: super_tooltip
description: Super flexible Tooltip class that gets opend in the screens overlay
version: 2.0.7
version: 2.0.8
homepage: https://github.com/bensonarafat/super_tooltip


Expand Down
Loading