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 e54f3df commit 8b8e55d
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 @@ -225,6 +225,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 @@ -420,8 +451,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 @@ -440,7 +472,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 @@ -99,8 +99,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 @@ -291,10 +292,10 @@ class Showcase extends StatefulWidget {
this.titleTextDirection,
this.descriptionTextDirection,
this.onBarrierClick,
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 @@ -308,7 +309,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 @@ -556,7 +557,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 @@ -41,7 +41,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 @@ -74,7 +74,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 @@ -354,7 +354,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 @@ -477,9 +477,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 @@ -514,7 +527,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
),
),
),
if (widget.staticContainer != null) ...[widget.staticContainer!],
if (widget.floatingActionWidget != null) widget.floatingActionWidget!,
],
);
}
Expand Down

0 comments on commit 8b8e55d

Please sign in to comment.