Skip to content

Commit

Permalink
Added LoadingAnimation
Browse files Browse the repository at this point in the history
  • Loading branch information
niloysikdar committed May 2, 2021
1 parent 5b6e93d commit 8b3da30
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/screens/addoxygen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ class _AddOxygenDetailsState extends State<AddOxygenDetails> {
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,
Expand All @@ -29,6 +34,8 @@ class _AddOxygenDetailsState extends State<AddOxygenDetails> {
);
await DatabaseMethod().uploadOxygen(oxygenPostModel);
clearcontrollers();
isUploading = false;
setState(() {});
}

void clearcontrollers() {
Expand Down Expand Up @@ -132,6 +139,20 @@ class _AddOxygenDetailsState extends State<AddOxygenDetails> {
),
),
),
(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),
],
),
),
Expand Down
21 changes: 21 additions & 0 deletions lib/screens/plasmaform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class _PlasmaDonateState extends State<PlasmaDonate> {
String covidquestion = "Have you ever tested covid positive ?";
int covidStatus = 1;

bool isUploading = false;

@override
void initState() {
super.initState();
Expand All @@ -46,6 +48,9 @@ class _PlasmaDonateState extends State<PlasmaDonate> {
}

void donePressed() async {
setState(() {
isUploading = true;
});
var donorModel = DonorModel(
name: namecontroller.text,
phone: phonecontroller.text,
Expand All @@ -59,6 +64,8 @@ class _PlasmaDonateState extends State<PlasmaDonate> {
);
await DatabaseMethod().uploadDonor(donorModel);
clearInput();
isUploading = false;
setState(() {});
}

void clearInput() {
Expand Down Expand Up @@ -379,6 +386,20 @@ class _PlasmaDonateState extends State<PlasmaDonate> {
),
),
),
(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),
],
),
),
Expand Down

0 comments on commit 8b3da30

Please sign in to comment.