Skip to content

Commit

Permalink
🐛 fix issue SimformSolutionsPvtLtd#121 - SlideTransition widget in to…
Browse files Browse the repository at this point in the history
…oltip_widget.dart is constantly rebuildung even after the showcasing is supposed to have stopped.

- Move animation controller from showcase widget to tooltip widget.

- Update Readme.md
  • Loading branch information
ParthBaraiya committed Dec 2, 2021
1 parent 1c54995 commit e5862c7
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 168 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ Check out the **example** app in the [example](example) directory or the 'Exampl
<td align="center"><a href="https://github.com/AnkitPanchal10"><img src="https://avatars.githubusercontent.com/u/38405884?s=100" width="100px;" alt=""/><br /><sub><b>Ankit Panchal</b></sub></a></td>
<td align="center"><a href="https://github.com/Kashifalaliwala"><img src="https://avatars.githubusercontent.com/u/30998350?s=100" width="100px;" alt=""/><br /><sub><b>Kashifa Laliwala</b></sub></a></td>
<td align="center"><a href="https://github.com/vatsaltanna"><img src="https://avatars.githubusercontent.com/u/25323183?s=100" width="100px;" alt=""/><br /><sub><b>Vatsal Tanna</b></sub></a></td>
<td align="center"><a href="https://github.com/sanket-simform"><img src="https://avatars.githubusercontent.com/u/65167856?v=4" width="100px;" alt=""/><br /><sub><b>Sanket Kachhela</b></sub></a></td>
<td align="center"><a href="https://github.com/parthbaraiya"><img src="https://avatars.githubusercontent.com/u/36261739?v=4" width="100px;" alt=""/><br /><sub><b>Parth Baraiya</b></sub></a></td>
</tr>
</table>
<br/>
Expand Down
52 changes: 9 additions & 43 deletions lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Showcase extends StatefulWidget {
width = null,
container = null,
assert(overlayOpacity >= 0.0 && overlayOpacity <= 1.0,
"overlay opacity should be >= 0.0 and <= 1.0."),
"overlay opacity must be between 0 and 1."),
assert(
onTargetClick == null
? true
Expand Down Expand Up @@ -133,49 +133,17 @@ class Showcase extends StatefulWidget {
}) : showArrow = false,
onToolTipClick = null,
assert(overlayOpacity >= 0.0 && overlayOpacity <= 1.0,
"overlay opacity should be >= 0.0 and <= 1.0.");
"overlay opacity must be between 0 and 1.");

@override
_ShowcaseState createState() => _ShowcaseState();
}

class _ShowcaseState extends State<Showcase> with TickerProviderStateMixin {
class _ShowcaseState extends State<Showcase> {
bool _showShowCase = false;
Animation<double>? _slideAnimation;
late AnimationController _slideAnimationController;
Timer? timer;
GetPosition? position;

@override
void initState() {
super.initState();

_slideAnimationController = AnimationController(
duration: widget.animationDuration,
vsync: this,
)..addStatusListener((status) {
if (status == AnimationStatus.completed) {
_slideAnimationController.reverse();
}
if (_slideAnimationController.isDismissed) {
if (!widget.disableAnimation) {
_slideAnimationController.forward();
}
}
});

_slideAnimation = CurvedAnimation(
parent: _slideAnimationController,
curve: Curves.easeInOut,
);
}

@override
void dispose() {
_slideAnimationController.dispose();
super.dispose();
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
Expand All @@ -188,7 +156,6 @@ class _ShowcaseState extends State<Showcase> with TickerProviderStateMixin {
showOverlay();
}

///
/// show overlay if there is any target widget
///
void showOverlay() {
Expand All @@ -198,7 +165,6 @@ class _ShowcaseState extends State<Showcase> with TickerProviderStateMixin {
});

if (activeStep == widget.key) {
_slideAnimationController.forward();
if (ShowCaseWidget.of(context)!.autoPlay) {
timer = Timer(
Duration(
Expand Down Expand Up @@ -236,9 +202,6 @@ class _ShowcaseState extends State<Showcase> with TickerProviderStateMixin {
timer = null;
}
ShowCaseWidget.of(context)!.completed(widget.key);
if (!widget.disableAnimation) {
_slideAnimationController.forward();
}
}

void _getOnTargetTap() {
Expand Down Expand Up @@ -288,15 +251,17 @@ class _ShowcaseState extends State<Showcase> with TickerProviderStateMixin {
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
color: widget.overlayColor,
color: widget.overlayColor
.withOpacity(widget.overlayOpacity),
),
),
)
: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
color: widget.overlayColor,
color: widget.overlayColor
.withOpacity(widget.overlayOpacity),
),
),
),
Expand All @@ -313,7 +278,6 @@ class _ShowcaseState extends State<Showcase> with TickerProviderStateMixin {
screenSize: screenSize,
title: widget.title,
description: widget.description,
animationOffset: _slideAnimation,
titleTextStyle: widget.titleTextStyle,
descTextStyle: widget.descTextStyle,
container: widget.container,
Expand All @@ -324,6 +288,8 @@ class _ShowcaseState extends State<Showcase> with TickerProviderStateMixin {
contentWidth: widget.width,
onTooltipTap: _getOnTooltipTap,
contentPadding: widget.contentPadding,
disableAnimation: widget.disableAnimation,
animationDuration: widget.animationDuration,
),
],
)
Expand Down
Loading

0 comments on commit e5862c7

Please sign in to comment.