Skip to content

Commit 91c519d

Browse files
Sahil-Simformaditya-css
authored andcommitted
feat: ✨Added Hide functionality for global floating action widget
1 parent 1d06866 commit 91c519d

File tree

6 files changed

+124
-68
lines changed

6 files changed

+124
-68
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
## [4.0.0] (unreleased)
22
- [BREAKING] Fixed [#457](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/457) titleAlignment property does not work
3-
- Feature : Added Action widget for tooltip
3+
- Feature [#466](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/466): Added Action widget for tooltip
44
- Feature [#475](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/475) - Add
55
feasibility to change margin of tooltip with `toolTipMargin`.
66
- Feature [#478](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/478) - Added
77
feasibility to change auto scroll widget alignment `scrollAlignment`.
8-
- Feature : Added `enableAutoScroll` to `showcase`.
8+
- Feature [#386](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/386): Added `enableAutoScroll` to `showcase`.
99
- Fix [#489](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/489) - Fixed
1010
mounter issue inside the `_scrollIntoView` function
1111
- Feature [#395](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/395) -
1212
Added `floatingActionWidget` to give a static fixed widget at any place on the screen.
13+
- Feature [#396](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/396): Added `globalFloatingActionWidget` and `hideFloatingActionWidgetForShowcase` for global
14+
static fixed widget
1315

1416
## [3.0.0]
1517
- [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: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,28 @@ WidgetsBinding.instance.addPostFrameCallback((_) =>
136136

137137
## Properties of `ShowCaseWidget`:
138138

139-
| Name | Type | Default Behaviour | Description |
140-
|---------------------------|----------------------------|------------------------------|--------------------------------------------------------------------------------|
141-
| builder | Builder | | |
142-
| blurValue | double | 0 | Provides blur effect on overlay |
143-
| autoPlay | bool | false | Automatically display Next showcase |
144-
| autoPlayDelay | Duration | Duration(milliseconds: 2000) | Visibility time of showcase when `autoplay` is enabled |
145-
| enableAutoPlayLock | bool | false | Block the user interaction on overlay when autoPlay is enabled. |
146-
| enableAutoScroll | bool | false | Allows to auto scroll to next showcase so as to make the given target visible. |
147-
| scrollDuration | Duration | Duration(milliseconds: 300) | Time duration for auto scrolling |
148-
| disableBarrierInteraction | bool | false | Disable barrier interaction |
149-
| disableScaleAnimation | bool | false | Disable scale transition for all showcases |
150-
| disableMovingAnimation | bool | false | Disable bouncing/moving transition for all showcases |
151-
| onStart | Function(int?, GlobalKey)? | | Triggered on start of each showcase. |
152-
| onComplete | Function(int?, GlobalKey)? | | Triggered on completion of each showcase. |
153-
| onFinish | VoidCallback? | | Triggered when all the showcases are completed |
154-
| enableShowcase | bool | true | Enable or disable showcase globally. |
155-
| toolTipMargin | double | 14 | For tooltip margin |
156-
| globalTooltipActionConfig | TooltipActionConfig? | | Global tooltip actionbar config |
157-
| globalTooltipActions | List<TooltipActionButton>? | | Global list of tooltip actions |
158-
| scrollAlignment | double | 0.5 | For Auto scroll widget alignment |
159-
| globalTooltipActionConfig | FloatingActionWidget | | Global Config for tooltip action to auto apply for all the toolTip |
139+
| Name | Type | Default Behaviour | Description |
140+
|-------------------------------------|----------------------------------------------|------------------------------|--------------------------------------------------------------------------------|
141+
| builder | Builder | | |
142+
| blurValue | double | 0 | Provides blur effect on overlay. |
143+
| autoPlay | bool | false | Automatically display Next showcase. |
144+
| autoPlayDelay | Duration | Duration(milliseconds: 2000) | Visibility time of showcase when `autoplay` is enabled. |
145+
| enableAutoPlayLock | bool | false | Block the user interaction on overlay when autoPlay is enabled. |
146+
| enableAutoScroll | bool | false | Allows to auto scroll to next showcase so as to make the given target visible. |
147+
| scrollDuration | Duration | Duration(milliseconds: 300) | Time duration for auto scrolling. |
148+
| disableBarrierInteraction | bool | false | Disable barrier interaction. |
149+
| disableScaleAnimation | bool | false | Disable scale transition for all showcases. |
150+
| disableMovingAnimation | bool | false | Disable bouncing/moving transition for all showcases. |
151+
| onStart | Function(int?, GlobalKey)? | | Triggered on start of each showcase. |
152+
| onComplete | Function(int?, GlobalKey)? | | Triggered on completion of each showcase. |
153+
| onFinish | VoidCallback? | | Triggered when all the showcases are completed. |
154+
| enableShowcase | bool | true | Enable or disable showcase globally. |
155+
| toolTipMargin | double | 14 | For tooltip margin. |
156+
| globalTooltipActionConfig | TooltipActionConfig? | | Global tooltip actionbar config. |
157+
| globalTooltipActions | List<TooltipActionButton>? | | Global list of tooltip actions . |
158+
| scrollAlignment | double | 0.5 | For Auto scroll widget alignment. |
159+
| globalFloatingActionWidget | FloatingActionWidget Function(BuildContext)? | | Global Config for tooltip action to auto apply for all the toolTip . |
160+
| hideFloatingActionWidgetForShowcase | List<GlobalKey> | [] | Hides globalFloatingActionWidget for the provided showcase widget keys. |
160161

161162

162163
## Properties of `Showcase` and `Showcase.withWidget`:

example/lib/main.dart

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@ class MyApp extends StatelessWidget {
2626
debugShowCheckedModeBanner: false,
2727
home: Scaffold(
2828
body: ShowCaseWidget(
29+
hideFloatingActionWidgetForShowcase: [_lastShowcaseWidget],
30+
globalFloatingActionWidget: (showcaseContext) => FloatingActionWidget(
31+
left: 16,
32+
bottom: 16,
33+
child: Padding(
34+
padding: const EdgeInsets.all(16.0),
35+
child: ElevatedButton(
36+
onPressed: ShowCaseWidget.of(showcaseContext).dismiss,
37+
style: ElevatedButton.styleFrom(
38+
backgroundColor: const Color(0xffEE5366),
39+
),
40+
child: const Text(
41+
'Skip',
42+
style: TextStyle(
43+
color: Colors.white,
44+
fontSize: 15,
45+
),
46+
),
47+
),
48+
),
49+
),
2950
onStart: (index, key) {
3051
log('onStart: $index, $key');
3152
},
@@ -207,8 +228,18 @@ class _MailPageState extends State<MailPage> {
207228
Showcase(
208229
key: _firstShowcaseWidget,
209230
description: 'Tap to see menu options',
210-
onBarrierClick: () =>
211-
debugPrint('Barrier clicked'),
231+
onBarrierClick: () {
232+
debugPrint('Barrier clicked');
233+
debugPrint(
234+
'Floating Action widget for first '
235+
'showcase is now hidden',
236+
);
237+
ShowCaseWidget.of(context)
238+
.hideFloatingActionWidgetForKeys([
239+
_firstShowcaseWidget,
240+
_lastShowcaseWidget
241+
]);
242+
},
212243
tooltipActionConfig:
213244
const TooltipActionConfig(
214245
alignment: MainAxisAlignment.end,
@@ -262,15 +293,17 @@ class _MailPageState extends State<MailPage> {
262293
child: Padding(
263294
padding: const EdgeInsets.all(16.0),
264295
child: ElevatedButton(
296+
style: ElevatedButton.styleFrom(
297+
backgroundColor: const Color(0xffEE5366),
298+
),
299+
onPressed: ShowCaseWidget.of(context).dismiss,
265300
child: const Text(
266-
'Skip Showcase',
301+
'Close Showcase',
267302
style: TextStyle(
268-
color: Colors.pink,
303+
color: Colors.white,
269304
fontSize: 15,
270305
),
271306
),
272-
onPressed: () =>
273-
ShowCaseWidget.of(context).dismiss(),
274307
),
275308
),
276309
),
@@ -582,38 +615,6 @@ class MailTile extends StatelessWidget {
582615
targetBorderRadius: const BorderRadius.all(
583616
Radius.circular(150),
584617
),
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,
602-
),
603-
),
604-
),
605-
),
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(),
614-
),
615-
),
616-
),
617618
container: Container(
618619
padding: const EdgeInsets.all(10),
619620
decoration: const BoxDecoration(

lib/src/showcase.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ class _ShowcaseState extends State<Showcase> {
562562
RenderBox? rootRenderObject;
563563

564564
late final showCaseWidgetState = ShowCaseWidget.of(context);
565+
FloatingActionWidget? _globalFloatingActionWidget;
565566

566567
@override
567568
void initState() {
@@ -577,6 +578,8 @@ class _ShowcaseState extends State<Showcase> {
577578
recalculateRootWidgetSize();
578579

579580
if (_enableShowcase) {
581+
_globalFloatingActionWidget =
582+
showCaseWidgetState.globalFloatingActionWidget?.call(context);
580583
final size = MediaQuery.of(context).size;
581584
position ??= GetPosition(
582585
rootRenderObject: rootRenderObject,
@@ -797,8 +800,8 @@ class _ShowcaseState extends State<Showcase> {
797800
titleTextStyle: widget.titleTextStyle,
798801
descTextStyle: widget.descTextStyle,
799802
container: widget.container,
800-
floatingActionWidget: widget.floatingActionWidget ??
801-
showCaseWidgetState.widget.globalFloatingActionWidget,
803+
floatingActionWidget:
804+
widget.floatingActionWidget ?? _globalFloatingActionWidget,
802805
tooltipBackgroundColor: widget.tooltipBackgroundColor,
803806
textColor: widget.textColor,
804807
showArrow: widget.showArrow,

0 commit comments

Comments
 (0)