Skip to content

Commit 1d06866

Browse files
Sahil-Simformaditya-css
authored andcommitted
🩹Updated: Updated name of parameter and also added support for the floatingAction Widget for the default showcase widget
1 parent 25c88ff commit 1d06866

File tree

8 files changed

+218
-31
lines changed

8 files changed

+218
-31
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- Feature ✨: Added `enableAutoScroll` to `showcase`.
99
- Fix [#489](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/489) - Fixed
1010
mounter issue inside the `_scrollIntoView` function
11+
- Feature [#395](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/395) -
12+
Added `floatingActionWidget` to give a static fixed widget at any place on the screen.
1113

1214
## [3.0.0]
1315
- [BREAKING] Fixed [#434](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/434) removed deprecated text style after Flutter 3.22 follow [migration guide](https://docs.flutter.dev/release/breaking-changes/3-19-deprecations#texttheme)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ WidgetsBinding.instance.addPostFrameCallback((_) =>
156156
| globalTooltipActionConfig | TooltipActionConfig? | | Global tooltip actionbar config |
157157
| globalTooltipActions | List<TooltipActionButton>? | | Global list of tooltip actions |
158158
| scrollAlignment | double | 0.5 | For Auto scroll widget alignment |
159+
| globalTooltipActionConfig | FloatingActionWidget | | Global Config for tooltip action to auto apply for all the toolTip |
160+
159161

160162
## Properties of `Showcase` and `Showcase.withWidget`:
161163

@@ -210,6 +212,7 @@ WidgetsBinding.instance.addPostFrameCallback((_) =>
210212
| tooltipActions | List<TooltipActionButton>? | [] | Provide a list of tooltip actions |||
211213
| tooltipActionConfig | TooltipActionConfig? | | Give configurations (alignment, position, etc...) to the tooltip actionbar |||
212214
| enableAutoScroll | bool? | ShowCaseWidget.enableAutoScroll | This is used to override the `ShowCaseWidget.enableAutoScroll` behaviour |||
215+
| floatingActionWidget | FloatingActionWidget | | Provided a floating static action widget to show at any place on the screen |||
213216

214217
## Properties of `TooltipActionButton` and `TooltipActionButton.custom`:
215218

example/lib/main.dart

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,24 @@ class _MailPageState extends State<MailPage> {
256256
"Tap to see profile which contains user's name, profile picture, mobile number and country",
257257
tooltipBackgroundColor: Theme.of(context).primaryColor,
258258
textColor: Colors.white,
259+
floatingActionWidget: FloatingActionWidget(
260+
left: 16,
261+
bottom: 16,
262+
child: Padding(
263+
padding: const EdgeInsets.all(16.0),
264+
child: ElevatedButton(
265+
child: const Text(
266+
'Skip Showcase',
267+
style: TextStyle(
268+
color: Colors.pink,
269+
fontSize: 15,
270+
),
271+
),
272+
onPressed: () =>
273+
ShowCaseWidget.of(context).dismiss(),
274+
),
275+
),
276+
),
259277
targetShapeBorder: const CircleBorder(),
260278
tooltipActionConfig: const TooltipActionConfig(
261279
alignment: MainAxisAlignment.spaceBetween,
@@ -564,32 +582,37 @@ class MailTile extends StatelessWidget {
564582
targetBorderRadius: const BorderRadius.all(
565583
Radius.circular(150),
566584
),
567-
staticContainer: Column(
568-
mainAxisAlignment: MainAxisAlignment.end,
569-
children: [
570-
Padding(
571-
padding: const EdgeInsets.all(16.0),
572-
child: ElevatedButton(
573-
style: ButtonStyle(
574-
backgroundColor: MaterialStateProperty.all<Color>(
575-
Theme.of(context).primaryColor),
576-
shape: MaterialStateProperty.all<
577-
RoundedRectangleBorder>(
578-
RoundedRectangleBorder(
579-
borderRadius: BorderRadius.circular(18.0),
580-
side: BorderSide(
581-
color: Theme.of(context).primaryColor,
582-
width: 2.0,
583-
),
585+
floatingActionWidget: FloatingActionWidget.directional(
586+
textDirection: Directionality.of(context),
587+
start: 0,
588+
bottom: 0,
589+
child: Padding(
590+
padding: const EdgeInsets.all(16.0),
591+
child: ElevatedButton(
592+
style: ButtonStyle(
593+
backgroundColor: MaterialStateProperty.all<Color>(
594+
Theme.of(context).primaryColor),
595+
shape: MaterialStateProperty.all<
596+
RoundedRectangleBorder>(
597+
RoundedRectangleBorder(
598+
borderRadius: BorderRadius.circular(18.0),
599+
side: BorderSide(
600+
color: Theme.of(context).primaryColor,
601+
width: 2.0,
584602
),
585603
),
586604
),
587-
child: const Text('Skip Showcase'),
588-
onPressed: () =>
589-
ShowCaseWidget.of(context).dismiss(),
590605
),
606+
child: const Text(
607+
'Skip Showcase',
608+
style: TextStyle(
609+
color: Colors.white,
610+
fontSize: 15,
611+
),
612+
),
613+
onPressed: () => ShowCaseWidget.of(context).dismiss(),
591614
),
592-
],
615+
),
593616
),
594617
container: Container(
595618
padding: const EdgeInsets.all(10),

lib/showcaseview.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ export 'src/models/tooltip_action_config.dart';
2929
export 'src/showcase.dart';
3030
export 'src/showcase_widget.dart';
3131
export 'src/tooltip_action_button_widget.dart';
32+
export 'src/widget/floating_action_widget.dart';

lib/src/showcase.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import 'shape_clipper.dart';
3535
import 'showcase_widget.dart';
3636
import 'tooltip_action_button_widget.dart';
3737
import 'tooltip_widget.dart';
38+
import 'widget/floating_action_widget.dart';
3839

3940
class Showcase extends StatefulWidget {
4041
/// A key that is unique across the entire app.
@@ -96,8 +97,9 @@ class Showcase extends StatefulWidget {
9697
/// Custom tooltip widget when [Showcase.withWidget] is used.
9798
final Widget? container;
9899

99-
/// Custom static tooltip widget when [Showcase.withWidget] is used.
100-
final Widget? staticContainer;
100+
/// Custom static floating action widget to show a static widget anywhere
101+
/// on the screen
102+
final FloatingActionWidget? floatingActionWidget;
101103

102104
/// Defines background color for tooltip widget.
103105
///
@@ -418,10 +420,10 @@ class Showcase extends StatefulWidget {
418420
this.tooltipActionConfig,
419421
this.scrollAlignment = 0.5,
420422
this.enableAutoScroll,
423+
this.floatingActionWidget,
421424
}) : height = null,
422425
width = null,
423426
container = null,
424-
staticContainer = null,
425427
assert(overlayOpacity >= 0.0 && overlayOpacity <= 1.0,
426428
"overlay opacity must be between 0 and 1."),
427429
assert(onTargetClick == null || disposeOnTap != null,
@@ -471,6 +473,7 @@ class Showcase extends StatefulWidget {
471473
/// - `toolTipSlideEndDistance`: The distance the tooltip slides in from the edge of the screen (defaults to 7dp).
472474
/// - `tooltipActions`: A list of custom actions (widgets) to display within the tooltip.
473475
/// - `tooltipActionConfig`: Configuration options for custom tooltip actions.
476+
/// - `floatingActionWidget`: Custom static floating action widget to show a static widget anywhere
474477
///
475478
/// **Differences from default constructor:**
476479
///
@@ -488,7 +491,7 @@ class Showcase extends StatefulWidget {
488491
required this.width,
489492
required this.container,
490493
required this.child,
491-
this.staticContainer,
494+
this.floatingActionWidget,
492495
this.targetShapeBorder = const RoundedRectangleBorder(
493496
borderRadius: BorderRadius.all(
494497
Radius.circular(8),
@@ -794,7 +797,8 @@ class _ShowcaseState extends State<Showcase> {
794797
titleTextStyle: widget.titleTextStyle,
795798
descTextStyle: widget.descTextStyle,
796799
container: widget.container,
797-
staticContainer: widget.staticContainer,
800+
floatingActionWidget: widget.floatingActionWidget ??
801+
showCaseWidgetState.widget.globalFloatingActionWidget,
798802
tooltipBackgroundColor: widget.tooltipBackgroundColor,
799803
textColor: widget.textColor,
800804
showArrow: widget.showArrow,

lib/src/showcase_widget.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ class ShowCaseWidget extends StatefulWidget {
8383
/// Enable/disable showcase globally. Enabled by default.
8484
final bool enableShowcase;
8585

86+
/// Custom static floating action widget to show a static widget anywhere
87+
/// on the screen for all the showcase widget
88+
final FloatingActionWidget? globalFloatingActionWidget;
89+
8690
/// Global action to apply on every tooltip widget
8791
final List<TooltipActionButton>? globalTooltipActions;
8892

89-
/// Global Config for tooltip action to auto apply for all the toolTip
93+
/// Global Config for tooltip action to auto apply for all the toolTip.
9094
final TooltipActionConfig? globalTooltipActionConfig;
9195

9296
/// A widget that manages multiple Showcase widgets.
@@ -115,6 +119,7 @@ class ShowCaseWidget extends StatefulWidget {
115119
/// - `enableShowcase`: Enables or disables the showcase functionality globally (defaults to `true`).
116120
/// - `globalTooltipActions`: A list of custom actions to be added to all tooltips.
117121
/// - `globalTooltipActionConfig`: Configuration options for the global tooltip actions.
122+
/// - `floatingActionWidget`: Custom static floating action widget to show a static widget anywhere for all the showcase widgets
118123
const ShowCaseWidget({
119124
required this.builder,
120125
this.onFinish,
@@ -132,6 +137,7 @@ class ShowCaseWidget extends StatefulWidget {
132137
this.enableShowcase = true,
133138
this.globalTooltipActionConfig,
134139
this.globalTooltipActions,
140+
this.globalFloatingActionWidget,
135141
});
136142

137143
static GlobalKey? activeTargetWidget(BuildContext context) {

lib/src/tooltip_widget.dart

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import 'get_position.dart';
2929
import 'measure_size.dart';
3030
import 'models/tooltip_action_config.dart';
3131
import 'widget/action_widget.dart';
32+
import 'widget/floating_action_widget.dart';
3233
import 'widget/tooltip_slide_transition.dart';
3334

3435
class ToolTipWidget extends StatefulWidget {
@@ -44,7 +45,7 @@ class ToolTipWidget extends StatefulWidget {
4445
final TextStyle? titleTextStyle;
4546
final TextStyle? descTextStyle;
4647
final Widget? container;
47-
final Widget? staticContainer;
48+
final FloatingActionWidget? floatingActionWidget;
4849
final Color? tooltipBackgroundColor;
4950
final Color? textColor;
5051
final bool showArrow;
@@ -80,7 +81,7 @@ class ToolTipWidget extends StatefulWidget {
8081
required this.titleTextStyle,
8182
required this.descTextStyle,
8283
required this.container,
83-
required this.staticContainer,
84+
required this.floatingActionWidget,
8485
required this.tooltipBackgroundColor,
8586
required this.textColor,
8687
required this.showArrow,
@@ -472,7 +473,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
472473
}
473474

474475
if (widget.container == null) {
475-
return Positioned(
476+
final defaultToolTipWidget = Positioned(
476477
top: contentY,
477478
left: _getLeft(),
478479
right: _getRight(),
@@ -653,9 +654,22 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
653654
),
654655
),
655656
);
657+
658+
if (widget.floatingActionWidget != null) {
659+
return Stack(
660+
fit: StackFit.expand,
661+
children: [
662+
defaultToolTipWidget,
663+
widget.floatingActionWidget!,
664+
],
665+
);
666+
} else {
667+
return defaultToolTipWidget;
668+
}
656669
}
657670

658671
return Stack(
672+
fit: StackFit.expand,
659673
children: <Widget>[
660674
Positioned(
661675
left: _getSpace(),
@@ -723,7 +737,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
723737
),
724738
),
725739
),
726-
if (widget.staticContainer != null) ...[widget.staticContainer!],
740+
if (widget.floatingActionWidget != null) widget.floatingActionWidget!,
727741
],
728742
);
729743
}

0 commit comments

Comments
 (0)