From da4f80c9d7a56f1c3a63534779c6f111d89e5d6d Mon Sep 17 00:00:00 2001 From: niloysikdar Date: Sun, 2 May 2021 07:41:25 +0530 Subject: [PATCH] Added SlideLeft transition --- lib/main.dart | 4 +- lib/screens/homescreen.dart | 13 ++---- lib/screens/landingScreen.dart | 9 ++--- lib/screens/selectoxygen.dart | 9 ++--- lib/screens/selectplasma.dart | 73 +++++++++++++++++----------------- lib/screens/signup.dart | 11 ++--- lib/services/transitions.dart | 27 +++++++++++++ 7 files changed, 81 insertions(+), 65 deletions(-) create mode 100644 lib/services/transitions.dart diff --git a/lib/main.dart b/lib/main.dart index f812d65..dd63d6e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:plaso_connect/constants/colors.dart'; -import 'package:plaso_connect/screens/landingScreen.dart'; +import 'package:plaso_connect/screens/signup.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -30,7 +30,7 @@ class MyApp extends StatelessWidget { primaryColor: kelectronBlue, iconTheme: IconThemeData(color: kelectronBlue), ), - home: LandingScreen(), + home: SignUpPage(), ); } } diff --git a/lib/screens/homescreen.dart b/lib/screens/homescreen.dart index 818a3a4..18aeabd 100644 --- a/lib/screens/homescreen.dart +++ b/lib/screens/homescreen.dart @@ -3,6 +3,7 @@ import 'package:plaso_connect/constants/colors.dart'; import 'package:plaso_connect/screens/selectoxygen.dart'; import 'package:plaso_connect/screens/selectplasma.dart'; import 'package:plaso_connect/screens/statdashboard.dart'; +import 'package:plaso_connect/services/transitions.dart'; import 'package:plaso_connect/widgets/boxdecoration.dart'; import 'package:plaso_connect/widgets/logowidget.dart'; @@ -33,9 +34,7 @@ class HomeScreen extends StatelessWidget { onTap: () { Navigator.push( context, - MaterialPageRoute(builder: (context) { - return TotalStatsDashboard(); - }), + SlideLeftRoute(page: TotalStatsDashboard()), ); }, ), @@ -44,9 +43,7 @@ class HomeScreen extends StatelessWidget { onTap: () { Navigator.push( context, - MaterialPageRoute(builder: (context) { - return SelectPlasma(); - }), + SlideLeftRoute(page: SelectPlasma()), ); }, ), @@ -55,9 +52,7 @@ class HomeScreen extends StatelessWidget { onTap: () { Navigator.push( context, - MaterialPageRoute(builder: (context) { - return SelectOxygen(); - }), + SlideLeftRoute(page: SelectOxygen()), ); }, ), diff --git a/lib/screens/landingScreen.dart b/lib/screens/landingScreen.dart index 7b8db34..edf8025 100644 --- a/lib/screens/landingScreen.dart +++ b/lib/screens/landingScreen.dart @@ -2,6 +2,7 @@ import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; import 'package:plaso_connect/constants/colors.dart'; import 'package:plaso_connect/screens/homescreen.dart'; +import 'package:plaso_connect/services/transitions.dart'; import 'package:plaso_connect/widgets/boxdecoration.dart'; class LandingScreen extends StatelessWidget { @@ -39,9 +40,7 @@ class LandingScreen extends StatelessWidget { onTap: () { Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) { - return HomeScreen(); - }), + SlideLeftRoute(page: HomeScreen()), ); }, ), @@ -50,9 +49,7 @@ class LandingScreen extends StatelessWidget { onTap: () { Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) { - return HomeScreen(); - }), + SlideLeftRoute(page: HomeScreen()), ); }, ), diff --git a/lib/screens/selectoxygen.dart b/lib/screens/selectoxygen.dart index 445d33e..f536555 100644 --- a/lib/screens/selectoxygen.dart +++ b/lib/screens/selectoxygen.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:plaso_connect/constants/colors.dart'; import 'package:plaso_connect/screens/addoxygen.dart'; import 'package:plaso_connect/screens/showOxygenposts.dart'; +import 'package:plaso_connect/services/transitions.dart'; import 'package:plaso_connect/widgets/boxdecoration.dart'; class SelectOxygen extends StatelessWidget { @@ -29,9 +30,7 @@ class SelectOxygen extends StatelessWidget { onTap: () { Navigator.push( context, - MaterialPageRoute(builder: (context) { - return AddOxygenDetails(); - }), + SlideLeftRoute(page: AddOxygenDetails()), ); }, ), @@ -40,9 +39,7 @@ class SelectOxygen extends StatelessWidget { onTap: () { Navigator.push( context, - MaterialPageRoute(builder: (context) { - return ShowOxygenPosts(); - }), + SlideLeftRoute(page: ShowOxygenPosts()), ); }, ), diff --git a/lib/screens/selectplasma.dart b/lib/screens/selectplasma.dart index 0a2813f..8f5400d 100644 --- a/lib/screens/selectplasma.dart +++ b/lib/screens/selectplasma.dart @@ -2,50 +2,49 @@ import 'package:flutter/material.dart'; import 'package:plaso_connect/constants/colors.dart'; import 'package:plaso_connect/screens/donorlist.dart'; import 'package:plaso_connect/screens/plasmaform.dart'; +import 'package:plaso_connect/services/transitions.dart'; import 'package:plaso_connect/widgets/boxdecoration.dart'; class SelectPlasma extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - body: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(left: 30, bottom: 15), - child: Text( - "Choose an option :", - style: TextStyle( - color: kelectronBlue, - fontSize: 22, - fontWeight: FontWeight.w600, + return SafeArea( + child: Scaffold( + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 30, bottom: 15), + child: Text( + "Choose an option :", + style: TextStyle( + color: kelectronBlue, + fontSize: 22, + fontWeight: FontWeight.w600, + ), ), ), - ), - selectPlasmaButton( - text: "Donate Plasma/Blood", - onTap: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return PlasmaDonate(); - }), - ); - }, - ), - selectPlasmaButton( - text: "Availbe Donors", - onTap: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return DonorList(); - }), - ); - }, - ), - ], + selectPlasmaButton( + text: "Donate Plasma/Blood", + onTap: () { + Navigator.push( + context, + SlideLeftRoute(page: PlasmaDonate()), + ); + }, + ), + selectPlasmaButton( + text: "Availbe Donors", + onTap: () { + Navigator.push( + context, + SlideLeftRoute(page: DonorList()), + ); + }, + ), + ], + ), ), ); } diff --git a/lib/screens/signup.dart b/lib/screens/signup.dart index 6292673..d3de9fb 100644 --- a/lib/screens/signup.dart +++ b/lib/screens/signup.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:plaso_connect/screens/plasmaform.dart'; +import 'package:plaso_connect/screens/landingScreen.dart'; +import 'package:plaso_connect/services/transitions.dart'; import 'package:plaso_connect/widgets/inputfield.dart'; import 'package:plaso_connect/widgets/loginbutton.dart'; import 'package:plaso_connect/widgets/loginheader.dart'; @@ -61,11 +62,11 @@ class _SignUpPageState extends State { text: "Sign In/Up", onTap: () { print("Done"); - Navigator.push( + Navigator.pushReplacement( context, - MaterialPageRoute(builder: (context) { - return PlasmaDonate(); - }), + SlideLeftRoute( + page: LandingScreen(), + ), ); }, ), diff --git a/lib/services/transitions.dart b/lib/services/transitions.dart new file mode 100644 index 0000000..95a8e9a --- /dev/null +++ b/lib/services/transitions.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class SlideLeftRoute extends PageRouteBuilder { + final Widget page; + SlideLeftRoute({required this.page}) + : super( + pageBuilder: ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + ) => + page, + transitionsBuilder: ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + Widget child, + ) => + SlideTransition( + position: Tween( + begin: const Offset(1, 0), + end: Offset.zero, + ).animate(animation), + child: child, + ), + ); +}