From d8a73ee693567b357bbcd5e78c47f42f28552c25 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Thu, 12 Dec 2024 15:03:16 +0200 Subject: [PATCH 1/2] Fix format errs & warnings, Navigate back on send --- app/lib/screens/preference_screen.dart | 43 +------------------ app/lib/services/idenfy_service.dart | 3 +- app/lib/services/open_kyc_service.dart | 1 - app/lib/widgets/add_farm.dart | 2 +- app/lib/widgets/farm_item.dart | 7 ++- .../widgets/wallets/send_confirmation.dart | 2 + 6 files changed, 12 insertions(+), 46 deletions(-) diff --git a/app/lib/screens/preference_screen.dart b/app/lib/screens/preference_screen.dart index 767cc467f..b58e328b1 100644 --- a/app/lib/screens/preference_screen.dart +++ b/app/lib/screens/preference_screen.dart @@ -12,7 +12,7 @@ import 'package:threebotlogin/events/close_socket_event.dart'; import 'package:threebotlogin/events/events.dart'; import 'package:threebotlogin/helpers/environment.dart'; import 'package:threebotlogin/helpers/globals.dart'; -import 'package:threebotlogin/main.dart'; +import 'package:threebotlogin/helpers/logger.dart'; import 'package:threebotlogin/screens/authentication_screen.dart'; import 'package:threebotlogin/screens/change_pin_screen.dart'; @@ -266,45 +266,6 @@ class _PreferenceScreenState extends ConsumerState { return await checkBiometricsAvailable(); } - void _showDisableFingerprint() { - showDialog( - context: context, - builder: (BuildContext context) => CustomDialog( - type: DialogType.Warning, - image: Icons.warning, - title: 'Disable Fingerprint', - description: - 'Are you sure you want to deactivate fingerprint as authentication method?', - actions: [ - TextButton( - child: const Text('Cancel'), - onPressed: () async { - Navigator.pop(context); - finger = true; - await saveFingerprint(true); - setState(() {}); - }, - ), - TextButton( - child: Text( - 'Yes', - style: Theme.of(context) - .textTheme - .bodyMedium! - .copyWith(color: Theme.of(context).colorScheme.warning), - ), - onPressed: () async { - Navigator.pop(context); - finger = false; - await saveFingerprint(false); - setState(() {}); - }, - ), - ], - ), - ); - } - void _showDialog({delete = false}) { String title = 'Log Out'; String message = 'Are you sure you want to log out?'; @@ -349,7 +310,7 @@ class _PreferenceScreenState extends ConsumerState { deleted = false; } } catch (e) { - print('Failed to delete user due to $e'); + logger.e('Failed to delete user due to $e'); deleted = false; } if (deleted) { diff --git a/app/lib/services/idenfy_service.dart b/app/lib/services/idenfy_service.dart index 170c55c06..47beeb1c6 100644 --- a/app/lib/services/idenfy_service.dart +++ b/app/lib/services/idenfy_service.dart @@ -49,7 +49,8 @@ Future getToken() async { throw Exception('Failed to get token due to ${response.body}'); } -Future getVerificationStatus({required String address}) async { +Future getVerificationStatus( + {required String address}) async { final idenfyServiceUrl = Globals().idenfyServiceUrl; final response = await http.get( diff --git a/app/lib/services/open_kyc_service.dart b/app/lib/services/open_kyc_service.dart index 7db095892..20866b151 100644 --- a/app/lib/services/open_kyc_service.dart +++ b/app/lib/services/open_kyc_service.dart @@ -102,7 +102,6 @@ Future sendVerificationSms() async { return http.post(url, body: encodedBody, headers: requestHeaders); } -// TODO: Remove this method and use update user data Future updateEmailAddressOfUser() async { String timestamp = DateTime.now().millisecondsSinceEpoch.toString(); Uint8List sk = await getPrivateKey(); diff --git a/app/lib/widgets/add_farm.dart b/app/lib/widgets/add_farm.dart index b2efe9e99..88d43cff3 100644 --- a/app/lib/widgets/add_farm.dart +++ b/app/lib/widgets/add_farm.dart @@ -119,7 +119,7 @@ class _NewFarmState extends State { Icons.error, DialogType.Error); return; } - widget.onAddFarm(farm!); + widget.onAddFarm(farm); if (!context.mounted) return; Navigator.pop(context); } diff --git a/app/lib/widgets/farm_item.dart b/app/lib/widgets/farm_item.dart index 1a6a8f121..22477bb12 100644 --- a/app/lib/widgets/farm_item.dart +++ b/app/lib/widgets/farm_item.dart @@ -40,7 +40,10 @@ class _FarmItemWidgetState extends State { super.initState(); currentAddress = widget.farm.walletAddress; walletAddressController.text = currentAddress!; - tfchainAddress = widget.wallets.where((w)=> w.name == widget.farm.walletName).first.tfchainAddress; + tfchainAddress = widget.wallets + .where((w) => w.name == widget.farm.walletName) + .first + .tfchainAddress; } @override @@ -182,7 +185,7 @@ class _FarmItemWidgetState extends State { ? IconButton( onPressed: () { Navigator.of(context).push(MaterialPageRoute( - builder: (context) => ContractsScreen( + builder: (context) => ContactsScreen( chainType: chainType, currentWalletAddress: currentAddress!, wallets: widget.wallets diff --git a/app/lib/widgets/wallets/send_confirmation.dart b/app/lib/widgets/wallets/send_confirmation.dart index 05b388ba8..1602e4b68 100644 --- a/app/lib/widgets/wallets/send_confirmation.dart +++ b/app/lib/widgets/wallets/send_confirmation.dart @@ -164,6 +164,8 @@ class _SendConfirmationWidgetState extends State { loading = false; }); return; + } finally { + Navigator.pop(context); } setState(() { From 75e175585ddc0ca5cfff781566cf951fbb1d295e Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Tue, 17 Dec 2024 09:54:24 +0200 Subject: [PATCH 2/2] Navigate back in try only --- app/lib/widgets/wallets/send_confirmation.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/lib/widgets/wallets/send_confirmation.dart b/app/lib/widgets/wallets/send_confirmation.dart index 1602e4b68..a29b786f7 100644 --- a/app/lib/widgets/wallets/send_confirmation.dart +++ b/app/lib/widgets/wallets/send_confirmation.dart @@ -157,6 +157,7 @@ class _SendConfirmationWidgetState extends State { } await _showDialog('Success!', 'Tokens have been transferred successfully', Icons.check, DialogType.Info); + Navigator.pop(context); } catch (e) { _showDialog('Error', 'Failed to transfer. Please try again.', Icons.error, DialogType.Error); @@ -164,8 +165,6 @@ class _SendConfirmationWidgetState extends State { loading = false; }); return; - } finally { - Navigator.pop(context); } setState(() {