Skip to content

Commit

Permalink
🩹Updated: Updated name of parameter and also added support for the fl…
Browse files Browse the repository at this point in the history
…oatingAction Widget for the default showcase widget
  • Loading branch information
Sahil-Simform committed Oct 22, 2024
1 parent 7915a3b commit 8a55dac
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 11 deletions.
42 changes: 40 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,37 @@ 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,
floatingActionWidget: Align(
alignment: Alignment.bottomLeft,
child: 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',
style: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
onPressed: () =>
ShowCaseWidget.of(context).dismiss(),
),
),
),
targetShapeBorder: const CircleBorder(),
child: Container(
padding: const EdgeInsets.all(5),
Expand Down Expand Up @@ -416,8 +447,9 @@ class MailTile extends StatelessWidget {
targetBorderRadius: const BorderRadius.all(
Radius.circular(150),
),
staticContainer: Column(
floatingActionWidget: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(16.0),
Expand All @@ -436,7 +468,13 @@ class MailTile extends StatelessWidget {
),
),
),
child: const Text('Skip Showcase'),
child: const Text(
'Skip Showcase',
style: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
onPressed: () =>
ShowCaseWidget.of(context).dismiss(),
),
Expand Down
11 changes: 6 additions & 5 deletions lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +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;
/// Custom static floating action widget to show a static widget anywhere
/// on the screen
final Widget? floatingActionWidget;

/// Defines background color for tooltip widget.
///
Expand Down Expand Up @@ -308,10 +309,10 @@ class Showcase extends StatefulWidget {
this.disableBarrierInteraction = false,
this.toolTipSlideEndDistance = 7,
this.toolTipMargin = 14,
this.floatingActionWidget,
}) : 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 @@ -327,7 +328,7 @@ class Showcase extends StatefulWidget {
required this.width,
required this.container,
required this.child,
this.staticContainer,
this.floatingActionWidget,
this.targetShapeBorder = const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(8),
Expand Down Expand Up @@ -622,7 +623,7 @@ class _ShowcaseState extends State<Showcase> {
titleTextStyle: widget.titleTextStyle,
descTextStyle: widget.descTextStyle,
container: widget.container,
staticContainer: widget.staticContainer,
floatingActionWidget: widget.floatingActionWidget,
tooltipBackgroundColor: widget.tooltipBackgroundColor,
textColor: widget.textColor,
showArrow: widget.showArrow,
Expand Down
21 changes: 17 additions & 4 deletions lib/src/tooltip_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ToolTipWidget extends StatefulWidget {
final TextStyle? titleTextStyle;
final TextStyle? descTextStyle;
final Widget? container;
final Widget? staticContainer;
final Widget? floatingActionWidget;
final Color? tooltipBackgroundColor;
final Color? textColor;
final bool showArrow;
Expand Down Expand Up @@ -75,7 +75,7 @@ class ToolTipWidget extends StatefulWidget {
required this.titleTextStyle,
required this.descTextStyle,
required this.container,
required this.staticContainer,
required this.floatingActionWidget,
required this.tooltipBackgroundColor,
required this.textColor,
required this.showArrow,
Expand Down Expand Up @@ -367,7 +367,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
}

if (widget.container == null) {
return Positioned(
final defaultToolTipWidget = Positioned(
top: contentY,
left: _getLeft(),
right: _getRight(),
Expand Down Expand Up @@ -493,9 +493,22 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
),
),
);

if (widget.floatingActionWidget != null) {
return Stack(
fit: StackFit.expand,
children: [
defaultToolTipWidget,
widget.floatingActionWidget!,
],
);
} else {
return defaultToolTipWidget;
}
}

return Stack(
fit: StackFit.expand,
children: <Widget>[
Positioned(
left: _getSpace(),
Expand Down Expand Up @@ -532,7 +545,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
),
),
),
if (widget.staticContainer != null) ...[widget.staticContainer!],
if (widget.floatingActionWidget != null) widget.floatingActionWidget!,
],
);
}
Expand Down

0 comments on commit 8a55dac

Please sign in to comment.