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 Dec 3, 2024
1 parent cf351c2 commit 895c376
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 @@ -564,6 +564,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: Container(
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
Expand Down
6 changes: 6 additions & 0 deletions lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,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 @@ -418,6 +421,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 Down Expand Up @@ -484,6 +488,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 @@ -786,6 +791,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 @@ -44,6 +44,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 @@ -79,6 +80,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 @@ -652,6 +654,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
),
);
}

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

0 comments on commit 895c376

Please sign in to comment.