Skip to content

Commit

Permalink
Added SlideLeft transition
Browse files Browse the repository at this point in the history
  • Loading branch information
niloysikdar committed May 2, 2021
1 parent 8b3da30 commit da4f80c
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 65 deletions.
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -30,7 +30,7 @@ class MyApp extends StatelessWidget {
primaryColor: kelectronBlue,
iconTheme: IconThemeData(color: kelectronBlue),
),
home: LandingScreen(),
home: SignUpPage(),
);
}
}
13 changes: 4 additions & 9 deletions lib/screens/homescreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -33,9 +34,7 @@ class HomeScreen extends StatelessWidget {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return TotalStatsDashboard();
}),
SlideLeftRoute(page: TotalStatsDashboard()),
);
},
),
Expand All @@ -44,9 +43,7 @@ class HomeScreen extends StatelessWidget {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return SelectPlasma();
}),
SlideLeftRoute(page: SelectPlasma()),
);
},
),
Expand All @@ -55,9 +52,7 @@ class HomeScreen extends StatelessWidget {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return SelectOxygen();
}),
SlideLeftRoute(page: SelectOxygen()),
);
},
),
Expand Down
9 changes: 3 additions & 6 deletions lib/screens/landingScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -39,9 +40,7 @@ class LandingScreen extends StatelessWidget {
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) {
return HomeScreen();
}),
SlideLeftRoute(page: HomeScreen()),
);
},
),
Expand All @@ -50,9 +49,7 @@ class LandingScreen extends StatelessWidget {
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) {
return HomeScreen();
}),
SlideLeftRoute(page: HomeScreen()),
);
},
),
Expand Down
9 changes: 3 additions & 6 deletions lib/screens/selectoxygen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -29,9 +30,7 @@ class SelectOxygen extends StatelessWidget {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return AddOxygenDetails();
}),
SlideLeftRoute(page: AddOxygenDetails()),
);
},
),
Expand All @@ -40,9 +39,7 @@ class SelectOxygen extends StatelessWidget {
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return ShowOxygenPosts();
}),
SlideLeftRoute(page: ShowOxygenPosts()),
);
},
),
Expand Down
73 changes: 36 additions & 37 deletions lib/screens/selectplasma.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
);
},
),
],
),
),
);
}
Expand Down
11 changes: 6 additions & 5 deletions lib/screens/signup.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -61,11 +62,11 @@ class _SignUpPageState extends State<SignUpPage> {
text: "Sign In/Up",
onTap: () {
print("Done");
Navigator.push(
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) {
return PlasmaDonate();
}),
SlideLeftRoute(
page: LandingScreen(),
),
);
},
),
Expand Down
27 changes: 27 additions & 0 deletions lib/services/transitions.dart
Original file line number Diff line number Diff line change
@@ -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<double> animation,
Animation<double> secondaryAnimation,
) =>
page,
transitionsBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
) =>
SlideTransition(
position: Tween<Offset>(
begin: const Offset(1, 0),
end: Offset.zero,
).animate(animation),
child: child,
),
);
}

0 comments on commit da4f80c

Please sign in to comment.