Skip to content

Commit

Permalink
feat: ✨ Tooltip action widget
Browse files Browse the repository at this point in the history
- Added `ToolTipActionButton` class for tooltip action buttons
  • Loading branch information
rashi-simform committed Jul 3, 2024
1 parent 0f3f736 commit 001c0b2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 31 deletions.
55 changes: 24 additions & 31 deletions lib/src/tooltip_action.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

import 'showcase_widget.dart';
import 'toottip_action_button.dart';

/// Default Tooltip action Widget Nav
/// Shows tooltip navigation and index / count elements if the conditions are
Expand All @@ -26,28 +27,23 @@ class DefaultToolTipActionWidget extends StatelessWidget {
var ids = showCaseWidgetState.ids;
var activeWidgetId = showCaseWidgetState.activeWidgetId;
bool isFirstTip = activeWidgetId == 0;
bool isLastTip = activeWidgetId == (ids!.length - 1);
Color disabledIconColor = color?.withOpacity(0.3) ?? Colors.black26;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: (isFirstTip)
? null
: () {
showCaseWidgetState.previous();
},
child: Padding(
if (ids.isNotEmpty && activeWidgetId != null) ...[
ToolTipActionButton(
action: (isFirstTip)
? null
: () {
showCaseWidgetState.previous();
},
padding: padding,
child: Icon(
Icons.keyboard_arrow_left,
size: iconSize,
color: (isFirstTip)
? color?.withOpacity(0.3) ?? Colors.black26
: color,
),
icon: Icons.keyboard_arrow_left,
iconSize: iconSize,
color: (isFirstTip) ? disabledIconColor : color,
),
),
if (ids != null && activeWidgetId != null) ...[
const SizedBox(width: 4.0),
Padding(
padding: padding,
Expand All @@ -60,21 +56,18 @@ class DefaultToolTipActionWidget extends StatelessWidget {
),
),
const SizedBox(width: 4.0),
],
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
showCaseWidgetState.next();
},
child: Padding(
ToolTipActionButton(
action: (isLastTip)
? null
: () {
showCaseWidgetState.next();
},
padding: padding,
child: Icon(
Icons.keyboard_arrow_right,
color: color,
size: iconSize,
),
),
),
icon: Icons.keyboard_arrow_right,
iconSize: iconSize,
color: (isLastTip) ? disabledIconColor : color,
)
],
],
);
}
Expand Down
34 changes: 34 additions & 0 deletions lib/src/toottip_action_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';

class ToolTipActionButton extends StatelessWidget {
const ToolTipActionButton({
super.key,
required this.action,
required this.padding,
required this.icon,
required this.iconSize,
required this.color,
});

final VoidCallback? action;
final EdgeInsetsGeometry padding;
final IconData icon;
final double? iconSize;
final Color? color;

@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: action,
child: Padding(
padding: padding,
child: Icon(
icon,
size: iconSize,
color: color,
),
),
);
}
}

0 comments on commit 001c0b2

Please sign in to comment.