Skip to content

Commit

Permalink
feat: ✨Add staticContainer into ToolTipWidget for a custom tooltip th…
Browse files Browse the repository at this point in the history
…at can be placed anywhere on screen and is not affected by the animation

Signed-off-by: Michael Angelo Cadavillo <[email protected]>
  • Loading branch information
MichaelCadavillo authored and Sahil-Simform committed Oct 22, 2024
1 parent 72c030b commit 7915a3b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
27 changes: 27 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,33 @@ class MailTile extends StatelessWidget {
targetBorderRadius: const BorderRadius.all(
Radius.circular(150),
),
staticContainer: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Theme.of(context).primaryColor),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
side: BorderSide(
color: Theme.of(context).primaryColor,
width: 2.0,
),
),
),
),
child: const Text('Skip Showcase'),
onPressed: () =>
ShowCaseWidget.of(context).dismiss(),
),
),
],
),
container: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expand Down
6 changes: 6 additions & 0 deletions lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class Showcase extends StatefulWidget {
/// Custom tooltip widget when [Showcase.withWidget] is used.
final Widget? container;

/// Custom static tooltip widget when [Showcase.withWidget] is used.
final Widget? staticContainer;

/// Defines background color for tooltip widget.
///
/// Default to [Colors.white]
Expand Down Expand Up @@ -308,6 +311,7 @@ class Showcase extends StatefulWidget {
}) : height = null,
width = null,
container = null,
staticContainer = null,
assert(overlayOpacity >= 0.0 && overlayOpacity <= 1.0,
"overlay opacity must be between 0 and 1."),
assert(onTargetClick == null || disposeOnTap != null,
Expand All @@ -323,6 +327,7 @@ class Showcase extends StatefulWidget {
required this.width,
required this.container,
required this.child,
this.staticContainer,
this.targetShapeBorder = const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8),
Expand Down Expand Up @@ -617,6 +622,7 @@ class _ShowcaseState extends State<Showcase> {
titleTextStyle: widget.titleTextStyle,
descTextStyle: widget.descTextStyle,
container: widget.container,
staticContainer: widget.staticContainer,
tooltipBackgroundColor: widget.tooltipBackgroundColor,
textColor: widget.textColor,
showArrow: widget.showArrow,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/tooltip_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ToolTipWidget extends StatefulWidget {
final TextStyle? titleTextStyle;
final TextStyle? descTextStyle;
final Widget? container;
final Widget? staticContainer;
final Color? tooltipBackgroundColor;
final Color? textColor;
final bool showArrow;
Expand Down Expand Up @@ -74,6 +75,7 @@ class ToolTipWidget extends StatefulWidget {
required this.titleTextStyle,
required this.descTextStyle,
required this.container,
required this.staticContainer,
required this.tooltipBackgroundColor,
required this.textColor,
required this.showArrow,
Expand Down Expand Up @@ -492,6 +494,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
),
);
}

return Stack(
children: <Widget>[
Positioned(
Expand Down Expand Up @@ -529,6 +532,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
),
),
),
if (widget.staticContainer != null) ...[widget.staticContainer!],
],
);
}
Expand Down

0 comments on commit 7915a3b

Please sign in to comment.