Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

animated route #147

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
52 changes: 26 additions & 26 deletions lib/utils/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ import '../ui/views/launches/index.dart';
import '../ui/views/vehicles/index.dart';
import '../ui/widgets/index.dart';

//Animation for route
dynamic animateRoute(RouteSettings pageSetting, Widget routeName) {
return PageRouteBuilder(
settings: pageSetting,
pageBuilder: (context, animation, secondaryAnimation) => routeName,
transitionDuration: Duration(milliseconds: 600),
reverseTransitionDuration: Duration(milliseconds: 600),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
var begin = Offset(0.0, 1.0);
var end = Offset.zero;
var curve = Curves.ease;
var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
return SlideTransition(
position: animation.drive(tween),
child: child,
);
},
);
}

/// Class that holds both route names & generate methods.
/// Used by the Flutter routing system
class Routes {
Expand All @@ -15,36 +35,20 @@ class Routes {

switch (routeSettings.name) {
case StartScreen.route:
return MaterialPageRoute(
settings: routeSettings,
builder: (_) => StartScreen(),
);
return animateRoute(routeSettings, StartScreen());

case AboutScreen.route:
return MaterialPageRoute(
settings: routeSettings,
builder: (_) => AboutScreen(),
);
return animateRoute(routeSettings, AboutScreen());

case ChangelogScreen.route:
return MaterialPageRoute(
settings: routeSettings,
builder: (_) => ChangelogScreen(),
);
return animateRoute(routeSettings, ChangelogScreen());

case SettingsScreen.route:
return MaterialPageRoute(
settings: routeSettings,
builder: (_) => SettingsScreen(),
);
return animateRoute(routeSettings, SettingsScreen());

case LaunchPage.route:
final id = args['id'] as String;

return MaterialPageRoute(
settings: routeSettings,
builder: (_) => LaunchPage(id),
);
return animateRoute(routeSettings, LaunchPage(id));

case CorePage.route:
final launchId = args['launchId'] as String;
Expand Down Expand Up @@ -88,11 +92,7 @@ class Routes {

case VehiclePage.route:
final id = args['id'] as String;

return MaterialPageRoute(
settings: routeSettings,
builder: (_) => VehiclePage(vehicleId: id),
);
return animateRoute(routeSettings, VehiclePage(vehicleId: id));

default:
return errorRoute(routeSettings);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: cherry
description: Simple yet powerful, open-source SpaceX launch tracker.

version: 2.14.0+80
version: 2.14.0+81

environment:
sdk: ">=2.10.0 <3.0.0"
Expand Down