Skip to content

Commit

Permalink
Merge pull request #66 from petro-i/reverese-duration
Browse files Browse the repository at this point in the history
added reverse animation duration and implicit parameter for animation
  • Loading branch information
boyan01 authored Apr 13, 2021
2 parents dcde2f0 + dee4823 commit df0ed0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/src/overlay.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import 'dart:async';
import 'dart:collection';

import 'package:async/async.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:overlay_support/overlay_support.dart';
import 'package:overlay_support/src/theme.dart';

import 'overlay_keys.dart';
import 'overlay_state_finder.dart';

part 'overlay_animation.dart';

part 'overlay_entry.dart';

/// To build a widget with animated value.
Expand Down Expand Up @@ -56,6 +53,8 @@ OverlaySupportEntry showOverlay(
Duration? duration,
Key? key,
BuildContext? context,
Duration? animationDuration,
Duration? reverseAnimationDuration,
}) {
assert(key is! GlobalKey);

Expand Down Expand Up @@ -90,7 +89,8 @@ OverlaySupportEntry showOverlay(
key: stateKey,
builder: builder,
curve: curve,
animationDuration: kNotificationSlideDuration,
animationDuration: animationDuration ?? kNotificationSlideDuration,
reverseAnimationDuration: reverseAnimationDuration ?? kNotificationSlideDuration,
duration: duration ?? kNotificationDuration,
overlayKey: overlayKey,
overlaySupportState: overlaySupport,
Expand Down
12 changes: 10 additions & 2 deletions lib/src/overlay_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ class _AnimatedOverlay extends StatefulWidget {
/// [Duration.zero] means overlay display forever.
final Duration duration;

/// The duration overlay show/hide's animation.
/// The duration overlay show animation.
final Duration animationDuration;

/// The duration overlay hide animation.
final Duration reverseAnimationDuration;

final AnimatedOverlayWidgetBuilder builder;

final Curve curve;
Expand All @@ -19,13 +22,15 @@ class _AnimatedOverlay extends StatefulWidget {
_AnimatedOverlay({
required Key key,
required this.animationDuration,
required this.reverseAnimationDuration,
Curve? curve,
required this.builder,
required this.duration,
required this.overlayKey,
required this.overlaySupportState,
}) : curve = curve ?? Curves.easeInOut,
assert(animationDuration >= Duration.zero),
assert(reverseAnimationDuration >= Duration.zero),
assert(duration >= Duration.zero),
super(key: key);

Expand Down Expand Up @@ -57,7 +62,10 @@ class _AnimatedOverlayState extends State<_AnimatedOverlay> with TickerProviderS
@override
void initState() {
_controller = AnimationController(
vsync: this, duration: widget.animationDuration, debugLabel: 'AnimatedOverlayShowHideAnimation');
vsync: this,
duration: widget.animationDuration,
reverseDuration: widget.reverseAnimationDuration,
debugLabel: 'AnimatedOverlayShowHideAnimation');
super.initState();
final overlayEntry = widget.overlaySupportState.getEntry(key: widget.overlayKey);
_controller.addStatusListener((status) {
Expand Down

0 comments on commit df0ed0b

Please sign in to comment.