From 5a251248c1c11bc876e52722701ab38b2f70cd70 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Sun, 2 Feb 2025 16:03:26 +0200 Subject: [PATCH 1/2] Change home logo specs, Edit text size --- app/lib/helpers/globals.dart | 7 +- app/lib/helpers/login_helpers.dart | 1 - app/lib/main.dart | 1 - app/lib/models/wallet.dart | 2 +- app/lib/providers/wallets_provider.dart | 34 ++-- .../screens/identity_verification_screen.dart | 176 +++++++++--------- app/lib/screens/wallets/contacts.dart | 5 +- app/lib/services/contact_service.dart | 2 +- app/lib/services/idenfy_service.dart | 4 +- app/lib/services/identity_service.dart | 3 +- .../services/shared_preference_service.dart | 1 - app/lib/services/wallet_service.dart | 10 +- app/lib/widgets/add_farm.dart | 5 +- app/lib/widgets/farm_item.dart | 6 +- app/lib/widgets/home_logo.dart | 112 +++++------ app/lib/widgets/phone_widget.dart | 5 +- app/lib/widgets/wallets/add_wallet.dart | 10 +- app/lib/widgets/wallets/wallet_card.dart | 2 +- app/lib/widgets/wizard/common_page.dart | 4 +- .../widgets/wizard/terms_and_conditions.dart | 2 +- 20 files changed, 194 insertions(+), 198 deletions(-) diff --git a/app/lib/helpers/globals.dart b/app/lib/helpers/globals.dart index bae45b37..82e3cc29 100644 --- a/app/lib/helpers/globals.dart +++ b/app/lib/helpers/globals.dart @@ -5,10 +5,9 @@ import 'package:threebotlogin/models/payment_request.dart'; class NoAnimationTabController extends TabController { NoAnimationTabController( - {int initialIndex = 0, - required int length, - required TickerProvider vsync}) - : super(initialIndex: initialIndex, length: length, vsync: vsync); + {super.initialIndex, + required super.length, + required super.vsync}); @override void animateTo(int value, diff --git a/app/lib/helpers/login_helpers.dart b/app/lib/helpers/login_helpers.dart index 3719f434..cec1e512 100644 --- a/app/lib/helpers/login_helpers.dart +++ b/app/lib/helpers/login_helpers.dart @@ -49,7 +49,6 @@ Future?> readScopeAsObject( scope['digitalTwin'] = 'OK'; } - if (scopePermissionsDecoded['walletAddress'] == true) { scope['walletAddressData'] = { 'address': scopePermissionsDecoded['walletAddressData'] diff --git a/app/lib/main.dart b/app/lib/main.dart index 89ba0ff6..1abb6b26 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -52,7 +52,6 @@ Future setGlobalValues() async { Globals().emailVerified.value = (email['sei'] != null); Globals().phoneVerified.value = (phone['spi'] != null); - } class MyApp extends ConsumerWidget { diff --git a/app/lib/models/wallet.dart b/app/lib/models/wallet.dart index 497e61af..9978b5c2 100644 --- a/app/lib/models/wallet.dart +++ b/app/lib/models/wallet.dart @@ -26,7 +26,7 @@ class Wallet { String stellarBalance; String tfchainBalance; final WalletType type; - VerificationState verificationStatus; + VerificationState verificationStatus; } class PkidWallet { diff --git a/app/lib/providers/wallets_provider.dart b/app/lib/providers/wallets_provider.dart index 03ae6b68..87e5894b 100644 --- a/app/lib/providers/wallets_provider.dart +++ b/app/lib/providers/wallets_provider.dart @@ -50,24 +50,24 @@ class WalletsNotifier extends StateNotifier> { }); } -Future verifyWallet(String walletName) async { - final idenfyServiceUrl = Globals().idenfyServiceUrl; - await _mutex.protect(() async { - final wallet = state.where((w) => w.name == walletName).firstOrNull; - if (wallet != null) { - try { - final updatedVerificationStatus = await getVerificationStatus( - address: wallet.tfchainAddress, - idenfyServiceUrl: idenfyServiceUrl, - ); - wallet.verificationStatus = updatedVerificationStatus.status; - state = [...state]; - } catch (e) { - logger.e('[verifyWallet] Error during verification: $e'); + Future verifyWallet(String walletName) async { + final idenfyServiceUrl = Globals().idenfyServiceUrl; + await _mutex.protect(() async { + final wallet = state.where((w) => w.name == walletName).firstOrNull; + if (wallet != null) { + try { + final updatedVerificationStatus = await getVerificationStatus( + address: wallet.tfchainAddress, + idenfyServiceUrl: idenfyServiceUrl, + ); + wallet.verificationStatus = updatedVerificationStatus.status; + state = [...state]; + } catch (e) { + logger.e('[verifyWallet] Error during verification: $e'); + } } - } - }); -} + }); + } void reloadBalances() async { if (!_reload) return await TFChainService.disconnect(); diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 23965a7e..8d5d436c 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -184,13 +184,12 @@ class _IdentityVerificationScreenState ), ); } - + @override Widget build(BuildContext context) { return LayoutDrawer( titleText: 'Identity', - content: - FutureBuilder( + content: FutureBuilder( future: getEmail(), builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.done) { @@ -198,55 +197,57 @@ class _IdentityVerificationScreenState return pleaseWait(context); } return Padding( - padding: const EdgeInsets.symmetric(horizontal: 4.0), - child: SingleChildScrollView( - child: Column( - children: [ - const SizedBox(height: 20), - AnimatedBuilder( - animation: Listenable.merge([ - Globals().emailVerified, - Globals().phoneVerified, - ]), - builder: (BuildContext context, _) { - return Column( - children: [ - ListTile( - leading: const Icon(Icons.person), - title: Text( - doubleName.isNotEmpty - ? doubleName.substring( - 0, doubleName.length - 5) - : 'Unknown', - ), - ), - customDivider(context: context), - FutureBuilder( - future: getPhrase(), - builder: (context, snapshot) { - if (snapshot.hasData) { - return Padding( - padding: const EdgeInsets.only(right: 2.0), - child: ListTile( - trailing: const Icon(Icons.visibility), - leading: const Icon(Icons.vpn_key), - title: const Text('Show phrase'), - onTap: () async { - _showPhrase(); - }, - ), - ); - } else { - return Container(); - } - }, - ), - customDivider(context: context), + padding: const EdgeInsets.symmetric(horizontal: 4.0), + child: SingleChildScrollView( + child: Column( + children: [ + const SizedBox(height: 20), + AnimatedBuilder( + animation: Listenable.merge([ + Globals().emailVerified, + Globals().phoneVerified, + ]), + builder: (BuildContext context, _) { + return Column( + children: [ + ListTile( + leading: const Icon(Icons.person), + title: Text( + doubleName.isNotEmpty + ? doubleName.substring( + 0, doubleName.length - 5) + : 'Unknown', + ), + ), + customDivider(context: context), + FutureBuilder( + future: getPhrase(), + builder: (context, snapshot) { + if (snapshot.hasData) { + return Padding( + padding: + const EdgeInsets.only(right: 2.0), + child: ListTile( + trailing: + const Icon(Icons.visibility), + leading: const Icon(Icons.vpn_key), + title: const Text('Show phrase'), + onTap: () async { + _showPhrase(); + }, + ), + ); + } else { + return Container(); + } + }, + ), + customDivider(context: context), // Step one: verify email _fillCard( - getCorrectState(1, emailVerified, - phoneVerified), + getCorrectState( + 1, emailVerified, phoneVerified), 1, email, Icons.email), @@ -257,8 +258,8 @@ class _IdentityVerificationScreenState (Globals().spendingLimit > 0 && spending > Globals().spendingLimit)) ? _fillCard( - getCorrectState(2, emailVerified, - phoneVerified), + getCorrectState( + 2, emailVerified, phoneVerified), 2, phone, Icons.phone) @@ -267,25 +268,21 @@ class _IdentityVerificationScreenState const ListTile( leading: Icon(Icons.info), title: Text( - 'KYC Verification has been moved to wallet page.' - ), - ), - + 'KYC Verification has been moved to wallet page.'), + ), ], ); }) ], ), - ) - - ); + )); } return pleaseWait(context); }, ), ); } - + Future copySeedPhrase() async { Clipboard.setData(ClipboardData(text: (await getPhrase()).toString())); @@ -522,9 +519,7 @@ class _IdentityVerificationScreenState children: [ Expanded( child: Text( - (text.isEmpty - ? 'Unknown' - : text), + (text.isEmpty ? 'Unknown' : text), ), ) ], @@ -595,35 +590,34 @@ class _IdentityVerificationScreenState valueListenable: countdownNotifier, builder: (context, countdownValue, child) { return Padding( - padding: const EdgeInsets.only(left: 12), - child: ElevatedButton( - onPressed: countdownValue > 0 - ? null - : () async { - switch (step) { - // Verify email - case 1: - { - startOrResumeEmailCountdown( - startNew: true); - verifyEmail(); - } - break; - - // Verify phone - case 2: - { - await verifyPhone(); - } - break; - default: - {} - break; - } - }, - child: const Text('Verify'))); - } - ) + padding: const EdgeInsets.only(left: 12), + child: ElevatedButton( + onPressed: countdownValue > 0 + ? null + : () async { + switch (step) { + // Verify email + case 1: + { + startOrResumeEmailCountdown( + startNew: true); + verifyEmail(); + } + break; + + // Verify phone + case 2: + { + await verifyPhone(); + } + break; + default: + {} + break; + } + }, + child: const Text('Verify'))); + }) ], ), )) diff --git a/app/lib/screens/wallets/contacts.dart b/app/lib/screens/wallets/contacts.dart index e434eb20..8904672e 100644 --- a/app/lib/screens/wallets/contacts.dart +++ b/app/lib/screens/wallets/contacts.dart @@ -141,8 +141,9 @@ class _ContactsScreenState extends State { children: [ ContactsWidget( contacts: myWalletContacts - .where( - (c) => c.address != widget.currentWalletAddress && c.type == widget.chainType) + .where((c) => + c.address != widget.currentWalletAddress && + c.type == widget.chainType) .toList(), onSelectToAddress: widget.onSelectToAddress), ContactsWidget( diff --git a/app/lib/services/contact_service.dart b/app/lib/services/contact_service.dart index 05c7644d..5733acc4 100644 --- a/app/lib/services/contact_service.dart +++ b/app/lib/services/contact_service.dart @@ -24,7 +24,7 @@ Future> getPkidContacts() async { try { pKidResult = await client.getPKidDoc('contacts'); if (pKidResult.containsKey('error')) { - if (pKidResult.containsValue('Key is not found')){ + if (pKidResult.containsValue('Key is not found')) { return []; } logger.e('Error in pKidResult : ${pKidResult['error']}'); diff --git a/app/lib/services/idenfy_service.dart b/app/lib/services/idenfy_service.dart index 3d851e68..3adf766a 100644 --- a/app/lib/services/idenfy_service.dart +++ b/app/lib/services/idenfy_service.dart @@ -6,7 +6,8 @@ import 'package:threebotlogin/services/tfchain_service.dart'; import 'package:convert/convert.dart'; import 'package:threebotlogin/models/idenfy.dart'; -Future> _prepareRequestHeaders({required String walletSecretSeed} ) async { +Future> _prepareRequestHeaders( + {required String walletSecretSeed}) async { final idenfyServiceUrl = Globals().idenfyServiceUrl; final signer = await getSignerFromSeed(walletSecretSeed); final now = DateTime.now().millisecondsSinceEpoch; @@ -50,7 +51,6 @@ Future getToken(String seed) async { Future getVerificationStatus( {required String address, required String idenfyServiceUrl}) async { - final response = await http.get( Uri.https(idenfyServiceUrl, '/api/v1/status', {'client_id': address}), ); diff --git a/app/lib/services/identity_service.dart b/app/lib/services/identity_service.dart index c3e2d093..d0cf0287 100644 --- a/app/lib/services/identity_service.dart +++ b/app/lib/services/identity_service.dart @@ -7,8 +7,7 @@ String getFullNameOfObject(Map identityName) { return fullName != '' ? fullName : '$firstName $middleName $lastName'; } -String getCorrectState( - int step, emailVerified, phoneVerified) { +String getCorrectState(int step, emailVerified, phoneVerified) { if (step == 1) { if (!emailVerified) { return 'CurrentPhase'; diff --git a/app/lib/services/shared_preference_service.dart b/app/lib/services/shared_preference_service.dart index 3be150c2..d98b5d0a 100644 --- a/app/lib/services/shared_preference_service.dart +++ b/app/lib/services/shared_preference_service.dart @@ -230,7 +230,6 @@ Future savePhone(String phone, String? signedPhoneIdentifier) async { client.setPKidDoc('phone', json.encode({'phone': phone})); } - /// /// /// Methods for derived seed diff --git a/app/lib/services/wallet_service.dart b/app/lib/services/wallet_service.dart index 4c69aa1c..eca977a5 100644 --- a/app/lib/services/wallet_service.dart +++ b/app/lib/services/wallet_service.dart @@ -32,7 +32,7 @@ Future> getPkidWallets() async { try { pKidResult = await client.getPKidDoc('purse'); if (pKidResult.containsKey('error')) { - if (pKidResult.containsValue('Key is not found')){ + if (pKidResult.containsValue('Key is not found')) { return []; } logger.e('Error in pKidResult : ${pKidResult['error']}'); @@ -64,7 +64,8 @@ Future> listWallets() async { final List wallets = await compute((void _) async { final List> walletFutures = []; for (final w in pkidWallets) { - final walletFuture = loadWallet(w.name, w.seed, w.type, chainUrl, idenfyServiceUrl); + final walletFuture = + loadWallet(w.name, w.seed, w.type, chainUrl, idenfyServiceUrl); walletFutures.add(walletFuture); } return await Future.wait(walletFutures); @@ -121,8 +122,9 @@ Future loadWallet(String walletName, String walletSeed, final stellarBalance = balances.first.toString(); final tfchainBalance = balances.last.toString() == '0.0' ? '0' : balances.last.toString(); - final kycVerified = - await getVerificationStatus(address: tfchainClient.keypair!.address,idenfyServiceUrl: idenfyServiceUrl ); + final kycVerified = await getVerificationStatus( + address: tfchainClient.keypair!.address, + idenfyServiceUrl: idenfyServiceUrl); final wallet = Wallet( name: walletName, stellarSecret: stellarClient.secretSeed, diff --git a/app/lib/widgets/add_farm.dart b/app/lib/widgets/add_farm.dart index 6a630034..dd357bd0 100644 --- a/app/lib/widgets/add_farm.dart +++ b/app/lib/widgets/add_farm.dart @@ -76,8 +76,9 @@ class _NewFarmState extends State { Farm? farm; try { final idenfyServiceUrl = Globals().idenfyServiceUrl; - final kycVerified = - await getVerificationStatus(address: _selectedWallet!.tfchainAddress, idenfyServiceUrl: idenfyServiceUrl); + final kycVerified = await getVerificationStatus( + address: _selectedWallet!.tfchainAddress, + idenfyServiceUrl: idenfyServiceUrl); if (kycVerified.status == VerificationState.VERIFIED) { final f = await createFarm(farmName, _selectedWallet!.tfchainSecret, _selectedWallet!.stellarAddress); diff --git a/app/lib/widgets/farm_item.dart b/app/lib/widgets/farm_item.dart index 5081fb17..c22780ae 100644 --- a/app/lib/widgets/farm_item.dart +++ b/app/lib/widgets/farm_item.dart @@ -238,9 +238,11 @@ class _FarmItemWidgetState extends State { children: [ IconButton( onPressed: () async { - final idenfyServiceUrl = Globals().idenfyServiceUrl; + final idenfyServiceUrl = + Globals().idenfyServiceUrl; final kycVerified = await getVerificationStatus( - address: tfchainAddress!, idenfyServiceUrl: idenfyServiceUrl); + address: tfchainAddress!, + idenfyServiceUrl: idenfyServiceUrl); if (kycVerified.status != VerificationState.VERIFIED) { showDialog( diff --git a/app/lib/widgets/home_logo.dart b/app/lib/widgets/home_logo.dart index f83f8a5c..aa7346f7 100644 --- a/app/lib/widgets/home_logo.dart +++ b/app/lib/widgets/home_logo.dart @@ -7,65 +7,65 @@ class HomeLogoWidget extends StatelessWidget { const HomeLogoWidget({super.key, required this.animate}); @override -Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center( - child: animate - ? Column( - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( - width: 50, - height: 50, - child: Lottie.asset( - 'assets/tfloading.json', - repeat: true, - animate: true, + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Center( + child: animate + ? Column( + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox( + width: 45, + height: 45, + child: Lottie.asset( + 'assets/tfloading.json', + repeat: true, + animate: true, + ), + ), + const SizedBox(height: 10), + Text( + 'THREEFOLD', + style: + Theme.of(context).textTheme.headlineLarge!.copyWith( + color: Theme.of(context).colorScheme.onSurface, + fontWeight: FontWeight.bold, + ), + ), + ], + ) + : SizedBox( + height: 90, + child: SvgPicture.asset( + 'assets/TF_logo.svg', + alignment: Alignment.center, + colorFilter: ColorFilter.mode( + Theme.of(context).colorScheme.onSurface, + BlendMode.srcIn, ), - ), - const SizedBox(height: 10), - Text( - 'THREEFOLD', - style: Theme.of(context).textTheme.headlineSmall!.copyWith( - color: Theme.of(context).colorScheme.onSurface, - fontWeight: FontWeight.bold, - ), - ), - ], - ) - : SizedBox( - height: 50, - child: SvgPicture.asset( - 'assets/TF_logo.svg', - alignment: Alignment.center, - colorFilter: ColorFilter.mode( - Theme.of(context).colorScheme.onSurface, - BlendMode.srcIn, ), ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.04, + width: MediaQuery.of(context).size.width * 0.6, + child: Divider( + thickness: 2, + color: Theme.of(context).colorScheme.primary, + ), + ), + Text( + 'CONNECT', + style: Theme.of(context).textTheme.titleLarge!.copyWith( + color: Theme.of(context).colorScheme.onSurface, + letterSpacing: 10, + fontWeight: FontWeight.bold, ), - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.04, - width: MediaQuery.of(context).size.width * 0.6, - child: Divider( - thickness: 2, - color: Theme.of(context).colorScheme.primary, ), - ), - Text( - 'CONNECT', - style: Theme.of(context).textTheme.titleLarge!.copyWith( - color: Theme.of(context).colorScheme.onSurface, - letterSpacing: 10, - fontWeight: FontWeight.bold, - ), - ), - ], - ); -} - + ], + ); + } } diff --git a/app/lib/widgets/phone_widget.dart b/app/lib/widgets/phone_widget.dart index f8696019..7cdbddd3 100644 --- a/app/lib/widgets/phone_widget.dart +++ b/app/lib/widgets/phone_widget.dart @@ -54,11 +54,10 @@ class PhoneAlertDialog extends StatefulWidget { final String oldPhone; const PhoneAlertDialog( - {Key? key, + {super.key, required this.defaultCountryCode, required this.newPhone, - required this.oldPhone}) - : super(key: key); + required this.oldPhone}); @override State createState() { diff --git a/app/lib/widgets/wallets/add_wallet.dart b/app/lib/widgets/wallets/add_wallet.dart index a75646a9..4ed98aab 100644 --- a/app/lib/widgets/wallets/add_wallet.dart +++ b/app/lib/widgets/wallets/add_wallet.dart @@ -139,7 +139,8 @@ class _NewWalletState extends ConsumerState { return false; } - if (walletSecret.startsWith('S') && widget.wallets.any((wallet) => wallet.stellarSecret == walletSecret)){ + if (walletSecret.startsWith('S') && + widget.wallets.any((wallet) => wallet.stellarSecret == walletSecret)) { secretError = 'Secret already exists'; return false; } @@ -152,9 +153,9 @@ class _NewWalletState extends ConsumerState { secretError = 'Invalid seed'; return false; } - if (widget.wallets.any((wallet) => wallet.tfchainSecret == walletSecret)){ + if (widget.wallets.any((wallet) => wallet.tfchainSecret == walletSecret)) { secretError = 'Secret already exists'; - return false; + return false; } if (!walletSecret.startsWith('0x') && walletSecret.length != 64) { secretError = 'Invalid seed length'; @@ -307,7 +308,8 @@ Future loadAddedWallet(String walletName, String walletSecret, final chainUrl = Globals().chainUrl; final idenfyServiceUrl = Globals().idenfyServiceUrl; final Wallet wallet = await compute((void _) async { - final wallet = await loadWallet(walletName, walletSecret, type, chainUrl, idenfyServiceUrl); + final wallet = await loadWallet( + walletName, walletSecret, type, chainUrl, idenfyServiceUrl); return wallet; }, null); return wallet; diff --git a/app/lib/widgets/wallets/wallet_card.dart b/app/lib/widgets/wallets/wallet_card.dart index ae77ec94..52b14e12 100644 --- a/app/lib/widgets/wallets/wallet_card.dart +++ b/app/lib/widgets/wallets/wallet_card.dart @@ -189,7 +189,7 @@ class _WalletCardWidgetState extends ConsumerState { ), borderRadius: BorderRadius.circular(20), ), - child: Text(capitalize(wallet.verificationStatus.name), + child: Text(capitalize(wallet.verificationStatus.name), style: Theme.of(context).textTheme.bodySmall!.copyWith( color: wallet.verificationStatus == VerificationState.VERIFIED diff --git a/app/lib/widgets/wizard/common_page.dart b/app/lib/widgets/wizard/common_page.dart index 46e7dd42..5e7af5cb 100644 --- a/app/lib/widgets/wizard/common_page.dart +++ b/app/lib/widgets/wizard/common_page.dart @@ -15,7 +15,7 @@ class CommonPage extends StatefulWidget { final bool? showTermsAndConditions; const CommonPage({ - Key? key, + super.key, required this.title, required this.subtitle, required this.imagePath, @@ -23,7 +23,7 @@ class CommonPage extends StatefulWidget { this.heightPercentage = 100, this.widthPercentage = 300, this.showTermsAndConditions = false, - }) : super(key: key); + }); @override State createState() => _CommonPageState(); diff --git a/app/lib/widgets/wizard/terms_and_conditions.dart b/app/lib/widgets/wizard/terms_and_conditions.dart index 48cb22a8..db0ea99b 100644 --- a/app/lib/widgets/wizard/terms_and_conditions.dart +++ b/app/lib/widgets/wizard/terms_and_conditions.dart @@ -5,7 +5,7 @@ import 'package:threebotlogin/widgets/custom_dialog.dart'; import 'package:threebotlogin/helpers/globals.dart'; class TermsAndConditions extends StatefulWidget { - const TermsAndConditions({Key? key}) : super(key: key); + const TermsAndConditions({super.key}); @override State createState() => _TermsAndConditionsState(); From 87f9a9b09895234ac2561942f52e82992a82f1a1 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Sun, 2 Feb 2025 16:07:28 +0200 Subject: [PATCH 2/2] Revert last commit --- app/lib/helpers/globals.dart | 5 +- app/lib/helpers/login_helpers.dart | 1 - app/lib/main.dart | 1 - app/lib/models/wallet.dart | 2 +- app/lib/providers/wallets_provider.dart | 34 ++-- .../screens/identity_verification_screen.dart | 176 +++++++++--------- app/lib/screens/wallets/contacts.dart | 5 +- app/lib/services/contact_service.dart | 2 +- app/lib/services/idenfy_service.dart | 4 +- app/lib/services/identity_service.dart | 3 +- .../services/shared_preference_service.dart | 1 - app/lib/services/wallet_service.dart | 10 +- app/lib/widgets/add_farm.dart | 5 +- app/lib/widgets/farm_item.dart | 6 +- app/lib/widgets/home_logo.dart | 112 +++++------ app/lib/widgets/phone_widget.dart | 5 +- app/lib/widgets/wallets/add_wallet.dart | 10 +- app/lib/widgets/wallets/wallet_card.dart | 2 +- app/lib/widgets/wizard/common_page.dart | 4 +- .../widgets/wizard/terms_and_conditions.dart | 2 +- 20 files changed, 192 insertions(+), 198 deletions(-) diff --git a/app/lib/helpers/globals.dart b/app/lib/helpers/globals.dart index bae45b37..0ba858b1 100644 --- a/app/lib/helpers/globals.dart +++ b/app/lib/helpers/globals.dart @@ -5,10 +5,7 @@ import 'package:threebotlogin/models/payment_request.dart'; class NoAnimationTabController extends TabController { NoAnimationTabController( - {int initialIndex = 0, - required int length, - required TickerProvider vsync}) - : super(initialIndex: initialIndex, length: length, vsync: vsync); + {super.initialIndex, required super.length, required super.vsync}); @override void animateTo(int value, diff --git a/app/lib/helpers/login_helpers.dart b/app/lib/helpers/login_helpers.dart index 3719f434..cec1e512 100644 --- a/app/lib/helpers/login_helpers.dart +++ b/app/lib/helpers/login_helpers.dart @@ -49,7 +49,6 @@ Future?> readScopeAsObject( scope['digitalTwin'] = 'OK'; } - if (scopePermissionsDecoded['walletAddress'] == true) { scope['walletAddressData'] = { 'address': scopePermissionsDecoded['walletAddressData'] diff --git a/app/lib/main.dart b/app/lib/main.dart index 89ba0ff6..1abb6b26 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -52,7 +52,6 @@ Future setGlobalValues() async { Globals().emailVerified.value = (email['sei'] != null); Globals().phoneVerified.value = (phone['spi'] != null); - } class MyApp extends ConsumerWidget { diff --git a/app/lib/models/wallet.dart b/app/lib/models/wallet.dart index 497e61af..9978b5c2 100644 --- a/app/lib/models/wallet.dart +++ b/app/lib/models/wallet.dart @@ -26,7 +26,7 @@ class Wallet { String stellarBalance; String tfchainBalance; final WalletType type; - VerificationState verificationStatus; + VerificationState verificationStatus; } class PkidWallet { diff --git a/app/lib/providers/wallets_provider.dart b/app/lib/providers/wallets_provider.dart index 03ae6b68..87e5894b 100644 --- a/app/lib/providers/wallets_provider.dart +++ b/app/lib/providers/wallets_provider.dart @@ -50,24 +50,24 @@ class WalletsNotifier extends StateNotifier> { }); } -Future verifyWallet(String walletName) async { - final idenfyServiceUrl = Globals().idenfyServiceUrl; - await _mutex.protect(() async { - final wallet = state.where((w) => w.name == walletName).firstOrNull; - if (wallet != null) { - try { - final updatedVerificationStatus = await getVerificationStatus( - address: wallet.tfchainAddress, - idenfyServiceUrl: idenfyServiceUrl, - ); - wallet.verificationStatus = updatedVerificationStatus.status; - state = [...state]; - } catch (e) { - logger.e('[verifyWallet] Error during verification: $e'); + Future verifyWallet(String walletName) async { + final idenfyServiceUrl = Globals().idenfyServiceUrl; + await _mutex.protect(() async { + final wallet = state.where((w) => w.name == walletName).firstOrNull; + if (wallet != null) { + try { + final updatedVerificationStatus = await getVerificationStatus( + address: wallet.tfchainAddress, + idenfyServiceUrl: idenfyServiceUrl, + ); + wallet.verificationStatus = updatedVerificationStatus.status; + state = [...state]; + } catch (e) { + logger.e('[verifyWallet] Error during verification: $e'); + } } - } - }); -} + }); + } void reloadBalances() async { if (!_reload) return await TFChainService.disconnect(); diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 23965a7e..8d5d436c 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -184,13 +184,12 @@ class _IdentityVerificationScreenState ), ); } - + @override Widget build(BuildContext context) { return LayoutDrawer( titleText: 'Identity', - content: - FutureBuilder( + content: FutureBuilder( future: getEmail(), builder: (ctx, snapshot) { if (snapshot.connectionState == ConnectionState.done) { @@ -198,55 +197,57 @@ class _IdentityVerificationScreenState return pleaseWait(context); } return Padding( - padding: const EdgeInsets.symmetric(horizontal: 4.0), - child: SingleChildScrollView( - child: Column( - children: [ - const SizedBox(height: 20), - AnimatedBuilder( - animation: Listenable.merge([ - Globals().emailVerified, - Globals().phoneVerified, - ]), - builder: (BuildContext context, _) { - return Column( - children: [ - ListTile( - leading: const Icon(Icons.person), - title: Text( - doubleName.isNotEmpty - ? doubleName.substring( - 0, doubleName.length - 5) - : 'Unknown', - ), - ), - customDivider(context: context), - FutureBuilder( - future: getPhrase(), - builder: (context, snapshot) { - if (snapshot.hasData) { - return Padding( - padding: const EdgeInsets.only(right: 2.0), - child: ListTile( - trailing: const Icon(Icons.visibility), - leading: const Icon(Icons.vpn_key), - title: const Text('Show phrase'), - onTap: () async { - _showPhrase(); - }, - ), - ); - } else { - return Container(); - } - }, - ), - customDivider(context: context), + padding: const EdgeInsets.symmetric(horizontal: 4.0), + child: SingleChildScrollView( + child: Column( + children: [ + const SizedBox(height: 20), + AnimatedBuilder( + animation: Listenable.merge([ + Globals().emailVerified, + Globals().phoneVerified, + ]), + builder: (BuildContext context, _) { + return Column( + children: [ + ListTile( + leading: const Icon(Icons.person), + title: Text( + doubleName.isNotEmpty + ? doubleName.substring( + 0, doubleName.length - 5) + : 'Unknown', + ), + ), + customDivider(context: context), + FutureBuilder( + future: getPhrase(), + builder: (context, snapshot) { + if (snapshot.hasData) { + return Padding( + padding: + const EdgeInsets.only(right: 2.0), + child: ListTile( + trailing: + const Icon(Icons.visibility), + leading: const Icon(Icons.vpn_key), + title: const Text('Show phrase'), + onTap: () async { + _showPhrase(); + }, + ), + ); + } else { + return Container(); + } + }, + ), + customDivider(context: context), // Step one: verify email _fillCard( - getCorrectState(1, emailVerified, - phoneVerified), + getCorrectState( + 1, emailVerified, phoneVerified), 1, email, Icons.email), @@ -257,8 +258,8 @@ class _IdentityVerificationScreenState (Globals().spendingLimit > 0 && spending > Globals().spendingLimit)) ? _fillCard( - getCorrectState(2, emailVerified, - phoneVerified), + getCorrectState( + 2, emailVerified, phoneVerified), 2, phone, Icons.phone) @@ -267,25 +268,21 @@ class _IdentityVerificationScreenState const ListTile( leading: Icon(Icons.info), title: Text( - 'KYC Verification has been moved to wallet page.' - ), - ), - + 'KYC Verification has been moved to wallet page.'), + ), ], ); }) ], ), - ) - - ); + )); } return pleaseWait(context); }, ), ); } - + Future copySeedPhrase() async { Clipboard.setData(ClipboardData(text: (await getPhrase()).toString())); @@ -522,9 +519,7 @@ class _IdentityVerificationScreenState children: [ Expanded( child: Text( - (text.isEmpty - ? 'Unknown' - : text), + (text.isEmpty ? 'Unknown' : text), ), ) ], @@ -595,35 +590,34 @@ class _IdentityVerificationScreenState valueListenable: countdownNotifier, builder: (context, countdownValue, child) { return Padding( - padding: const EdgeInsets.only(left: 12), - child: ElevatedButton( - onPressed: countdownValue > 0 - ? null - : () async { - switch (step) { - // Verify email - case 1: - { - startOrResumeEmailCountdown( - startNew: true); - verifyEmail(); - } - break; - - // Verify phone - case 2: - { - await verifyPhone(); - } - break; - default: - {} - break; - } - }, - child: const Text('Verify'))); - } - ) + padding: const EdgeInsets.only(left: 12), + child: ElevatedButton( + onPressed: countdownValue > 0 + ? null + : () async { + switch (step) { + // Verify email + case 1: + { + startOrResumeEmailCountdown( + startNew: true); + verifyEmail(); + } + break; + + // Verify phone + case 2: + { + await verifyPhone(); + } + break; + default: + {} + break; + } + }, + child: const Text('Verify'))); + }) ], ), )) diff --git a/app/lib/screens/wallets/contacts.dart b/app/lib/screens/wallets/contacts.dart index e434eb20..8904672e 100644 --- a/app/lib/screens/wallets/contacts.dart +++ b/app/lib/screens/wallets/contacts.dart @@ -141,8 +141,9 @@ class _ContactsScreenState extends State { children: [ ContactsWidget( contacts: myWalletContacts - .where( - (c) => c.address != widget.currentWalletAddress && c.type == widget.chainType) + .where((c) => + c.address != widget.currentWalletAddress && + c.type == widget.chainType) .toList(), onSelectToAddress: widget.onSelectToAddress), ContactsWidget( diff --git a/app/lib/services/contact_service.dart b/app/lib/services/contact_service.dart index 05c7644d..5733acc4 100644 --- a/app/lib/services/contact_service.dart +++ b/app/lib/services/contact_service.dart @@ -24,7 +24,7 @@ Future> getPkidContacts() async { try { pKidResult = await client.getPKidDoc('contacts'); if (pKidResult.containsKey('error')) { - if (pKidResult.containsValue('Key is not found')){ + if (pKidResult.containsValue('Key is not found')) { return []; } logger.e('Error in pKidResult : ${pKidResult['error']}'); diff --git a/app/lib/services/idenfy_service.dart b/app/lib/services/idenfy_service.dart index 3d851e68..3adf766a 100644 --- a/app/lib/services/idenfy_service.dart +++ b/app/lib/services/idenfy_service.dart @@ -6,7 +6,8 @@ import 'package:threebotlogin/services/tfchain_service.dart'; import 'package:convert/convert.dart'; import 'package:threebotlogin/models/idenfy.dart'; -Future> _prepareRequestHeaders({required String walletSecretSeed} ) async { +Future> _prepareRequestHeaders( + {required String walletSecretSeed}) async { final idenfyServiceUrl = Globals().idenfyServiceUrl; final signer = await getSignerFromSeed(walletSecretSeed); final now = DateTime.now().millisecondsSinceEpoch; @@ -50,7 +51,6 @@ Future getToken(String seed) async { Future getVerificationStatus( {required String address, required String idenfyServiceUrl}) async { - final response = await http.get( Uri.https(idenfyServiceUrl, '/api/v1/status', {'client_id': address}), ); diff --git a/app/lib/services/identity_service.dart b/app/lib/services/identity_service.dart index c3e2d093..d0cf0287 100644 --- a/app/lib/services/identity_service.dart +++ b/app/lib/services/identity_service.dart @@ -7,8 +7,7 @@ String getFullNameOfObject(Map identityName) { return fullName != '' ? fullName : '$firstName $middleName $lastName'; } -String getCorrectState( - int step, emailVerified, phoneVerified) { +String getCorrectState(int step, emailVerified, phoneVerified) { if (step == 1) { if (!emailVerified) { return 'CurrentPhase'; diff --git a/app/lib/services/shared_preference_service.dart b/app/lib/services/shared_preference_service.dart index 3be150c2..d98b5d0a 100644 --- a/app/lib/services/shared_preference_service.dart +++ b/app/lib/services/shared_preference_service.dart @@ -230,7 +230,6 @@ Future savePhone(String phone, String? signedPhoneIdentifier) async { client.setPKidDoc('phone', json.encode({'phone': phone})); } - /// /// /// Methods for derived seed diff --git a/app/lib/services/wallet_service.dart b/app/lib/services/wallet_service.dart index 4c69aa1c..eca977a5 100644 --- a/app/lib/services/wallet_service.dart +++ b/app/lib/services/wallet_service.dart @@ -32,7 +32,7 @@ Future> getPkidWallets() async { try { pKidResult = await client.getPKidDoc('purse'); if (pKidResult.containsKey('error')) { - if (pKidResult.containsValue('Key is not found')){ + if (pKidResult.containsValue('Key is not found')) { return []; } logger.e('Error in pKidResult : ${pKidResult['error']}'); @@ -64,7 +64,8 @@ Future> listWallets() async { final List wallets = await compute((void _) async { final List> walletFutures = []; for (final w in pkidWallets) { - final walletFuture = loadWallet(w.name, w.seed, w.type, chainUrl, idenfyServiceUrl); + final walletFuture = + loadWallet(w.name, w.seed, w.type, chainUrl, idenfyServiceUrl); walletFutures.add(walletFuture); } return await Future.wait(walletFutures); @@ -121,8 +122,9 @@ Future loadWallet(String walletName, String walletSeed, final stellarBalance = balances.first.toString(); final tfchainBalance = balances.last.toString() == '0.0' ? '0' : balances.last.toString(); - final kycVerified = - await getVerificationStatus(address: tfchainClient.keypair!.address,idenfyServiceUrl: idenfyServiceUrl ); + final kycVerified = await getVerificationStatus( + address: tfchainClient.keypair!.address, + idenfyServiceUrl: idenfyServiceUrl); final wallet = Wallet( name: walletName, stellarSecret: stellarClient.secretSeed, diff --git a/app/lib/widgets/add_farm.dart b/app/lib/widgets/add_farm.dart index 6a630034..dd357bd0 100644 --- a/app/lib/widgets/add_farm.dart +++ b/app/lib/widgets/add_farm.dart @@ -76,8 +76,9 @@ class _NewFarmState extends State { Farm? farm; try { final idenfyServiceUrl = Globals().idenfyServiceUrl; - final kycVerified = - await getVerificationStatus(address: _selectedWallet!.tfchainAddress, idenfyServiceUrl: idenfyServiceUrl); + final kycVerified = await getVerificationStatus( + address: _selectedWallet!.tfchainAddress, + idenfyServiceUrl: idenfyServiceUrl); if (kycVerified.status == VerificationState.VERIFIED) { final f = await createFarm(farmName, _selectedWallet!.tfchainSecret, _selectedWallet!.stellarAddress); diff --git a/app/lib/widgets/farm_item.dart b/app/lib/widgets/farm_item.dart index 5081fb17..c22780ae 100644 --- a/app/lib/widgets/farm_item.dart +++ b/app/lib/widgets/farm_item.dart @@ -238,9 +238,11 @@ class _FarmItemWidgetState extends State { children: [ IconButton( onPressed: () async { - final idenfyServiceUrl = Globals().idenfyServiceUrl; + final idenfyServiceUrl = + Globals().idenfyServiceUrl; final kycVerified = await getVerificationStatus( - address: tfchainAddress!, idenfyServiceUrl: idenfyServiceUrl); + address: tfchainAddress!, + idenfyServiceUrl: idenfyServiceUrl); if (kycVerified.status != VerificationState.VERIFIED) { showDialog( diff --git a/app/lib/widgets/home_logo.dart b/app/lib/widgets/home_logo.dart index f83f8a5c..aa7346f7 100644 --- a/app/lib/widgets/home_logo.dart +++ b/app/lib/widgets/home_logo.dart @@ -7,65 +7,65 @@ class HomeLogoWidget extends StatelessWidget { const HomeLogoWidget({super.key, required this.animate}); @override -Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center( - child: animate - ? Column( - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox( - width: 50, - height: 50, - child: Lottie.asset( - 'assets/tfloading.json', - repeat: true, - animate: true, + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Center( + child: animate + ? Column( + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox( + width: 45, + height: 45, + child: Lottie.asset( + 'assets/tfloading.json', + repeat: true, + animate: true, + ), + ), + const SizedBox(height: 10), + Text( + 'THREEFOLD', + style: + Theme.of(context).textTheme.headlineLarge!.copyWith( + color: Theme.of(context).colorScheme.onSurface, + fontWeight: FontWeight.bold, + ), + ), + ], + ) + : SizedBox( + height: 90, + child: SvgPicture.asset( + 'assets/TF_logo.svg', + alignment: Alignment.center, + colorFilter: ColorFilter.mode( + Theme.of(context).colorScheme.onSurface, + BlendMode.srcIn, ), - ), - const SizedBox(height: 10), - Text( - 'THREEFOLD', - style: Theme.of(context).textTheme.headlineSmall!.copyWith( - color: Theme.of(context).colorScheme.onSurface, - fontWeight: FontWeight.bold, - ), - ), - ], - ) - : SizedBox( - height: 50, - child: SvgPicture.asset( - 'assets/TF_logo.svg', - alignment: Alignment.center, - colorFilter: ColorFilter.mode( - Theme.of(context).colorScheme.onSurface, - BlendMode.srcIn, ), ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.04, + width: MediaQuery.of(context).size.width * 0.6, + child: Divider( + thickness: 2, + color: Theme.of(context).colorScheme.primary, + ), + ), + Text( + 'CONNECT', + style: Theme.of(context).textTheme.titleLarge!.copyWith( + color: Theme.of(context).colorScheme.onSurface, + letterSpacing: 10, + fontWeight: FontWeight.bold, ), - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.04, - width: MediaQuery.of(context).size.width * 0.6, - child: Divider( - thickness: 2, - color: Theme.of(context).colorScheme.primary, ), - ), - Text( - 'CONNECT', - style: Theme.of(context).textTheme.titleLarge!.copyWith( - color: Theme.of(context).colorScheme.onSurface, - letterSpacing: 10, - fontWeight: FontWeight.bold, - ), - ), - ], - ); -} - + ], + ); + } } diff --git a/app/lib/widgets/phone_widget.dart b/app/lib/widgets/phone_widget.dart index f8696019..7cdbddd3 100644 --- a/app/lib/widgets/phone_widget.dart +++ b/app/lib/widgets/phone_widget.dart @@ -54,11 +54,10 @@ class PhoneAlertDialog extends StatefulWidget { final String oldPhone; const PhoneAlertDialog( - {Key? key, + {super.key, required this.defaultCountryCode, required this.newPhone, - required this.oldPhone}) - : super(key: key); + required this.oldPhone}); @override State createState() { diff --git a/app/lib/widgets/wallets/add_wallet.dart b/app/lib/widgets/wallets/add_wallet.dart index a75646a9..4ed98aab 100644 --- a/app/lib/widgets/wallets/add_wallet.dart +++ b/app/lib/widgets/wallets/add_wallet.dart @@ -139,7 +139,8 @@ class _NewWalletState extends ConsumerState { return false; } - if (walletSecret.startsWith('S') && widget.wallets.any((wallet) => wallet.stellarSecret == walletSecret)){ + if (walletSecret.startsWith('S') && + widget.wallets.any((wallet) => wallet.stellarSecret == walletSecret)) { secretError = 'Secret already exists'; return false; } @@ -152,9 +153,9 @@ class _NewWalletState extends ConsumerState { secretError = 'Invalid seed'; return false; } - if (widget.wallets.any((wallet) => wallet.tfchainSecret == walletSecret)){ + if (widget.wallets.any((wallet) => wallet.tfchainSecret == walletSecret)) { secretError = 'Secret already exists'; - return false; + return false; } if (!walletSecret.startsWith('0x') && walletSecret.length != 64) { secretError = 'Invalid seed length'; @@ -307,7 +308,8 @@ Future loadAddedWallet(String walletName, String walletSecret, final chainUrl = Globals().chainUrl; final idenfyServiceUrl = Globals().idenfyServiceUrl; final Wallet wallet = await compute((void _) async { - final wallet = await loadWallet(walletName, walletSecret, type, chainUrl, idenfyServiceUrl); + final wallet = await loadWallet( + walletName, walletSecret, type, chainUrl, idenfyServiceUrl); return wallet; }, null); return wallet; diff --git a/app/lib/widgets/wallets/wallet_card.dart b/app/lib/widgets/wallets/wallet_card.dart index ae77ec94..52b14e12 100644 --- a/app/lib/widgets/wallets/wallet_card.dart +++ b/app/lib/widgets/wallets/wallet_card.dart @@ -189,7 +189,7 @@ class _WalletCardWidgetState extends ConsumerState { ), borderRadius: BorderRadius.circular(20), ), - child: Text(capitalize(wallet.verificationStatus.name), + child: Text(capitalize(wallet.verificationStatus.name), style: Theme.of(context).textTheme.bodySmall!.copyWith( color: wallet.verificationStatus == VerificationState.VERIFIED diff --git a/app/lib/widgets/wizard/common_page.dart b/app/lib/widgets/wizard/common_page.dart index 46e7dd42..5e7af5cb 100644 --- a/app/lib/widgets/wizard/common_page.dart +++ b/app/lib/widgets/wizard/common_page.dart @@ -15,7 +15,7 @@ class CommonPage extends StatefulWidget { final bool? showTermsAndConditions; const CommonPage({ - Key? key, + super.key, required this.title, required this.subtitle, required this.imagePath, @@ -23,7 +23,7 @@ class CommonPage extends StatefulWidget { this.heightPercentage = 100, this.widthPercentage = 300, this.showTermsAndConditions = false, - }) : super(key: key); + }); @override State createState() => _CommonPageState(); diff --git a/app/lib/widgets/wizard/terms_and_conditions.dart b/app/lib/widgets/wizard/terms_and_conditions.dart index 48cb22a8..db0ea99b 100644 --- a/app/lib/widgets/wizard/terms_and_conditions.dart +++ b/app/lib/widgets/wizard/terms_and_conditions.dart @@ -5,7 +5,7 @@ import 'package:threebotlogin/widgets/custom_dialog.dart'; import 'package:threebotlogin/helpers/globals.dart'; class TermsAndConditions extends StatefulWidget { - const TermsAndConditions({Key? key}) : super(key: key); + const TermsAndConditions({super.key}); @override State createState() => _TermsAndConditionsState();