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

feat: ❇️ Provide tooltip action buttons #466

Merged

Conversation

harsh-u-simform
Copy link
Contributor

@harsh-u-simform harsh-u-simform commented Aug 2, 2024

Description

This PR allows us to provide the list of tooltip action button with configurations.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have followed the Contributor Guide when preparing my PR.
  • [ ] I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Video of the new feature

379697654-ed82cee2-f283-49e8-bfe5-a79f66e151eb.webm

@harsh-u-simform harsh-u-simform self-assigned this Aug 2, 2024
@harsh-u-simform harsh-u-simform force-pushed the feature/tooltip_button_action_widget branch 2 times, most recently from 3507ecb to 2408212 Compare August 2, 2024 12:52
faiyaz-shaikh and others added 6 commits October 24, 2024 15:01
- Added `toolTipAction` parameter in `Showcase` which is used to get action widget configuration and defaults to `null`
- Added `DefaultToolTipActionWidget` class for default tooltip action widgets
- Added `ToolTipActionButton` class for tooltip action buttons
@Sahil-Simform Sahil-Simform force-pushed the feature/tooltip_button_action_widget branch 6 times, most recently from 34cb40f to 685adf3 Compare October 25, 2024 06:36
@@ -1,500 +0,0 @@
// !$*UTF8*$!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should not be changed.

CHANGELOG.md Show resolved Hide resolved
@@ -221,7 +236,34 @@ class _MailPageState extends State<MailPage> {
"Tap to see profile which contains user's name, profile picture, mobile number and country",
tooltipBackgroundColor: Theme.of(context).primaryColor,
textColor: Colors.white,
onTargetClick: () {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unrelated changes from this PR.

backgroundColor: Colors.pink.shade50,
textStyle: const TextStyle(
color: Colors.pink,
)),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format the code.

@@ -26,11 +26,10 @@ import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'enum.dart';
import '../showcaseview.dart';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for this import?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason for this import; it just reduces the number of other imports needed.

Removing this and adding individual file imports.

@@ -299,12 +309,14 @@ class Showcase extends StatefulWidget {
this.tooltipPosition,
this.titlePadding,
this.descriptionPadding,
this.tooltipActions,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put action and config together in constructor

: widget.tooltipActions ?? [];

final actionWidgets = <Widget>[];
for (var action = 0; action < actionData.length; action++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use for in loop

),
],
],
);
}

List<Widget> _getTooltipActions() {
final showCaseState = ShowCaseWidget.of(context);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use context check before this

),
child: TooltipActionButtonWidget(
config: actionData[action],
showCaseState: ShowCaseWidget.of(context),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to pass this state? We can access it directly from the widget.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToolTip is not a child of the ShowCaseWidget, so we won't get the showCaseState directly in the tooltip action using the context. Therefore, we passed that as an argument.

image

@Sahil-Simform Sahil-Simform force-pushed the feature/tooltip_button_action_widget branch 7 times, most recently from f2180b7 to 8b2c1fe Compare October 28, 2024 04:32
lib/src/showcase.dart Outdated Show resolved Hide resolved
Comment on lines 221 to 222
var maxTextWidth =
max(toolTipActionSize?.width ?? 0, max(titleLength, descriptionLength));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At line 242, you have considered textPadding for condition but not here. Why is that?

Comment on lines 241 to 245
if ((toolTipActionSize?.width ?? 0) >=
(max(titleLength, descriptionLength) + textPadding)) {
tooltipWidth = toolTipActionSize?.width ?? 0;
} else {
tooltipWidth = maxTextWidth + textPadding;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here can we use maxTextWidth in some to simplify this?

lib/src/tooltip_widget.dart Show resolved Hide resolved
lib/src/tooltip_widget.dart Show resolved Hide resolved
Comment on lines 766 to 767
tempPos = Offset(position!.dx, position!.dy + size!.height);
setState(() => position = tempPos);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add mounted check and use ??

lib/src/tooltip_widget.dart Show resolved Hide resolved
Comment on lines 30 to 34
padding: EdgeInsets.only(
top: isArrowUp ? tooltipActionConfig.gapBetweenContentAndAction : 0.0,
bottom:
!isArrowUp ? tooltipActionConfig.gapBetweenContentAndAction : 0.0,
).add(outSidePadding),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do add operation in build.

Comment on lines 234 to 236
(widget.tooltipPadding ?? EdgeInsets.zero).horizontal +
max((widget.titlePadding ?? EdgeInsets.zero).horizontal,
(widget.descriptionPadding ?? EdgeInsets.zero).horizontal);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point just create a variable named zeroPadding.

lib/src/showcase.dart Show resolved Hide resolved
@Sahil-Simform Sahil-Simform force-pushed the feature/tooltip_button_action_widget branch 2 times, most recently from b425f85 to a2fd3db Compare October 28, 2024 11:00
@Sahil-Simform Sahil-Simform force-pushed the feature/tooltip_button_action_widget branch from a2fd3db to 17af25d Compare October 28, 2024 12:56
@Sahil-Simform Sahil-Simform force-pushed the feature/tooltip_button_action_widget branch 3 times, most recently from 52b6ca7 to ac00df9 Compare November 21, 2024 13:40
@Sahil-Simform Sahil-Simform force-pushed the feature/tooltip_button_action_widget branch 2 times, most recently from 706a9f3 to bcf824a Compare November 25, 2024 12:39

return config.button ??
GestureDetector(
onTap: handleOnTap,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check if the onTap working with the button containing a transparent background. Here there chance the tap event might be received by the background barrier tap.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it will work on transparent part for that user has to provide the padding as needed.
Updated Example application for this.

}

final availableSpaceForText =
(widget.position?.screenWidth ?? MediaQuery.of(context).size.width) -

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a documentation comment here explaining the logic of getting available space for text

@Sahil-Simform Sahil-Simform force-pushed the feature/tooltip_button_action_widget branch from bcf824a to da9b99b Compare November 27, 2024 14:11
@Sahil-Simform Sahil-Simform force-pushed the feature/tooltip_button_action_widget branch from da9b99b to 2dad8a5 Compare November 29, 2024 12:59
@vatsaltanna-simformsolutions vatsaltanna-simformsolutions merged commit c1eb606 into master Dec 2, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants