Skip to content

Commit

Permalink
Format the snack bar
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Sep 8, 2024
1 parent f6d11e4 commit 5f0644a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
26 changes: 18 additions & 8 deletions app/lib/screens/identity_verification_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ class _IdentityVerificationScreenState
}
});
});
getSpending().then((mySpending) => {
setState(() {
spending = mySpending;
})
});
}

@override
Expand Down Expand Up @@ -1617,18 +1622,23 @@ class _IdentityVerificationScreenState
phoneSendDialog(context);
}

Future<void> getSpending() async {
Future<double> getSpending() async {
try {
final mySpending = await getMySpending();
setState(() {
spending = mySpending;
});
return await getMySpending();
} catch (e) {
const loadingSpendingFailure = SnackBar(
content: Text('Failed to load user spending'),
duration: Duration(seconds: 1),
final loadingSpendingFailure = SnackBar(
content: Text(
'Failed to load user spending',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Theme.of(context).colorScheme.errorContainer),
),
duration: Duration(seconds: 2),
);
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(loadingSpendingFailure);
return 0.0;
}
}
}
15 changes: 12 additions & 3 deletions app/lib/screens/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,22 @@ class _AppState extends State<MainScreen> {
print(mounted);
Navigator.of(context).popUntil((route) => route.isFirst);

updateMessage = 'Fetching user data';
setState(() {});
try {
await loadTwinId();
} catch (e) {
const loadingTwinFailure = SnackBar(
content: Text('Failed to load twin information'),
duration: Duration(seconds: 1),
final loadingTwinFailure = SnackBar(
content: Text(
'Failed to load twin information',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Theme.of(context).colorScheme.errorContainer),
),
duration: Duration(seconds: 2),
);
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(loadingTwinFailure);
print('Failed to load twin information due to $e');
}
Expand Down

0 comments on commit 5f0644a

Please sign in to comment.