From 8b3da304cb3189f7e0f44bb8b72d60affffc51c6 Mon Sep 17 00:00:00 2001 From: niloysikdar Date: Sun, 2 May 2021 07:24:28 +0530 Subject: [PATCH] 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), ], ), ),