Skip to content

Commit

Permalink
feat: ✨Added Hide functionality for global floating action widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahil-Simform committed Dec 4, 2024
1 parent e4a0b04 commit b55f5cf
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 68 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
## [4.0.0] (unreleased)
- [BREAKING] Fixed [#457](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/457) titleAlignment property does not work
- Feature : Added Action widget for tooltip
- Feature [#466](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/466): Added Action widget for tooltip
- Feature [#475](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/475) - Add
feasibility to change margin of tooltip with `toolTipMargin`.
- Feature [#478](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/478) - Added
feasibility to change auto scroll widget alignment `scrollAlignment`.
- Feature : Added `enableAutoScroll` to `showcase`.
- Feature [#386](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/386): Added `enableAutoScroll` to `showcase`.
- Feature [#395](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/395) -
Added `floatingActionWidget` to give a static fixed widget at any place on the screen.
- Feature [#396](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/396): Added `globalFloatingActionWidget` and `hideFloatingActionWidgetForShowcase` for global
static fixed widget

## [3.0.0]
- [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)
Expand Down
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,28 @@ WidgetsBinding.instance.addPostFrameCallback((_) =>

## Properties of `ShowCaseWidget`:

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


## Properties of `Showcase` and `Showcase.withWidget`:
Expand Down
77 changes: 39 additions & 38 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ class MyApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
home: Scaffold(
body: ShowCaseWidget(
hideFloatingActionWidgetForShowcase: [_lastShowcaseWidget],
globalFloatingActionWidget: (showcaseContext) => FloatingActionWidget(
left: 16,
bottom: 16,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
onPressed: ShowCaseWidget.of(showcaseContext).dismiss,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffEE5366),
),
child: const Text(
'Skip',
style: TextStyle(
color: Colors.white,
fontSize: 15,
),
),
),
),
),
onStart: (index, key) {
log('onStart: $index, $key');
},
Expand Down Expand Up @@ -207,8 +228,18 @@ class _MailPageState extends State<MailPage> {
Showcase(
key: _firstShowcaseWidget,
description: 'Tap to see menu options',
onBarrierClick: () =>
debugPrint('Barrier clicked'),
onBarrierClick: () {
debugPrint('Barrier clicked');
debugPrint(
'Floating Action widget for first '
'showcase is now hidden',
);
ShowCaseWidget.of(context)
.hideFloatingActionWidgetForKeys([
_firstShowcaseWidget,
_lastShowcaseWidget
]);
},
tooltipActionConfig:
const TooltipActionConfig(
alignment: MainAxisAlignment.end,
Expand Down Expand Up @@ -262,15 +293,17 @@ class _MailPageState extends State<MailPage> {
child: Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffEE5366),
),
onPressed: ShowCaseWidget.of(context).dismiss,
child: const Text(
'Skip Showcase',
'Close Showcase',
style: TextStyle(
color: Colors.pink,
color: Colors.white,
fontSize: 15,
),
),
onPressed: () =>
ShowCaseWidget.of(context).dismiss(),
),
),
),
Expand Down Expand Up @@ -582,38 +615,6 @@ class MailTile extends StatelessWidget {
targetBorderRadius: const BorderRadius.all(
Radius.circular(150),
),
floatingActionWidget: FloatingActionWidget.directional(
textDirection: Directionality.of(context),
start: 0,
bottom: 0,
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(),
),
),
),
container: Container(
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
Expand Down
7 changes: 5 additions & 2 deletions lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ class _ShowcaseState extends State<Showcase> {
RenderBox? rootRenderObject;

late final showCaseWidgetState = ShowCaseWidget.of(context);
FloatingActionWidget? _globalFloatingActionWidget;

@override
void initState() {
Expand All @@ -577,6 +578,8 @@ class _ShowcaseState extends State<Showcase> {
recalculateRootWidgetSize();

if (_enableShowcase) {
_globalFloatingActionWidget =
showCaseWidgetState.globalFloatingActionWidget?.call(context);
final size = MediaQuery.of(context).size;
position ??= GetPosition(
rootRenderObject: rootRenderObject,
Expand Down Expand Up @@ -794,8 +797,8 @@ class _ShowcaseState extends State<Showcase> {
titleTextStyle: widget.titleTextStyle,
descTextStyle: widget.descTextStyle,
container: widget.container,
floatingActionWidget: widget.floatingActionWidget ??
showCaseWidgetState.widget.globalFloatingActionWidget,
floatingActionWidget:
widget.floatingActionWidget ?? _globalFloatingActionWidget,
tooltipBackgroundColor: widget.tooltipBackgroundColor,
textColor: widget.textColor,
showArrow: widget.showArrow,
Expand Down
Loading

0 comments on commit b55f5cf

Please sign in to comment.