From 8b3da304cb3189f7e0f44bb8b72d60affffc51c6 Mon Sep 17 00:00:00 2001 From: niloysikdar Date: Sun, 2 May 2021 07:24:28 +0530 Subject: [PATCH 1/3] Added LoadingAnimation --- lib/screens/addoxygen.dart | 21 +++++++++++++++++++++ lib/screens/plasmaform.dart | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/lib/screens/addoxygen.dart b/lib/screens/addoxygen.dart index 0b8c3ee..0164f64 100644 --- a/lib/screens/addoxygen.dart +++ b/lib/screens/addoxygen.dart @@ -15,10 +15,15 @@ class _AddOxygenDetailsState extends State { late TextEditingController descriptioncontroller; late TextEditingController pincontroller; + bool isUploading = false; + String headerstring = "Please ensure all the data that you are providing are from verified sources.\nFeeding any false information or spamming will lead to permanent ban."; void postPressed() async { + setState(() { + isUploading = true; + }); var oxygenPostModel = OxygenPostModel( title: titlecontroller.text, description: descriptioncontroller.text, @@ -29,6 +34,8 @@ class _AddOxygenDetailsState extends State { ); await DatabaseMethod().uploadOxygen(oxygenPostModel); clearcontrollers(); + isUploading = false; + setState(() {}); } void clearcontrollers() { @@ -132,6 +139,20 @@ class _AddOxygenDetailsState extends State { ), ), ), + (isUploading) + ? Container( + height: double.infinity, + width: double.infinity, + color: Colors.grey.withOpacity(0.5), + child: Center( + child: SizedBox( + height: size.width * 0.2, + width: size.width * 0.2, + child: CircularProgressIndicator(), + ), + ), + ) + : Container(height: 0, width: 0), ], ), ), diff --git a/lib/screens/plasmaform.dart b/lib/screens/plasmaform.dart index 5819d86..ec0fb4d 100644 --- a/lib/screens/plasmaform.dart +++ b/lib/screens/plasmaform.dart @@ -23,6 +23,8 @@ class _PlasmaDonateState extends State { String covidquestion = "Have you ever tested covid positive ?"; int covidStatus = 1; + bool isUploading = false; + @override void initState() { super.initState(); @@ -46,6 +48,9 @@ class _PlasmaDonateState extends State { } void donePressed() async { + setState(() { + isUploading = true; + }); var donorModel = DonorModel( name: namecontroller.text, phone: phonecontroller.text, @@ -59,6 +64,8 @@ class _PlasmaDonateState extends State { ); await DatabaseMethod().uploadDonor(donorModel); clearInput(); + isUploading = false; + setState(() {}); } void clearInput() { @@ -379,6 +386,20 @@ class _PlasmaDonateState extends State { ), ), ), + (isUploading) + ? Container( + height: double.infinity, + width: double.infinity, + color: Colors.grey.withOpacity(0.5), + child: Center( + child: SizedBox( + height: size.width * 0.2, + width: size.width * 0.2, + child: CircularProgressIndicator(), + ), + ), + ) + : Container(height: 0, width: 0), ], ), ), From da4f80c9d7a56f1c3a63534779c6f111d89e5d6d Mon Sep 17 00:00:00 2001 From: niloysikdar Date: Sun, 2 May 2021 07:41:25 +0530 Subject: [PATCH 2/3] 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, + ), + ); +} From 6aa12a0302464e5a79d6cbf8d503dd3cefd9eceb Mon Sep 17 00:00:00 2001 From: niloysikdar Date: Sun, 2 May 2021 07:56:53 +0530 Subject: [PATCH 3/3] Added Toast Message --- lib/screens/homescreen.dart | 13 ++++++++++++- pubspec.lock | 7 +++++++ pubspec.yaml | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/screens/homescreen.dart b/lib/screens/homescreen.dart index 18aeabd..982fc93 100644 --- a/lib/screens/homescreen.dart +++ b/lib/screens/homescreen.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:plaso_connect/constants/colors.dart'; import 'package:plaso_connect/screens/selectoxygen.dart'; import 'package:plaso_connect/screens/selectplasma.dart'; @@ -58,7 +59,17 @@ class HomeScreen extends StatelessWidget { ), homeButton( text: "More", - onTap: () {}, + onTap: () { + Fluttertoast.showToast( + msg: "Coming Soon", + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 1, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 18.0, + ); + }, ), ], ), diff --git a/pubspec.lock b/pubspec.lock index 4155791..2878646 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -170,6 +170,13 @@ packages: description: flutter source: sdk version: "0.0.0" + fluttertoast: + dependency: "direct main" + description: + name: fluttertoast + url: "https://pub.dartlang.org" + source: hosted + version: "8.0.6" google_fonts: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index e12779d..645054e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,6 +31,7 @@ dependencies: firebase_auth: ^1.1.2 cloud_firestore: ^1.0.7 carousel_slider: ^4.0.0-nullsafety.0 + fluttertoast: ^8.0.6 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.