Skip to content

Commit

Permalink
Make the ui more smoother while getting the user spendings
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Sep 9, 2024
1 parent 8f2a9f5 commit 743d56b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions app/lib/screens/identity_verification_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,7 @@ class _IdentityVerificationScreenState
}
});
});
getSpending().then((mySpending) => {
if (Globals().spendingLimit > 0)
{
setState(() {
spending = mySpending;
})
}
});
getSpending();
}

@override
Expand Down Expand Up @@ -1625,9 +1618,13 @@ class _IdentityVerificationScreenState
phoneSendDialog(context);
}

Future<double> getSpending() async {
Future<void> getSpending() async {
if (Globals().spendingLimit <= 0) return;
try {
return await getMySpending();
setState(() {
isLoading = true;
});
spending = await getMySpending();
} catch (e) {
final loadingSpendingFailure = SnackBar(
content: Text(
Expand All @@ -1642,7 +1639,11 @@ class _IdentityVerificationScreenState
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(loadingSpendingFailure);
print('Failed to load user spending due to $e');
return 0.0;
spending = 0.0;
} finally {
setState(() {
isLoading = false;
});
}
}
}

0 comments on commit 743d56b

Please sign in to comment.