@@ -40,6 +40,7 @@ class IdentityVerificationScreenState
4040 bool emailVerified = false ;
4141 bool phoneVerified = false ;
4242 bool isLoading = false ;
43+ bool failed = false ;
4344 bool hidePhoneVerifyButton = false ;
4445 bool emailInputValidated = false ;
4546 int emailCountdown = 60 ;
@@ -196,20 +197,44 @@ class IdentityVerificationScreenState
196197 }
197198
198199 void getUserValues () async {
199- doubleName = (await getDoubleName ())? .replaceAll ('.3bot' , '' ) ?? 'Unknown' ;
200- phrase = (await getPhrase ())! ;
201- final emailMap = await getEmail ();
202- if (emailMap['email' ] != null ) {
203- email = emailMap['email' ]! ;
204- changeEmailController.text = email;
205- emailVerified = (emailMap['sei' ] != null );
206- }
207- final phoneMap = await getPhone ();
208- if (phoneMap['phone' ] != null ) {
209- phone = phoneMap['phone' ]! ;
210- phoneVerified = (phoneMap['spi' ] != null );
200+ setState (() => isLoading = true );
201+ try {
202+ doubleName =
203+ (await getDoubleName ())? .replaceAll ('.3bot' , '' ) ?? 'Unknown' ;
204+ phrase = (await getPhrase ()) ?? '' ;
205+ final emailMap = await getEmail ();
206+ if (emailMap['email' ] != null ) {
207+ email = emailMap['email' ]! ;
208+ changeEmailController.text = email;
209+ emailVerified = (emailMap['sei' ] != null );
210+ }
211+ final phoneMap = await getPhone ();
212+ if (phoneMap['phone' ] != null ) {
213+ phone = phoneMap['phone' ]! ;
214+ phoneVerified = (phoneMap['spi' ] != null );
215+ }
216+ } catch (e) {
217+ setState (() {
218+ failed = true ;
219+ });
220+ logger.e ('Failed to get user values due to $e ' );
221+ if (context.mounted) {
222+ final loadingFarmsFailure = SnackBar (
223+ content: Text (
224+ 'Failed to get user values' ,
225+ style: Theme .of (context)
226+ .textTheme
227+ .bodyMedium!
228+ .copyWith (color: Theme .of (context).colorScheme.errorContainer),
229+ ),
230+ duration: const Duration (seconds: 3 ),
231+ );
232+ ScaffoldMessenger .of (context).clearSnackBars ();
233+ ScaffoldMessenger .of (context).showSnackBar (loadingFarmsFailure);
234+ }
235+ } finally {
236+ if (mounted) setState (() => isLoading = false );
211237 }
212- setState (() {});
213238 }
214239
215240 Future copySeedPhrase () async {
@@ -619,9 +644,44 @@ class IdentityVerificationScreenState
619644
620645 @override
621646 Widget build (BuildContext context) {
622- return LayoutDrawer (
623- titleText: 'Identity' ,
624- content: Padding (
647+ final Widget content;
648+ if (isLoading) {
649+ content = Center (
650+ child: Column (
651+ mainAxisAlignment: MainAxisAlignment .center,
652+ children: [
653+ const CircularProgressIndicator (),
654+ const SizedBox (height: 15 ),
655+ Text (
656+ 'Loading identity information...' ,
657+ style: Theme .of (context).textTheme.bodyLarge! .copyWith (
658+ color: Theme .of (context).colorScheme.onSurface,
659+ fontWeight: FontWeight .bold),
660+ ),
661+ ],
662+ ));
663+ } else if (failed) {
664+ content = Center (
665+ child: Column (
666+ mainAxisAlignment: MainAxisAlignment .center,
667+ children: [
668+ const SizedBox (height: 15 ),
669+ ElevatedButton .icon (
670+ icon: const Icon (Icons .refresh),
671+ label: const Text ('Try Again' ),
672+ onPressed: () {
673+ setState (() {
674+ failed = false ;
675+ isLoading = true ;
676+ });
677+ getUserValues ();
678+ },
679+ ),
680+ ],
681+ ),
682+ );
683+ } else {
684+ content = Padding (
625685 padding: const EdgeInsets .symmetric (horizontal: 4.0 ),
626686 child: SingleChildScrollView (
627687 child: Column (
@@ -641,16 +701,18 @@ class IdentityVerificationScreenState
641701 title: Text (doubleName),
642702 ),
643703 customDivider (context: context),
644- Padding (
645- padding: const EdgeInsets .only (right: 2.0 ),
646- child: ListTile (
647- trailing: const Icon (Icons .visibility),
648- leading: const Icon (Icons .vpn_key),
649- title: const Text ('Show phrase' ),
650- onTap: _showPhrase,
704+ if (phrase.isNotEmpty) ...[
705+ Padding (
706+ padding: const EdgeInsets .only (right: 2.0 ),
707+ child: ListTile (
708+ trailing: const Icon (Icons .visibility),
709+ leading: const Icon (Icons .vpn_key),
710+ title: const Text ('Show phrase' ),
711+ onTap: _showPhrase,
712+ ),
651713 ),
652- ),
653- customDivider (context : context) ,
714+ customDivider (context : context ),
715+ ] ,
654716 infoWidget (1 , email, Icons .email, emailVerified),
655717 customDivider (context: context),
656718 infoWidget (2 , phone, Icons .phone, phoneVerified),
@@ -661,7 +723,12 @@ class IdentityVerificationScreenState
661723 ],
662724 ),
663725 ),
664- ),
726+ );
727+ }
728+
729+ return LayoutDrawer (
730+ titleText: 'Identity' ,
731+ content: content,
665732 );
666733 }
667734}
0 commit comments