Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Move animation controller from showcase widget to tooltip widget.

- Update Readme.md
  • Loading branch information
ParthBaraiya committed Dec 1, 2021
1 parent 1c54995 commit 355ac19
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 163 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
42 changes: 3 additions & 39 deletions lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,43 +139,11 @@ class Showcase extends StatefulWidget {
_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 @@ -313,7 +276,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 +286,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 355ac19

Please sign in to comment.