Skip to content

Commit

Permalink
Updated changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
Salby committed Aug 27, 2019
2 parents a07f1e9 + 213f65f commit e741890
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [Unreleased]

### Added
- Added documentation for `MorpheusPageRoute` transitions.

### Changed
- Improved `MorpheusPageRoute` bidirectional transition when there is no transition widget.

## [1.2.0+3] - 2019-08-26

### Changed
Expand Down
7 changes: 4 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ class HomeScreen extends StatelessWidget {
],
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton(
floatingActionButton: FloatingActionButton.extended(
key: createKey,
child: Icon(Icons.add),
icon: Icon(Icons.add),
label: Text('Create'),
onPressed: () => Navigator.of(context).pushNamed(
'/create',
arguments: MorpheusRouteArguments(
parentKey: createKey,
transitionColor: Theme.of(context).accentColor,
borderRadius: BorderRadius.circular(56.0),
borderRadius: BorderRadius.circular(24.0),
),
),
),
Expand Down
22 changes: 10 additions & 12 deletions lib/page_routes/morpheus_page_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class MorpheusPageRoute<T> extends PageRoute<T> {
final bool scaleChild;

RenderBox _findRenderBox() {

final arguments = settings.arguments as MorpheusRouteArguments;
final key = parentKey ?? arguments?.parentKey;

Expand All @@ -83,7 +82,6 @@ class MorpheusPageRoute<T> extends PageRoute<T> {
_renderBox = renderBox;
return renderBox;
}

}

RenderBox _renderBox;
Expand All @@ -108,20 +106,20 @@ class MorpheusPageRoute<T> extends PageRoute<T> {

@override
Widget buildPage(
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
return Builder(builder: builder);
}

@override
Widget buildTransitions(
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) {
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) {
final routeSettings = settings.arguments as MorpheusRouteArguments;

// Define transition settings.
Expand All @@ -144,4 +142,4 @@ class MorpheusPageRoute<T> extends PageRoute<T> {
settings: transitionSettings,
);
}
}
}
24 changes: 24 additions & 0 deletions lib/page_routes/morpheus_page_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ class MorpheusPageTransition extends StatelessWidget {
/// [transitionWidget] is scaled up before it fades into the [childScreen]
/// that ends up at full-size.
Widget buildBidirectionalTransition(Widget childScreen) {
// Controls the opacity of the [childScreen] in a transition where there is
// no transition widget.
final fadeInAnimation = CurvedAnimation(
parent: animation,
curve: Interval(
0.5,
1.0,
curve: Curves.fastOutSlowIn,
),
);

// The animation that controls the scale of the parent widget.
final Animation<double> scaleParentAnimation = Tween<double>(
begin: 1.0,
Expand All @@ -272,6 +283,19 @@ class MorpheusPageTransition extends StatelessWidget {
)
: Container();

// This transition is used in case there is no transition widget.
if (transitionWidget == null)
return FadeTransition(
opacity: fadeInAnimation,
child: ScaleTransition(
alignment: Alignment.topCenter,
scale: settings.scaleChild
? scaleChildAnimation
: ConstantTween(1.0).animate(positionAnimationCurve),
child: childScreen,
),
);

return FadeTransition(
opacity: PageTransitionOpacityTween(
begin: 0.0,
Expand Down

0 comments on commit e741890

Please sign in to comment.