From 4c5aa5bde13b16b546caa0a347aa71afc15a92bb Mon Sep 17 00:00:00 2001 From: AlaaElattar Date: Tue, 5 Nov 2024 11:06:22 +0200 Subject: [PATCH 1/6] WIP: move user infor to identity page --- .../screens/identity_verification_screen.dart | 4 ++++ app/lib/screens/preference_screen.dart | 16 ++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index bff4b989c..517984462 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -180,6 +180,10 @@ class _IdentityVerificationScreenState builder: (BuildContext context, _) { return Column( children: [ + ListTile( + leading: const Icon(Icons.person), + title: Text(doubleName), + ), // Step one: verify email _fillCard( getCorrectState(1, emailVerified, diff --git a/app/lib/screens/preference_screen.dart b/app/lib/screens/preference_screen.dart index 4af8f5a07..e20b89962 100644 --- a/app/lib/screens/preference_screen.dart +++ b/app/lib/screens/preference_screen.dart @@ -31,7 +31,7 @@ class PreferenceScreen extends ConsumerStatefulWidget { class _PreferenceScreenState extends ConsumerState { // FirebaseNotificationListener _listener; Map email = {}; - String doubleName = ''; + // String doubleName = ''; String phrase = ''; bool showAdvancedOptions = false; Icon showAdvancedOptionsIcon = const Icon(Icons.keyboard_arrow_down); @@ -94,10 +94,6 @@ class _PreferenceScreenState extends ConsumerState { const ListTile( title: Text('Global settings'), ), - ListTile( - leading: const Icon(Icons.person), - title: Text(doubleName), - ), FutureBuilder( future: getPhrase(), builder: (context, snapshot) { @@ -408,11 +404,11 @@ class _PreferenceScreenState extends ConsumerState { } void getUserValues() { - getDoubleName().then((dn) { - setState(() { - doubleName = dn!.substring(0, dn.length - 5); - }); - }); + // getDoubleName().then((dn) { + // setState(() { + // doubleName = dn!.substring(0, dn.length - 5); + // }); + // }); getPhrase().then((seedPhrase) { setState(() { phrase = seedPhrase!; From 2a075acf48a5e03b32b89525768b445604f91749 Mon Sep 17 00:00:00 2001 From: AlaaElattar Date: Sun, 10 Nov 2024 17:00:20 +0200 Subject: [PATCH 2/6] change page styling to be like settings page --- .../screens/identity_verification_screen.dart | 621 +++++++++--------- app/lib/screens/preference_screen.dart | 20 - 2 files changed, 302 insertions(+), 339 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 517984462..6078494f1 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'dart:core'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_pkid/flutter_pkid.dart'; import 'package:http/http.dart'; import 'package:idenfy_sdk_flutter/idenfy_sdk_flutter.dart'; @@ -13,6 +14,7 @@ import 'package:threebotlogin/helpers/kyc_helpers.dart'; import 'package:threebotlogin/helpers/logger.dart'; import 'package:threebotlogin/main.dart'; import 'package:threebotlogin/models/idenfy.dart'; +import 'package:threebotlogin/screens/authentication_screen.dart'; import 'package:threebotlogin/services/gridproxy_service.dart'; import 'package:threebotlogin/services/idenfy_service.dart'; import 'package:threebotlogin/services/identity_service.dart'; @@ -182,7 +184,32 @@ class _IdentityVerificationScreenState children: [ ListTile( leading: const Icon(Icons.person), - title: Text(doubleName), + title: Text( + doubleName.isNotEmpty + ? doubleName.substring( + 0, doubleName.length - 5) + : 'Unknown', + ), + ), + FutureBuilder( + future: getPhrase(), + builder: (context, snapshot) { + if (snapshot.hasData) { + return ListTile( + trailing: const Padding( + padding: EdgeInsets.only(right: 7.5), + child: Icon(Icons.visibility), + ), + leading: const Icon(Icons.vpn_key), + title: const Text('Show phrase'), + onTap: () async { + _showPhrase(); + }, + ); + } else { + return Container(); + } + }, ), // Step one: verify email _fillCard( @@ -299,6 +326,53 @@ class _IdentityVerificationScreenState ); } + Future copySeedPhrase() async { + Clipboard.setData(ClipboardData(text: (await getPhrase()).toString())); + + const seedCopied = SnackBar( + content: Text('Seed phrase copied to clipboard'), + duration: Duration(seconds: 1), + ); + + ScaffoldMessenger.of(context).showSnackBar(seedCopied); + } + + void _showPhrase() async { + String? pin = await getPin(); + bool? authenticated = await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AuthenticationScreen( + correctPin: pin!, + userMessage: 'Please enter your PIN code', + ), + )); + + if (authenticated != null && authenticated) { + final phrase = await getPhrase(); + + showDialog( + context: context, + builder: (BuildContext context) => CustomDialog( + hiddenAction: copySeedPhrase, + image: Icons.info, + title: 'Please write this down on a piece of paper', + description: phrase.toString(), + actions: [ + // usually buttons at the bottom of the dialog + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.pop(context); + setState(() {}); + }, + ), + ], + ), + ); + } + } + Future initIdenfySdk(String token) async { IdenfyIdentificationResult? idenfySDKresult; try { @@ -544,86 +618,57 @@ class _IdentityVerificationScreenState onTap: () async {}, child: Opacity( opacity: 0.5, - child: Container( - decoration: BoxDecoration( - border: Border.all(width: 0.5, color: Colors.grey)), - height: 75, - width: MediaQuery.of(context).size.width * 100, - child: Row( - children: [ - const Padding(padding: EdgeInsets.only(left: 10)), - Container( - width: 30.0, - height: 30.0, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context).colorScheme.primary, - width: 2), - shape: BoxShape.circle, - color: Theme.of(context).colorScheme.surface), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text('0$step', - style: TextStyle( - color: Theme.of(context).colorScheme.primary, - fontWeight: FontWeight.bold, - fontSize: 12)) - ], - ), - ), - const Padding(padding: EdgeInsets.only(left: 20)), - Icon( - icon, - size: 20, - ), - const Padding(padding: EdgeInsets.only(left: 15)), - Flexible( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - children: [ - Expanded( - child: Text( - text == '' ? 'Unknown' : text, - overflow: TextOverflow.clip, - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - fontWeight: FontWeight.bold, - color: Theme.of(context) - .colorScheme - .onSurface), - ), - ) - ], - ), - const SizedBox( - height: 5, - ), - Row( - children: [ - Icon( - Icons.close, - color: Theme.of(context).colorScheme.error, - size: 18.0, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 10.0), + child: ListTile( + leading: Icon(icon), + title: Flexible( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + children: [ + Expanded( + child: Text( + text == '' ? 'Unknown' : text, + overflow: TextOverflow.clip, + style: Theme.of(context) + .textTheme + .bodySmall! + .copyWith( + fontWeight: FontWeight.bold, + color: Theme.of(context) + .colorScheme + .onSurface), + ), + ) + ], ), - const Padding(padding: EdgeInsets.only(left: 5)), - Text( - 'Not verified', - style: TextStyle( + const SizedBox( + height: 5, + ), + Row( + children: [ + Icon( + Icons.close, color: Theme.of(context).colorScheme.error, - fontWeight: FontWeight.bold, - fontSize: 12), - ) - ], - ), - ])), - const Padding(padding: EdgeInsets.only(right: 10)) - ], - ), + size: 18.0, + ), + const Padding(padding: EdgeInsets.only(left: 5)), + Text( + 'Not verified', + style: TextStyle( + color: Theme.of(context).colorScheme.error, + fontWeight: FontWeight.bold, + fontSize: 12), + ) + ], + ), + ])), + )) + ], ), )); } @@ -664,148 +709,112 @@ class _IdentityVerificationScreenState } } }, - child: Container( - decoration: BoxDecoration( - border: Border( - left: BorderSide( - color: Theme.of(context).colorScheme.primary, width: 5), - right: const BorderSide(color: Colors.grey, width: 0.5), - bottom: const BorderSide(color: Colors.grey, width: 0.5), - top: const BorderSide(color: Colors.grey, width: 0.5))), - height: 75, - width: MediaQuery.of(context).size.width * 100, - child: Row( - children: [ - const Padding(padding: EdgeInsets.only(left: 10)), - Container( - width: 30.0, - height: 30.0, - decoration: BoxDecoration( - border: Border.all( - color: Theme.of(context).colorScheme.primary, width: 2), - shape: BoxShape.circle, - color: Theme.of(context).colorScheme.surface), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, + child: Column(children: [ + Padding( + padding: const EdgeInsets.only(bottom: 10.0), + child: ListTile( + leading: Icon(icon), + title: Row( + mainAxisSize: MainAxisSize.min, children: [ - Text('0$step', - style: TextStyle( - color: Theme.of(context).colorScheme.primary, - fontWeight: FontWeight.bold, - fontSize: 12)) + Flexible( + child: Container( + constraints: Globals().hidePhoneButton.value == + false || + (step != 2 && + Globals().hidePhoneButton.value == true) + ? BoxConstraints( + minWidth: + MediaQuery.of(context).size.width * 0.5, + maxWidth: + MediaQuery.of(context).size.width * 0.5) + : BoxConstraints( + minWidth: + MediaQuery.of(context).size.width * 0.7, + maxWidth: + MediaQuery.of(context).size.width * + 0.7), + padding: const EdgeInsets.all(10), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + children: [ + Expanded( + child: Text( + step == 3 + ? 'Identity' + : (text.isEmpty + ? 'Unknown' + : text), + ), + ) + ], + ), + step == 2 && + Globals().hidePhoneButton.value == + true + ? const SizedBox( + height: 5, + ) + : Container(), + step == 2 && + Globals().hidePhoneButton.value == + true + ? Row( + children: [ + Text( + 'SMS sent, retry in ${calculateMinutes()} minute${calculateMinutes() == '1' ? '' : 's'}', + overflow: TextOverflow.clip, + style: Theme.of(context) + .textTheme + .bodySmall! + .copyWith( + fontWeight: + FontWeight.bold, + color: Theme.of(context) + .colorScheme + .warning), + ) + ], + ) + : Container(), + ]))), + Globals().hidePhoneButton.value == true && step == 2 + ? Container() + : ElevatedButton( + onPressed: () async { + switch (step) { + // Verify email + case 1: + { + verifyEmail(); + } + break; + + // Verify phone + case 2: + { + await verifyPhone(); + } + break; + + // Verify identity + case 3: + { + await verifyIdentityProcess(); + } + break; + default: + {} + break; + } + }, + child: const Text('Verify')) ], ), - ), - const Padding(padding: EdgeInsets.only(left: 15)), - Icon( - icon, - size: 20, - ), - const Padding(padding: EdgeInsets.only(left: 10)), - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Flexible( - child: Container( - constraints: Globals().hidePhoneButton.value == - false || - (step != 2 && - Globals().hidePhoneButton.value == true) - ? BoxConstraints( - minWidth: - MediaQuery.of(context).size.width * 0.4, - maxWidth: - MediaQuery.of(context).size.width * 0.4) - : BoxConstraints( - minWidth: - MediaQuery.of(context).size.width * 0.6, - maxWidth: - MediaQuery.of(context).size.width * 0.6), - padding: const EdgeInsets.all(10), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - children: [ - Expanded( - child: Text( - text == '' ? 'Unknown' : text, - overflow: TextOverflow.clip, - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - fontWeight: FontWeight.bold, - color: Theme.of(context) - .colorScheme - .onSurface), - ), - ) - ], - ), - step == 2 && - Globals().hidePhoneButton.value == true - ? const SizedBox( - height: 5, - ) - : Container(), - step == 2 && - Globals().hidePhoneButton.value == true - ? Row( - children: [ - Text( - 'SMS sent, retry in ${calculateMinutes()} minute${calculateMinutes() == '1' ? '' : 's'}', - overflow: TextOverflow.clip, - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - fontWeight: FontWeight.bold, - color: Theme.of(context) - .colorScheme - .warning), - ) - ], - ) - : Container(), - ]))), - Globals().hidePhoneButton.value == true && step == 2 - ? Container() - : ElevatedButton( - onPressed: () async { - switch (step) { - // Verify email - case 1: - { - verifyEmail(); - } - break; - - // Verify phone - case 2: - { - await verifyPhone(); - } - break; - - // Verify identity - case 3: - { - await verifyIdentityProcess(); - } - break; - default: - {} - break; - } - }, - child: const Text('Verify')) - ], - ), - const Padding(padding: EdgeInsets.only(right: 10)), - ], - ), - )); + )) + ])); } String calculateMinutes() { @@ -824,115 +833,89 @@ class _IdentityVerificationScreenState Widget verifiedWidget(step, text, icon) { return GestureDetector( - onTap: () async { - if (step == 1) { - return _changeEmailDialog(false); - } - // Only make this section clickable if it is Identity Verification + Current Phase - if (step != 3) { - return; - } + onTap: () async { + if (step == 1) { + return _changeEmailDialog(false); + } + // Only make this section clickable if it is Identity Verification + Current Phase + if (step != 3) { + return; + } - return showIdentityDetails(); - }, - child: Container( - decoration: - BoxDecoration(border: Border.all(width: 0.5, color: Colors.grey)), - height: 75, - width: MediaQuery.of(context).size.width * 100, - child: Row( - children: [ - const Padding(padding: EdgeInsets.only(left: 10)), - Container( - width: 30.0, - height: 30.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Theme.of(context).colorScheme.primary), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.check, - size: 15.0, - color: Theme.of(context).colorScheme.onPrimary, - ), - ], - ), - ), - const Padding(padding: EdgeInsets.only(left: 20)), - Icon( - icon, - size: 20, - ), - const Padding(padding: EdgeInsets.only(left: 15)), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, + return showIdentityDetails(); + }, + child: Column(children: [ + Padding( + padding: const EdgeInsets.only(bottom: 10.0), + child: ListTile( + leading: Icon(icon), + title: Row( children: [ Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container( - constraints: BoxConstraints( - minWidth: - MediaQuery.of(context).size.width * 0.55, - maxWidth: - MediaQuery.of(context).size.width * 0.55), - child: Text(text == '' ? 'Unknown' : text, - overflow: TextOverflow.clip, - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - fontWeight: FontWeight.bold, - color: Theme.of(context) - .colorScheme - .onSurface))) + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + constraints: BoxConstraints( + minWidth: + MediaQuery.of(context).size.width * + 0.65, + maxWidth: + MediaQuery.of(context).size.width * + 0.65), + child: Text( + text == '' ? 'Unknown' : text, + overflow: TextOverflow.clip, + )) + ], + ), + const SizedBox(height: 5), + Row( + children: [ + Text( + 'Verified', + style: Theme.of(context) + .textTheme + .bodySmall! + .copyWith( + color: Theme.of(context) + .colorScheme + .primary, + fontWeight: FontWeight.bold), + ) + ], + ) + ], + ), + step == 1 + ? const Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.edit, + ), + ]) + : const Column(), + step == 3 + ? const Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.chevron_right, + ), + ]) + : const Column() ], ), - const SizedBox(height: 5), - Row( - children: [ - Text( - 'Verified', - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - color: Theme.of(context).colorScheme.primary, - fontWeight: FontWeight.bold), - ) - ], - ) ], ), - step == 1 - ? const Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [Icon(Icons.edit, size: 20)], - ) - : const Column(), - step == 3 - ? const Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.chevron_right, - size: 20, - ) - ], - ) - : const Column() - ], - ), - const Padding(padding: EdgeInsets.only(right: 10)) - ], - ), - ), - ); + )) + ])); } Future verifyIdentityProcess() async { diff --git a/app/lib/screens/preference_screen.dart b/app/lib/screens/preference_screen.dart index e20b89962..521b861a6 100644 --- a/app/lib/screens/preference_screen.dart +++ b/app/lib/screens/preference_screen.dart @@ -94,26 +94,6 @@ class _PreferenceScreenState extends ConsumerState { const ListTile( title: Text('Global settings'), ), - FutureBuilder( - future: getPhrase(), - builder: (context, snapshot) { - if (snapshot.hasData) { - return ListTile( - trailing: const Padding( - padding: EdgeInsets.only(right: 7.5), - child: Icon(Icons.visibility), - ), - leading: const Icon(Icons.vpn_key), - title: const Text('Show phrase'), - onTap: () async { - _showPhrase(); - }, - ); - } else { - return Container(); - } - }, - ), FutureBuilder( future: checkBiometrics(), builder: (context, snapshot) { From bfc72cf6efcf6ce275fb175cfe45fa4398f2d7b8 Mon Sep 17 00:00:00 2001 From: AlaaElattar Date: Mon, 11 Nov 2024 11:13:05 +0200 Subject: [PATCH 3/6] remove commented lines --- app/lib/screens/identity_verification_screen.dart | 7 ++++++- app/lib/screens/preference_screen.dart | 12 ------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index d2dbb269d..a7205b35f 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -39,6 +39,7 @@ class IdentityVerificationScreen extends StatefulWidget { class _IdentityVerificationScreenState extends State { String doubleName = ''; + String phrase = ''; String email = ''; String phone = ''; @@ -125,6 +126,11 @@ class _IdentityVerificationScreenState doubleName = dn!; }); }); + getPhrase().then((seedPhrase) { + setState(() { + phrase = seedPhrase!; + }); + }); getEmail().then((emailMap) { setState(() { if (emailMap['email'] != null) { @@ -532,7 +538,6 @@ class _IdentityVerificationScreenState child: const Text('Close'), onPressed: () { Navigator.pop(context); - setState(() {}); }, ), ], diff --git a/app/lib/screens/preference_screen.dart b/app/lib/screens/preference_screen.dart index 521b861a6..826d8831f 100644 --- a/app/lib/screens/preference_screen.dart +++ b/app/lib/screens/preference_screen.dart @@ -31,8 +31,6 @@ class PreferenceScreen extends ConsumerStatefulWidget { class _PreferenceScreenState extends ConsumerState { // FirebaseNotificationListener _listener; Map email = {}; - // String doubleName = ''; - String phrase = ''; bool showAdvancedOptions = false; Icon showAdvancedOptionsIcon = const Icon(Icons.keyboard_arrow_down); @@ -384,16 +382,6 @@ class _PreferenceScreenState extends ConsumerState { } void getUserValues() { - // getDoubleName().then((dn) { - // setState(() { - // doubleName = dn!.substring(0, dn.length - 5); - // }); - // }); - getPhrase().then((seedPhrase) { - setState(() { - phrase = seedPhrase!; - }); - }); getFingerprint().then((fingerprint) { setState(() { if (fingerprint == null) { From 616d1d09b289fbbc9a762b310f1a28d6e106a48d Mon Sep 17 00:00:00 2001 From: AlaaElattar Date: Thu, 28 Nov 2024 11:34:50 +0200 Subject: [PATCH 4/6] update styling to make page consistent --- app/lib/screens/identity_verification_screen.dart | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 2c7d80b57..c237aba5e 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -807,14 +807,7 @@ class _IdentityVerificationScreenState child: Text( text == '' ? 'Unknown' : text, overflow: TextOverflow.clip, - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - fontWeight: FontWeight.bold, - color: Theme.of(context) - .colorScheme - .onSurface), + style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.onSurface) ), ) ], @@ -907,7 +900,6 @@ class _IdentityVerificationScreenState maxWidth: MediaQuery.of(context).size.width * 0.7), - padding: const EdgeInsets.all(10), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ From f190f7336a22273d53b379ade82ae32086d786a9 Mon Sep 17 00:00:00 2001 From: AlaaElattar Date: Mon, 9 Dec 2024 16:00:24 +0200 Subject: [PATCH 5/6] update page design --- .../screens/identity_verification_screen.dart | 133 ++++++++++++------ 1 file changed, 89 insertions(+), 44 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index c237aba5e..476e682e1 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -178,7 +178,7 @@ class _IdentityVerificationScreenState mainAxisSize: MainAxisSize.max, children: [ Padding( - padding: const EdgeInsets.all(15), + padding: const EdgeInsets.fromLTRB(0, 24, 15, 24), child: Column( children: [ AnimatedBuilder( @@ -199,15 +199,22 @@ class _IdentityVerificationScreenState : 'Unknown', ), ), + Center( + child: SizedBox( + width: MediaQuery.of(context).size.width * + 0.85, + child: const Divider( + thickness: 0.5, + color: Colors.grey, + ), + ), + ), FutureBuilder( future: getPhrase(), builder: (context, snapshot) { if (snapshot.hasData) { return ListTile( - trailing: const Padding( - padding: EdgeInsets.only(right: 7.5), - child: Icon(Icons.visibility), - ), + trailing: Icon(Icons.visibility), leading: const Icon(Icons.vpn_key), title: const Text('Show phrase'), onTap: () async { @@ -219,6 +226,16 @@ class _IdentityVerificationScreenState } }, ), + Center( + child: SizedBox( + width: MediaQuery.of(context).size.width * + 0.85, + child: const Divider( + thickness: 0.5, + color: Colors.grey, + ), + ), + ), // Step one: verify email _fillCard( getCorrectState(1, emailVerified, @@ -226,7 +243,16 @@ class _IdentityVerificationScreenState 1, email, Icons.email), - + Center( + child: SizedBox( + width: MediaQuery.of(context).size.width * + 0.85, + child: const Divider( + thickness: 0.5, + color: Colors.grey, + ), + ), + ), // Step two: verify phone (Globals().phoneVerification == true || (Globals().spendingLimit > 0 && @@ -238,7 +264,16 @@ class _IdentityVerificationScreenState phone, Icons.phone) : Container(), - + Center( + child: SizedBox( + width: MediaQuery.of(context).size.width * + 0.85, + child: const Divider( + thickness: 0.5, + color: Colors.grey, + ), + ), + ), // Step three: verify identity (Globals().isOpenKYCEnabled || (Globals().spendingLimit > 0 && @@ -804,11 +839,13 @@ class _IdentityVerificationScreenState Row( children: [ Expanded( - child: Text( - text == '' ? 'Unknown' : text, - overflow: TextOverflow.clip, - style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.onSurface) - ), + child: Text(text == '' ? 'Unknown' : text, + overflow: TextOverflow.clip, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Theme.of(context) + .colorScheme + .onSurface)), ) ], ), @@ -947,35 +984,37 @@ class _IdentityVerificationScreenState ]))), Globals().hidePhoneButton.value == true && step == 2 ? Container() - : ElevatedButton( - onPressed: () async { - switch (step) { - // Verify email - case 1: - { - verifyEmail(); + : Padding( + padding: EdgeInsets.only(left: 15), + child: ElevatedButton( + onPressed: () async { + switch (step) { + // Verify email + case 1: + { + verifyEmail(); + } + break; + + // Verify phone + case 2: + { + await verifyPhone(); + } + break; + + // Verify identity + case 3: + { + await verifyIdentityProcess(); + } + break; + default: + {} + break; } - break; - - // Verify phone - case 2: - { - await verifyPhone(); - } - break; - - // Verify identity - case 3: - { - await verifyIdentityProcess(); - } - break; - default: - {} - break; - } - }, - child: const Text('Verify')) + }, + child: const Text('Verify'))), ], ), )) @@ -1061,8 +1100,11 @@ class _IdentityVerificationScreenState ? const Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon( - Icons.edit, + Padding( + padding: EdgeInsets.only(left: 15), + child: Icon( + Icons.edit, + ), ), ]) : const Column(), @@ -1070,8 +1112,11 @@ class _IdentityVerificationScreenState ? const Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon( - Icons.chevron_right, + Padding( + padding: EdgeInsets.only(left: 15), + child: Icon( + Icons.chevron_right, + ), ), ]) : const Column() From 48e5f8a48c6b8e4bc192feb71e220e547fc83201 Mon Sep 17 00:00:00 2001 From: AlaaElattar Date: Wed, 11 Dec 2024 10:09:32 +0200 Subject: [PATCH 6/6] make divider as component && remove phrase function from settings page --- .../screens/identity_verification_screen.dart | 61 ++++++----------- app/lib/screens/preference_screen.dart | 67 ------------------- 2 files changed, 21 insertions(+), 107 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 482a70dfa..8e0dd04de 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -213,6 +213,20 @@ class _IdentityVerificationScreenState getSpending(); } + Widget customDivider({ + required BuildContext context, + }) { + return Center( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.85, + child: const Divider( + thickness: 0.5, + color: Colors.grey, + ), + ), + ); + } + @override Widget build(BuildContext context) { return LayoutDrawer( @@ -250,16 +264,7 @@ class _IdentityVerificationScreenState : 'Unknown', ), ), - Center( - child: SizedBox( - width: MediaQuery.of(context).size.width * - 0.85, - child: const Divider( - thickness: 0.5, - color: Colors.grey, - ), - ), - ), + customDivider(context: context), FutureBuilder( future: getPhrase(), builder: (context, snapshot) { @@ -277,16 +282,8 @@ class _IdentityVerificationScreenState } }, ), - Center( - child: SizedBox( - width: MediaQuery.of(context).size.width * - 0.85, - child: const Divider( - thickness: 0.5, - color: Colors.grey, - ), - ), - ), + customDivider(context: context), + // Step one: verify email _fillCard( getCorrectState(1, emailVerified, @@ -294,16 +291,8 @@ class _IdentityVerificationScreenState 1, email, Icons.email), - Center( - child: SizedBox( - width: MediaQuery.of(context).size.width * - 0.85, - child: const Divider( - thickness: 0.5, - color: Colors.grey, - ), - ), - ), + customDivider(context: context), + // Step two: verify phone (Globals().phoneVerification == true || (Globals().spendingLimit > 0 && @@ -315,16 +304,8 @@ class _IdentityVerificationScreenState phone, Icons.phone) : Container(), - Center( - child: SizedBox( - width: MediaQuery.of(context).size.width * - 0.85, - child: const Divider( - thickness: 0.5, - color: Colors.grey, - ), - ), - ), + customDivider(context: context), + // Step three: verify identity (Globals().isOpenKYCEnabled || (Globals().spendingLimit > 0 && diff --git a/app/lib/screens/preference_screen.dart b/app/lib/screens/preference_screen.dart index 12495fd2e..37cd0a2eb 100644 --- a/app/lib/screens/preference_screen.dart +++ b/app/lib/screens/preference_screen.dart @@ -403,37 +403,6 @@ class _PreferenceScreenState extends ConsumerState { ); } - Future copySeedPhrase() async { - Clipboard.setData(ClipboardData(text: (await getPhrase()).toString())); - - const seedCopied = SnackBar( - content: Text('Seed phrase copied to clipboard'), - duration: Duration(seconds: 1), - ); - - ScaffoldMessenger.of(context).showSnackBar(seedCopied); - } - - void checkPin(pin, callbackParam) async { - if (pin == await getPin()) { - Navigator.pop(context); - switch (callbackParam) { - case 'phrase': - _showPhrase(); - break; - case 'fingerprint': - _showDisableFingerprint(); - break; - } - } else { - Navigator.pop(context); - ScaffoldMessenger.of(context).showSnackBar(const SnackBar( - content: Text('Pin invalid'), - )); - } - setState(() {}); - } - void getUserValues() { getFingerprint().then((fingerprint) { setState(() { @@ -446,42 +415,6 @@ class _PreferenceScreenState extends ConsumerState { }); } - void _showPhrase() async { - String? pin = await getPin(); - bool? authenticated = await Navigator.push( - context, - MaterialPageRoute( - builder: (context) => AuthenticationScreen( - correctPin: pin!, - userMessage: 'Please enter your PIN code', - ), - )); - - if (authenticated != null && authenticated) { - final phrase = await getPhrase(); - - showDialog( - context: context, - builder: (BuildContext context) => CustomDialog( - hiddenAction: copySeedPhrase, - image: Icons.info, - title: 'Please write this down on a piece of paper', - description: phrase.toString(), - actions: [ - // usually buttons at the bottom of the dialog - TextButton( - child: const Text('Close'), - onPressed: () { - Navigator.pop(context); - setState(() {}); - }, - ), - ], - ), - ); - } - } - void _toggleFingerprint(bool newFingerprintValue) async { String? pin = await getPin();