diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 112b3561..c600610b 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -138,4 +138,5 @@ const Map> localizedValues = { "ar": "هل ترغب في تسجيل الدخول باسم المستخدم الحالي؟" }, "another-acc": {"en": "Use Another Account", "ar": "استخدم حسابا آخر"}, + "next": {"en": "Next", "ar": 'التالى'}, }; diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 7f58551b..1b482299 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -125,7 +125,7 @@ class _Login extends State { void validateForm() { if (util.validateIDBox(nationalIDorFile.text, loginType) == true && mobileNo.length >= 9 && - util.isSAUDIIDValid(nationalIDorFile.text) == true) { + util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) { setState(() { isButtonDisabled = false; }); diff --git a/lib/pages/login/register-info.dart b/lib/pages/login/register-info.dart index 51caa972..70e5fb29 100644 --- a/lib/pages/login/register-info.dart +++ b/lib/pages/login/register-info.dart @@ -27,7 +27,7 @@ class _RegisterInfo extends State { final sharedPref = new AppSharedPreferences(); RegisterInfoResponse registerInfo; bool isLoading; - + int page = 1; @override void initState() { getRegisterInfo(); @@ -52,55 +52,71 @@ class _RegisterInfo extends State { fontSize: SizeConfig.textMultiplier * 3, textAlign: TextAlign.left, )), - registerInfo != null - ? Expanded( - flex: 4, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - child: TextFields( - hintText: registerInfo.idNumber, - prefixIcon: - Icon(Icons.chrome_reader_mode, color: Colors.red), - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - Container( - child: TextFields( - hintText: registerInfo.firstNameEn + - ' ' + - registerInfo.lastNameEn, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - Container( - child: TextFields( - hintText: registerInfo.maritalStatusCode, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - Container( - child: TextFields( - prefixIcon: - Icon(Icons.chrome_reader_mode, color: Colors.red), - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - hintText: TranslationBase.of(context).nationalID, - )), - Container( - child: TextFields( - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - hintText: TranslationBase.of(context).nationalID, - )), - ], - ), + registerInfo != null && page == 1 + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + AppText('National ID'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.idNumber, + prefixIcon: Icon(Icons.chrome_reader_mode, + color: Colors.red), + padding: EdgeInsets.only( + top: 20, bottom: 20, left: 10, right: 10), + readOnly: true, + )), + AppText('Name'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.firstNameEn + + ' ' + + registerInfo.lastNameEn, + padding: EdgeInsets.only( + top: 20, bottom: 20, left: 10, right: 10), + readOnly: true, + )), + AppText('Gender'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.maritalStatusCode == 'U' + ? 'Unknown' + : registerInfo.maritalStatusCode == 'M' + ? 'Male' + : 'Female', + padding: EdgeInsets.only( + top: 20, bottom: 20, left: 10, right: 10), + readOnly: true, + )), + AppText('Nationality'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.nationalityCode, + padding: EdgeInsets.only( + top: 20, bottom: 20, left: 10, right: 10), + readOnly: true, + )), + AppText('Date of Birth'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.dateOfBirth, + padding: EdgeInsets.only( + top: 20, bottom: 20, left: 10, right: 10), + readOnly: true, + )), + ], ) - : SizedBox(), + : registerInfo != null && page == 2 + ? Column( + children: [], + ) + : SizedBox(), Expanded( flex: 2, child: Column( @@ -110,8 +126,8 @@ class _RegisterInfo extends State { children: [ Expanded( child: DefaultButton( - TranslationBase.of(context).registerNow, - () => {registerNow()}, + TranslationBase.of(context).next, + () => {nextPage()}, textColor: Colors.white, )) ], @@ -122,6 +138,12 @@ class _RegisterInfo extends State { ))); } + nextPage() { + setState(() { + page++; + }); + } + registerNow() {} getRegisterInfo() async { registerInfo = diff --git a/lib/pages/login/register.dart b/lib/pages/login/register.dart index e87f42c2..5197b652 100644 --- a/lib/pages/login/register.dart +++ b/lib/pages/login/register.dart @@ -204,7 +204,7 @@ class _Register extends State { void validateForm() { if (util.validateIDBox(nationalIDorFile.text, loginType) == true && mobileNo.length >= 9 && - util.isSAUDIIDValid(nationalIDorFile.text) == true && + util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true && isHijri != null) { setState(() { isButtonDisabled = false; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 1ac7b12f..2cf6ca23 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -176,6 +176,7 @@ class TranslationBase { localizedValues['account-info'][locale.languageCode]; String get useAnotherAccount => localizedValues['another-acc'][locale.languageCode]; + String get next => localizedValues['next'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 455279cc..7a987279 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -43,42 +43,46 @@ class Utils { FocusScope.of(context).unfocus(); } - bool isSAUDIIDValid(String id) { - if (id == null) { - return false; - } - try { - id = id.toString(); - id = id.trim(); - var returnValue = int.parse(id); - var sum = 0; - if (returnValue > 0) { - var type = int.parse(id[0]); + bool isSAUDIIDValid(String id, type) { + if (type == 1) { + if (id == null) { + return false; + } + try { + id = id.toString(); + id = id.trim(); + var returnValue = int.parse(id); + var sum = 0; + if (returnValue > 0) { + var type = int.parse(id[0]); - if (id.length != 10) { - return false; - } - if (type != 2 && type != 1) { - return false; - } + if (id.length != 10) { + return false; + } + if (type != 2 && type != 1) { + return false; + } - for (var i = 0; i < 10; i++) { - if (i % 2 == 0) { - var a = id[i]; - var x = int.parse(a) * 2; - var b = x.toString(); - if (b.length == 1) { - b = "0" + b; + for (var i = 0; i < 10; i++) { + if (i % 2 == 0) { + var a = id[i]; + var x = int.parse(a) * 2; + var b = x.toString(); + if (b.length == 1) { + b = "0" + b; + } + sum += int.parse(b[0]) + int.parse(b[1]); + } else { + sum += int.parse(id[i]); } - sum += int.parse(b[0]) + int.parse(b[1]); - } else { - sum += int.parse(id[i]); } + return sum % 10 == 0; } - return sum % 10 == 0; - } - } catch (err) {} - return false; + } catch (err) {} + return false; + } else { + return true; + } } bool validateIDBox(String value, type) {