Skip to content

Commit

Permalink
[animations] Remove copy of curves (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer authored Jul 28, 2020
1 parent 987d168 commit 837b1a3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 71 deletions.
6 changes: 4 additions & 2 deletions packages/animations/lib/src/fade_scale_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter/material.dart'
hide decelerateEasing; // ignore: undefined_hidden_name
// TODO(goderbauer): Remove implementation import when material properly exports the file.
import 'package:flutter/src/material/curves.dart'; // ignore: implementation_imports

// TODO(shihaohong): Remove DualTransitionBuilder once flutter/flutter's `stable`
// branch contains DualTransitionBuilder.
import 'dual_transition_builder.dart' as dual_transition_builder;
import 'modal.dart';
import 'utils/curves.dart';

/// The modal transition configuration for a Material fade transition.
///
Expand Down
29 changes: 26 additions & 3 deletions packages/animations/lib/src/shared_axis_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@

import 'package:flutter/animation.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/material.dart'
hide
decelerateEasing, // ignore: undefined_hidden_name
standardEasing, // ignore: undefined_hidden_name
accelerateEasing; // ignore: undefined_hidden_name
// TODO(goderbauer): Remove implementation import when material properly exports the file.
import 'package:flutter/src/material/curves.dart'; // ignore: implementation_imports
import 'package:flutter/widgets.dart';

// TODO(shihaohong): Remove DualTransitionBuilder once flutter/flutter's `stable`
// branch contains DualTransitionBuilder.
import 'dual_transition_builder.dart' as dual_transition_builder;
import 'utils/curves.dart';

/// Determines which type of shared axis transition is used.
enum SharedAxisTransitionType {
Expand Down Expand Up @@ -398,7 +403,7 @@ class _ExitTransition extends StatelessWidget {
final Color fillColor;
final Widget child;

static final Animatable<double> _fadeOutTransition = FlippedCurveTween(
static final Animatable<double> _fadeOutTransition = _FlippedCurveTween(
curve: accelerateEasing,
).chain(CurveTween(curve: const Interval(0.0, 0.3)));

Expand Down Expand Up @@ -478,3 +483,21 @@ class _ExitTransition extends StatelessWidget {
return null; // unreachable
}
}

/// Enables creating a flipped [CurveTween].
///
/// This creates a [CurveTween] that evaluates to a result that flips the
/// tween vertically.
///
/// This tween sequence assumes that the evaluated result has to be a double
/// between 0.0 and 1.0.
class _FlippedCurveTween extends CurveTween {
/// Creates a vertically flipped [CurveTween].
_FlippedCurveTween({
@required Curve curve,
}) : assert(curve != null),
super(curve: curve);

@override
double transform(double t) => 1.0 - super.transform(t);
}
66 changes: 0 additions & 66 deletions packages/animations/lib/src/utils/curves.dart

This file was deleted.

0 comments on commit 837b1a3

Please sign in to comment.