From 54d17d2c1634721bb069070ef4b11e75673dc126 Mon Sep 17 00:00:00 2001 From: Aamir Muhammad Date: Sun, 20 Jul 2025 17:12:22 +0300 Subject: [PATCH] font changes --- android/settings.gradle | 111 -- assets/images/svg/dropdow-icon.svg | 3 + assets/images/svg/habiblogo.svg | 3 + assets/images/svg/password-validation.svg | 8 + lib/config/localized_values.dart | 25 +- .../Authentication/register_user_requet.dart | 2 +- lib/models/Nationality_countires_model.dart | 29 + .../otp/otp_validation_bootmsheet_widget.dart | 181 +-- .../health_calculator/carbs/carbs.dart | 1001 +++++++++-------- lib/pages/landing/landing_page.dart | 13 +- lib/pages/login/register_new.dart | 124 +- lib/pages/login/register_new_step_2.dart | 513 +++++---- lib/pages/login/saved_login.dart | 671 +++++------ .../login/user-login-agreement-page.dart | 20 +- lib/pages/login/welcome.dart | 182 +-- .../authentication/auth_provider.dart | 18 +- lib/theme/colors.dart | 10 + lib/theme/theme_value.dart | 15 +- lib/uitl/font_utils.dart | 148 +++ lib/uitl/translations_delegate_base.dart | 22 + lib/uitl/utils.dart | 111 ++ lib/widgets/drawer/langauge_picker.dart | 9 +- lib/widgets/others/app_scaffold_widget.dart | 110 +- lib/widgets/otp/sms-popup.dart | 10 +- lib/widgets/text/app_texts_widget.dart | 23 +- pubspec.yaml | 6 +- 26 files changed, 1972 insertions(+), 1396 deletions(-) create mode 100644 assets/images/svg/dropdow-icon.svg create mode 100644 assets/images/svg/habiblogo.svg create mode 100644 assets/images/svg/password-validation.svg create mode 100644 lib/models/Nationality_countires_model.dart create mode 100644 lib/uitl/font_utils.dart diff --git a/android/settings.gradle b/android/settings.gradle index 9bfc6a53..984ef784 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,114 +1,3 @@ -//pluginManagement { -// def flutterSdkPath = { -// def properties = new Properties() -// file("local.properties").withInputStream { properties.load(it) } -// def flutterSdkPath = properties.getProperty("flutter.sdk") -// assert flutterSdkPath != null : "flutter.sdk not set in local.properties" -// return flutterSdkPath -// }() -// -// includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -// -// repositories { -// google() -// mavenCentral() -// gradlePluginPortal() -// } -// -// plugins { -// id "dev.flutter.flutter-plugin-loader" version "1.0.0" -// id "com.android.application" version "8.1.0" apply false -// id "org.jetbrains.kotlin.android" version "2.1.10" apply false -// id "com.google.gms.google-services" version "4.4.2" apply false -// id "com.google.firebase.crashlytics" version "3.0.3" apply false -// -// } -//} -// -// -//dependencyResolutionManagement { -// repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) -// -// repositories { -// google() -// mavenCentral() -// flatDir { -// dirs 'libs' -// } -// maven { -// url 'https://developer.huawei.com/repo/' -// } -// maven { -// url "https://artifactory.ess-dev.com/artifactory/gradle-dev-local" -// } -// maven { -// url 'https://api.mapbox.com/downloads/v2/releases/maven' -// -// credentials { -// username = 'mapbox' -// password = "sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg" -// if (password == null || password == "") { -// throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the environment variables.") -// } -// } -// authentication { -// basic(BasicAuthentication) -// } -// } -// } -//} -// -// -//// Load local properties -//def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -//def properties = new Properties() -//assert localPropertiesFile.exists() -//localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } -// -//// Get Flutter SDK path -//def flutterSdkPath = properties.getProperty('flutter.sdk') -//assert flutterSdkPath != null : "flutter.sdk not set in local.properties" -// -//// Get vital-sign-engine path -//def vitalSignEnginePath = properties.getProperty('vital.sign.engine.path') -//assert vitalSignEnginePath != null : "vital.sign.engine.path not set in local.properties" -// -//// Include modules -//include ':app' -////project(':vital-sign-engine').projectDir = file(vitalSignEnginePath) -//// ':vital-sign-engine' - - -//include ':app' -// -//def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() -// -//def plugins = new Properties() -//def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -//if (pluginsFile.exists()) { -// pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } -//} -// -//plugins.each { name, path -> -// def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() -// include ":$name" -// project(":$name").projectDir = pluginDirectory -//} - -//// Load local properties -//def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -//def properties = new Properties() -//assert localPropertiesFile.exists() -//localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } -// -//// Get Flutter SDK path -//def flutterSdkPath = properties.getProperty('flutter.sdk') -//assert flutterSdkPath != null : "flutter.sdk not set in local.properties" -// -//// Get vital-sign-engine path -//def vitalSignEnginePath = properties.getProperty('vital.sign.engine.path') -//assert vitalSignEnginePath != null : "vital.sign.engine.path not set in local.properties" -// pluginManagement { def flutterSdkPath = { diff --git a/assets/images/svg/dropdow-icon.svg b/assets/images/svg/dropdow-icon.svg new file mode 100644 index 00000000..9ae2e618 --- /dev/null +++ b/assets/images/svg/dropdow-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/svg/habiblogo.svg b/assets/images/svg/habiblogo.svg new file mode 100644 index 00000000..8c33d825 --- /dev/null +++ b/assets/images/svg/habiblogo.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/svg/password-validation.svg b/assets/images/svg/password-validation.svg new file mode 100644 index 00000000..c9d641dd --- /dev/null +++ b/assets/images/svg/password-validation.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index d2c6fa86..908b5666 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1344,7 +1344,7 @@ const Map localizedValues = { "select-appo": {"en": "Kindly select one of the available appointments from below:", "ar": " يرجى اختيار أحد المواعيد المتاحة مما يلي:"}, "covid-alert-header": {"en": "Pay With-in 15 mins to confirm the appointment", "ar": "الرجاء اتمام عملية الدفع خلال 15 دقيقه لتاكيد الموعد"}, "covid-alert-info": { - "en": "Payment for Covid-19 Test should Be made with-in 15 mins otherwise The system will Cancel the Scheduled appointment automatically​", + "en": "Payment for Covid-19 Test should Be made with-in 15 mins otherwise The system will Cancel the Scheduled appointment automatically.", "ar": "سيتم الغاء الموعد عن طريق النظام بشكل الي في حال عدم اتمام عمليه الدفع خلال 15 دقيقة" }, "covid-alert-mins": {"en": "Pay With-in 15 mins", "ar": "ادفع خلال 15 دقيقة"}, @@ -2340,6 +2340,29 @@ const Map localizedValues = { "enableQuickLogin": {"en": "Enable Quick Login", "ar":"تمكين تسجيل الدخول السريع"}, "enableMsg": {"en": "Enabling the quick login will verify through your existing device Face ID / Biometric", "ar":"'تمكين تسجيل الدخول السريع سيسمح بالتحقق من خلال Face ID / Biometric الخاص بجهازك الحالي'"}, "notNow": {"en": "Not Now", "ar":"ليس الآن"}, + "fullName": {"en": "Full Name", "ar":"الاسم الكامل"}, + "personalDetailsVerificaion": {"en": "Personal Details Verification", "ar":"التحقق من التفاصيل الشخصية"}, + "married": {"en": "Married", "ar":"متزوج"}, + "uae": {"en": "United Arab Emirates", "ar":"الإمارات العربية المتحدة"}, + "enterFullName": {"en": "Please enter your Full Name", "ar":"الرجاء إدخال اسمك الكامل"}, + "chooseMaritalStatus": {"en": "Please choose Marital Status", "ar":"الرجاء اختيار الحالة الاجتماعية"}, + "chooseYourCountry": {"en": "Please choose Country", "ar":"الرجاء اختيار بلدك"}, + "enterEmailAddress": {"en": "Please enter your email address.", "ar":"الرجاء إدخال عنوان بريدك الإلكتروني."}, + "sendOTPSMS": {"en": "Send me OTP on SMS", "ar":"أرسل لي OTP عبر الرسائل القصيرة"}, + "sendOTPWHATSAPP": {"en": "Send me OTP on Whatsapp", "ar":"أرسل لي OTP عبر واتساب"}, + "validIQama": {"en": "Please enter a valid Iqama number", "ar":"الرجاء إدخال رقم إقامة صالح"}, + "oR": {"en": "OR", "ar":"أو"}, + "pleaseEnterNationalId": {"en": "Please enter your national id", "ar":"الرجاء إدخال رقم الهوية الوطنية الخاص بك"}, + "pleaseSelectCountry": {"en": "Please select your country", "ar":"الرجاء اختيار بلدك"}, + "pleaseSelectDOB": {"en": "Please enter your date of birth", "ar":"الرجاء إدخال تاريخ ميلادك"}, + "pleaseAcceptTermsConditions": {"en": "Please check agree to the term and conditions", "ar":"الرجاء الموافقة على الشروط والأحكام"}, + "lastLoginBy": {"en": "Last Login by", "ar":"آخر تسجيل دخول بواسطة"}, + "enterPhoneNumber": {"en": "Enter Phone Number", "ar":"أدخل رقم الهاتف"}, + "enterEmailDesc": {"en": "Enter your email address to complete the process of creating a medical file", "ar":"أدخل عنوان بريدك الإلكتروني لإكمال عملية إنشاء ملف طبي"}, + "enterPhoneDesc": {"en": "Enter your phone number to receive OTP verification code", "ar":"أدخل رقم هاتفك لتلقي رمز التحقق OTP"}, + "otpVerification": {"en": "OTP Verification", "ar":"التحقق من OTP"}, + "submiT": {"en": "Submit", "ar":"إرسال"}, + diff --git a/lib/models/Authentication/register_user_requet.dart b/lib/models/Authentication/register_user_requet.dart index bb0e967e..7c8e6340 100644 --- a/lib/models/Authentication/register_user_requet.dart +++ b/lib/models/Authentication/register_user_requet.dart @@ -113,7 +113,7 @@ class Patientobject { String? dateofBirthN; String? emailAddress; int? sourceType; - int? preferredLanguage; + dynamic? preferredLanguage; String? marital; Patientobject({ diff --git a/lib/models/Nationality_countires_model.dart b/lib/models/Nationality_countires_model.dart new file mode 100644 index 00000000..fb3961bb --- /dev/null +++ b/lib/models/Nationality_countires_model.dart @@ -0,0 +1,29 @@ +import 'dart:convert'; + +class NationalityCountries { + String? id; + String? name; + String? nameN; + + NationalityCountries({ + this.id, + this.name, + this.nameN, + }); + + factory NationalityCountries.fromRawJson(String str) => NationalityCountries.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory NationalityCountries.fromJson(Map json) => NationalityCountries( + id: json["ID"], + name: json["Name"], + nameN: json["NameN"], + ); + + Map toJson() => { + "ID": id, + "Name": name, + "NameN": nameN, + }; +} diff --git a/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart b/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart index 0f7efb46..a45b0f89 100644 --- a/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart +++ b/lib/new_ui/otp/otp_validation_bootmsheet_widget.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:hmg_patient_app/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; import 'package:hmg_patient_app/uitl/utils.dart'; +import 'package:hmg_patient_app/uitl/font_utils.dart'; import 'package:hmg_patient_app/widgets/text/app_texts_widget.dart'; class GenericBottomSheet extends StatefulWidget { @@ -11,8 +13,13 @@ class GenericBottomSheet extends StatefulWidget { final List buttons; TextEditingController? textController; final bool isForEmail; + Function(Country)? onCountryChange; + final bool isEnableCountryDropdown; + final bool isFromSavedLogin; - GenericBottomSheet({Key? key, this.countryCode = "", this.initialPhoneNumber = "", required this.buttons, this.textController, this.isForEmail = false}) : super(key: key); + GenericBottomSheet( + {Key? key, this.countryCode = "", this.initialPhoneNumber = "", required this.buttons, this.textController, this.isForEmail = false, this.onCountryChange, this.isEnableCountryDropdown = false, this.isFromSavedLogin = false}) + : super(key: key); @override _GenericBottomSheetState createState() => _GenericBottomSheetState(); @@ -34,66 +41,77 @@ class _GenericBottomSheetState extends State { onTap: () { FocusScope.of(context).unfocus(); // Dismiss the keyboard when tapping outside }, - child: Container( - padding: const EdgeInsets.all(24), - decoration: BoxDecoration( - color: Color(0xFFF8F8FA), - borderRadius: const BorderRadius.vertical(top: Radius.circular(16)), - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - // Title - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + child: Builder(builder: (context) { + final isRtl = Directionality.of(context) == TextDirection.rtl; + return Directionality( + textDirection: Directionality.of(context), + child: Container( + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + color: Color(0xFFF8F8FA), + borderRadius: const BorderRadius.vertical(top: Radius.circular(16)), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - AppText(widget.isForEmail ? "Enter Email Address" : "Enter Phone Number", - fontSize: 28, letterSpacing: -2, fontFamily: context.fontFamily, color: Color(0xFF2E3039), fontWeight: FontWeight.w600), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: SvgPicture.asset("assets/images/svg/cross-circle.svg", width: 24, height: 24)), + // Title + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText(widget.isForEmail ? TranslationBase.of(context).enterEmailAddress : TranslationBase.of(context).enterPhoneNumber, + fontSize: 28, letterSpacing: -2, color: Color(0xFF2E3039), fontWeight: FontWeight.w600), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: SvgPicture.asset("assets/images/svg/cross-circle.svg", width: 24, height: 24)), + ], + ), + const SizedBox(height: 10), + // Subtitle + AppText(widget.isForEmail ? TranslationBase.of(context).enterEmailDesc : TranslationBase.of(context).enterPhoneDesc, + fontSize: 16, color: Color(0xFF2E3039), fontWeight: FontWeight.w500), + const SizedBox(height: 10), + widget.textController != null + ? Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + newInputWidget( + widget.isForEmail ? TranslationBase.of(context).email : TranslationBase.of(context).phoneNumber, + widget.isForEmail ? "demo@gmail.com" : "5xxxxxxxx", + widget.textController!, + padding: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8), + + keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number, + onChange: (value) { + widget.textController!.text = value!; + }, + isEnable: true, + isReadOnly: widget.isFromSavedLogin, + prefix: widget.isForEmail ? null : widget.countryCode, + hasSelection: false, + isBorderAllowed: false, + isAllowLeadingIcon: true, + countryList: Country.values, + isCountryDropDown: widget.isEnableCountryDropdown, + // selectedCountry: widget, + onCountryChange: (Country country) { + widget.onCountryChange!(country); + }, + leadingIcon: widget.isForEmail ? "assets/images/svg/email.svg" : "assets/images/svg/smart-phone.svg", + ), + ], + ) + : SizedBox(), + SizedBox(height: 24), + ...widget.buttons, ], ), - const SizedBox(height: 10), - // Subtitle - AppText(widget.isForEmail ? "Enter your email address to complete the process of creating a medical file" : "Enter your phone number to receive OTP verification code", - fontSize: 16, fontFamily: context.fontFamily, color: Color(0xFF2E3039), fontWeight: FontWeight.w500), - const SizedBox(height: 10), - widget.textController != null - ? Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Directionality( - textDirection: TextDirection.ltr, - child: newInputWidget( - widget.isForEmail ? TranslationBase.of(context).email : TranslationBase.of(context).phoneNumber, - widget.isForEmail ? "demo@gmail.com" : "5xxxxxxxx", - widget.textController!, - padding: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8), - keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number, - onChange: (value) { - widget.textController!.text = value!; - }, - isEnable: true, - prefix: widget.isForEmail ? null : widget.countryCode, - hasSelection: false, - isBorderAllowed: false, - isAllowLeadingIcon: true, - leadingIcon: widget.isForEmail ? "assets/images/svg/email.svg" : "assets/images/svg/smart-phone.svg", - ), - ), - ], - ) - : SizedBox(), - SizedBox(height: 24), - ...widget.buttons, - ], - ), - ), + ), + ); + }), ), ); } @@ -123,7 +141,7 @@ class CustomButton extends StatelessWidget { this.textColor = Colors.white, this.borderRadius = 12, this.borderWidth = 1, - this.padding = const EdgeInsets.fromLTRB(8, 16, 8, 16), + this.padding = const EdgeInsets.fromLTRB(8, 10, 8, 10), this.fontSize = 16, this.fontFamily, this.fontWeight = FontWeight.w500, @@ -136,7 +154,6 @@ class CustomButton extends StatelessWidget { return GestureDetector( onTap: isDisabled ? null : onPressed, child: Container( - padding: padding, height: 56, decoration: BoxDecoration( color: isDisabled ? backgroundColor.withOpacity(0.5) : backgroundColor, @@ -146,29 +163,31 @@ class CustomButton extends StatelessWidget { width: borderWidth, ), ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - if (icon != null) - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: SvgPicture.asset( - icon!, - width: 24, - height: 24, + child: Padding( + padding: padding, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (icon != null) + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: SvgPicture.asset( + icon!, + width: 24, + height: 24, + ), + ), + Text( + text, + style: context.dynamicTextStyle( + fontSize: fontSize, + color: isDisabled ? textColor.withOpacity(0.5) : textColor, + fontWeight: fontWeight, ), ), - Text( - text, - style: TextStyle( - fontSize: fontSize, - fontFamily: fontFamily ?? context.fontFamily, - color: isDisabled ? textColor.withOpacity(0.5) : textColor, - fontWeight: fontWeight, - ), - ), - ], + ], + ), ), ), ); diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart index c43031c4..8157e5e7 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart @@ -4,6 +4,7 @@ import 'package:hmg_patient_app/pages/AlHabibMedicalService/health_calculator/ca import 'package:hmg_patient_app/theme/colors.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; import 'package:hmg_patient_app/uitl/utils.dart'; +import 'package:hmg_patient_app/uitl/font_utils.dart'; import 'package:hmg_patient_app/widgets/buttons/secondary_button.dart'; import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart'; import 'package:hmg_patient_app/widgets/transitions/fade_page.dart'; @@ -41,37 +42,27 @@ class _CarbsState extends State { double? fCalMeal; void calculateDietRatios() { - if (dropdownValue == TranslationBase - .of(context) - .dietVeryLow) { + if (dropdownValue == TranslationBase.of(context).dietVeryLow) { meals = 3; protein = 45; carbs = 10; fat = 45; - } else if (dropdownValue == TranslationBase - .of(context) - .dietLow) { + } else if (dropdownValue == TranslationBase.of(context).dietLow) { meals = 3; protein = 40; carbs = 30; fat = 30; - } else if (dropdownValue == TranslationBase - .of(context) - .dietModerate) { + } else if (dropdownValue == TranslationBase.of(context).dietModerate) { meals = 3; protein = 25; carbs = 50; fat = 25; - } else if (dropdownValue == TranslationBase - .of(context) - .dietUSDA) { + } else if (dropdownValue == TranslationBase.of(context).dietUSDA) { meals = 3; protein = 15; carbs = 55; fat = 30; - } else if (dropdownValue == TranslationBase - .of(context) - .dietZone) { + } else if (dropdownValue == TranslationBase.of(context).dietZone) { meals = 3; protein = 30; carbs = 40; @@ -97,17 +88,13 @@ class _CarbsState extends State { Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); - dropdownValue = TranslationBase - .of(context) - .dietVeryLow; + dropdownValue = TranslationBase.of(context).dietVeryLow; return AppScaffold( isShowAppBar: true, isShowDecPage: false, showNewAppBarTitle: true, showNewAppBar: true, - appBarTitle: TranslationBase - .of(context) - .carbohydrate, + appBarTitle: TranslationBase.of(context).carbohydrate, appBarIcons: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0), @@ -127,9 +114,7 @@ class _CarbsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - TranslationBase - .of(context) - .carbProteinDesc, + TranslationBase.of(context).carbProteinDesc, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -144,9 +129,7 @@ class _CarbsState extends State { mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ - inputWidget(TranslationBase - .of(context) - .calDay, "0", textController), + inputWidget(TranslationBase.of(context).calDay, "0", textController), InkWell( onTap: () { Navigator.push( @@ -157,14 +140,8 @@ class _CarbsState extends State { child: Padding( padding: const EdgeInsets.all(12.0), child: Text( - TranslationBase - .of(context) - .notSure, - style: TextStyle(fontSize: 12, - fontWeight: FontWeight.w600, - letterSpacing: -0.56, - color: CustomColors.accentColor, - decoration: TextDecoration.underline), + TranslationBase.of(context).notSure, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.accentColor, decoration: TextDecoration.underline), ), ), ) @@ -189,9 +166,7 @@ class _CarbsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - TranslationBase - .of(context) - .selectDiet, + TranslationBase.of(context).selectDiet, style: TextStyle( fontSize: 11, letterSpacing: -0.44, @@ -220,21 +195,11 @@ class _CarbsState extends State { }); }, items: [ - TranslationBase - .of(context) - .dietVeryLow, - TranslationBase - .of(context) - .dietLow, - TranslationBase - .of(context) - .dietModerate, - TranslationBase - .of(context) - .dietUSDA, - TranslationBase - .of(context) - .dietZone + TranslationBase.of(context).dietVeryLow, + TranslationBase.of(context).dietLow, + TranslationBase.of(context).dietModerate, + TranslationBase.of(context).dietUSDA, + TranslationBase.of(context).dietZone ].map>((String value) { return DropdownMenuItem( value: value, @@ -268,9 +233,7 @@ class _CarbsState extends State { margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), color: Colors.white, child: SecondaryButton( - label: TranslationBase - .of(context) - .calculate, + label: TranslationBase.of(context).calculate, color: CustomColors.accentColor, onTap: () { setState(() { @@ -280,16 +243,16 @@ class _CarbsState extends State { context, FadePage( page: CarbsResult( - cCal: cCal!, - pCal: pCal!, - fCal: fCal!, - pCalGram: pCalGram!, - pCalMeal: pCalMeal!, - fCalGram: fCalGram!, - fCalMeal: fCalMeal!, - cCalGram: cCalGram!, - cCalMeal: cCalMeal!, - )), + cCal: cCal!, + pCal: pCal!, + fCal: fCal!, + pCalGram: pCalGram!, + pCalMeal: pCalMeal!, + fCalGram: fCalGram!, + fCalMeal: fCalMeal!, + cCalGram: cCalGram!, + cCalMeal: cCalMeal!, + )), ); } }); @@ -345,29 +308,31 @@ class _CarbsState extends State { // } } -Widget inputWidget(String _labelText, - String _hintText, - TextEditingController? _controller, { - Function(String?)? onChange, - String? prefix, - bool isEnable = true, - bool hasSelection = false, - bool hasSelectionCustomIcon = false, - String? selectionCustomIcon, - bool isBorderAllowed = true, - bool isAllowLeadingIcon = false, - bool isLeadingCountry = false, - String? leadingIcon, - bool removePadding = false, - bool isAllowRadius = true, - bool isReadOnly = false, - TextInputType keyboardType = TextInputType.number, - List? dropdownItems, - String? selectedValue, - SelectionType? selectionType, - Function(bool)? onCalendarTypeChanged, - String lang = 'en', - }) { +Widget inputWidget( + String _labelText, + String _hintText, + TextEditingController? _controller, { + Function(String?)? onChange, + String? prefix, + bool isEnable = true, + bool hasSelection = false, + bool hasSelectionCustomIcon = false, + String? selectionCustomIcon, + bool isBorderAllowed = true, + bool isAllowLeadingIcon = false, + bool isLeadingCountry = false, + String? leadingIcon, + bool removePadding = false, + bool isAllowRadius = true, + bool isReadOnly = false, + TextInputType keyboardType = TextInputType.number, + List? dropdownItems, + String? selectedValue, + SelectionType? selectionType, + Function(bool)? onCalendarTypeChanged, + EdgeInsetsGeometry? padding, + String lang = 'en', +}) { return Builder( builder: (context) { final isRtl = Directionality.of(context) == TextDirection.rtl; @@ -375,7 +340,11 @@ Widget inputWidget(String _labelText, return Directionality( textDirection: Directionality.of(context), child: Container( - padding: removePadding ? const EdgeInsets.only(top: 16, bottom: 16) : const EdgeInsets.symmetric(horizontal: 16, vertical: 15), + padding: padding != null + ? padding + : removePadding + ? const EdgeInsets.only(top: 16, bottom: 16) + : const EdgeInsets.symmetric(horizontal: 16, vertical: 15), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: isAllowRadius ? BorderRadius.circular(15) : null, @@ -404,170 +373,186 @@ Widget inputWidget(String _labelText, children: [ Directionality( textDirection: Directionality.of(context), - child: Text( - _labelText, - textAlign: isRtl ? TextAlign.right : TextAlign.left, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w500, - color: const Color(0xff898A8D), - fontFamily: context.fontFamily, - letterSpacing: -0.2, - height: 18 / 12, - ), - ), + child: Text(_labelText, + textAlign: isRtl ? TextAlign.right : TextAlign.left, + style: context.dynamicTextStyle( + fontSize: 12, + fontWeight: FontWeight.w500, + color: const Color(0xff898A8D), + letterSpacing: -0.2, + height: 18 / 12, + ) + // style: TextStyle( + // fontSize: 12, + // fontWeight: FontWeight.w500, + // color: const Color(0xff898A8D), + // // fontFamily: FontUtils.getFontFamily(context), + // letterSpacing: -0.2, + // height: 18 / 12, + // ), + ), ), hasSelection ? GestureDetector( - onTap: isEnable && !isReadOnly - ? () async { - if (selectionType == SelectionType.dropdown) { - final renderBox = context.findRenderObject() as RenderBox; - final offset = renderBox.localToGlobal(Offset.zero); - final selected = await showMenu( - context: context, - position: RelativeRect.fromLTRB( - offset.dx, - offset.dy + renderBox.size.height, - offset.dx + renderBox.size.width, - 0, - ), - items: dropdownItems - ?.map( - (e) => - PopupMenuItem( - value: e, - child: Text(e), - ), - ) - .toList() ?? - [], - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - ), - ); + onTap: isEnable && !isReadOnly + ? () async { + if (selectionType == SelectionType.dropdown) { + final renderBox = context.findRenderObject() as RenderBox; + final offset = renderBox.localToGlobal(Offset.zero); + final selected = await showMenu( + context: context, + position: RelativeRect.fromLTRB( + offset.dx, + offset.dy + renderBox.size.height, + offset.dx + renderBox.size.width, + 0, + ), + items: dropdownItems + ?.map( + (e) => PopupMenuItem( + value: e, + child: Text(e), + ), + ) + .toList() ?? + [], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ); - if (selected != null && onChange != null) { - onChange(selected); - } - } else if (selectionType == SelectionType.calendar) { - bool isGregorian = true; - // final picked = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: DateTime(1900), lastDate: DateTime(2100)); - final picked = await showHijriGregBottomSheet( - context, - switcherIcon: SvgPicture.asset("assets/images/svg/language.svg", width: 24), - fontFamily: context.fontFamily, - language: lang, - initialDate: DateTime.now(), - okWidget: Padding( - padding: const EdgeInsets.only(right: 8.0), - child: SvgPicture.asset( - "assets/images/svg/confirm.svg", - width: 24, - height: 24, - ), - ), - cancelWidget: Padding( - padding: const EdgeInsets.only(right: 8.0), - child: SvgPicture.asset( - "assets/images/svg/cancel.svg", - colorFilter: ColorFilter.mode( - Colors.white, - BlendMode.srcIn, + if (selected != null && onChange != null) { + onChange(selected); + } + } else if (selectionType == SelectionType.calendar) { + bool isGregorian = true; + // final picked = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: DateTime(1900), lastDate: DateTime(2100)); + final picked = await showHijriGregBottomSheet( + context, + switcherIcon: SvgPicture.asset("assets/images/svg/language.svg", width: 24), + // fontFamily: FontUtils.getFontFamily(context), + language: lang, + initialDate: DateTime.now(), + okWidget: Padding( + padding: const EdgeInsets.only(right: 8.0), + child: SvgPicture.asset( + "assets/images/svg/confirm.svg", + width: 24, + height: 24, + ), + ), + cancelWidget: Padding( + padding: const EdgeInsets.only(right: 8.0), + child: SvgPicture.asset( + "assets/images/svg/cancel.svg", + colorFilter: ColorFilter.mode( + Colors.white, + BlendMode.srcIn, + ), + width: 24, + height: 24, + ), + ), + onCalendarTypeChanged: (bool value) { + isGregorian = value; + }, + ); + if (picked != null && onChange != null) { + print(picked.toIso8601String()); + if (onCalendarTypeChanged != null) { + print(isGregorian.toString()); + onCalendarTypeChanged.call(isGregorian); + } + onChange(picked.toIso8601String()); + } + } + } + : null, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text((selectedValue == null || selectedValue.isEmpty) ? _hintText : selectedValue, + textAlign: isRtl ? TextAlign.right : TextAlign.left, + textDirection: isRtl ? TextDirection.rtl : TextDirection.ltr, + style: context.dynamicTextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + // fontFamily: FontUtils.getFontFamily(context), + color: (selectedValue != null && selectedValue.isNotEmpty) ? const Color(0xff2E3039) : const Color(0xffB0B0B0), + letterSpacing: -0.2, + ) + // style: TextStyle( + // fontSize: 14, + // height: 21 / 14, + // fontWeight: FontWeight.w500, + // // fontFamily: FontUtils.getFontFamily(context), + // color: (selectedValue != null && selectedValue.isNotEmpty) ? const Color(0xff2E3039) : const Color(0xffB0B0B0), + // letterSpacing: -0.2, + // ), + ), ), - width: 24, - height: 24, - ), + if (hasSelectionCustomIcon && selectionCustomIcon != null) + SvgPicture.asset(selectionCustomIcon, width: 24, height: 24) + else + const Icon(Icons.keyboard_arrow_down_outlined), + ], ), - onCalendarTypeChanged: (bool value) { - isGregorian = value; - }, - ); - if (picked != null && onChange != null) { - print(picked.toIso8601String()); - if (onCalendarTypeChanged != null) { - print(isGregorian.toString()); - onCalendarTypeChanged.call(isGregorian); - } - onChange(picked.toIso8601String()); - } - } - } - : null, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - (selectedValue == null || selectedValue.isEmpty) ? _hintText : selectedValue, - textAlign: isRtl ? TextAlign.right : TextAlign.left, - textDirection: isRtl ? TextDirection.rtl : TextDirection.ltr, - style: TextStyle( + ) + : TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: keyboardType, + controller: _controller, + readOnly: isReadOnly, + textAlignVertical: TextAlignVertical.top, + textAlign: isRtl ? TextAlign.right : TextAlign.left, + textDirection: isRtl ? TextDirection.rtl : TextDirection.ltr, + onChanged: onChange, + style: context.dynamicTextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: const Color(0xff2E3039), + letterSpacing: -0.2, + ), + // TextStyle( + // fontSize: 14, + // height: 21 / 14, + // // fontFamily: FontUtils.getFontFamily(context), + // + // fontWeight: FontWeight.w500, + // color: const Color(0xff2E3039), + // letterSpacing: -0.2, + // ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: context.dynamicTextStyle( fontSize: 14, - height: 21 / 14, + height: 21 / 16, fontWeight: FontWeight.w500, - fontFamily: context.fontFamily, - color: (selectedValue != null && selectedValue.isNotEmpty) ? const Color(0xff2E3039) : const Color(0xffB0B0B0), + color: const Color(0xff898A8D), letterSpacing: -0.2, ), + prefixIconConstraints: const BoxConstraints(minWidth: 45), + prefixIcon: prefix == null + ? null + : Text("+" + prefix, + style: context.dynamicTextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: const Color(0xff2E303A), + letterSpacing: -0.2, + )), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, ), ), - if (hasSelectionCustomIcon && selectionCustomIcon != null) - SvgPicture.asset(selectionCustomIcon, width: 24, height: 24) - else - const Icon(Icons.keyboard_arrow_down_outlined), - ], - ), - ) - : TextField( - enabled: isEnable, - scrollPadding: EdgeInsets.zero, - keyboardType: keyboardType, - controller: _controller, - readOnly: isReadOnly, - textAlignVertical: TextAlignVertical.top, - textAlign: isRtl ? TextAlign.right : TextAlign.left, - textDirection: isRtl ? TextDirection.rtl : TextDirection.ltr, - onChanged: onChange, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontFamily: context.fontFamily, - fontWeight: FontWeight.w500, - color: const Color(0xff2E3039), - letterSpacing: -0.2, - ), - decoration: InputDecoration( - isDense: true, - hintText: _hintText, - hintStyle: TextStyle( - fontSize: 14, - height: 21 / 16, - fontFamily: context.fontFamily, - fontWeight: FontWeight.w500, - color: const Color(0xff898A8D), - letterSpacing: -0.2, - ), - prefixIconConstraints: const BoxConstraints(minWidth: 45), - prefixIcon: prefix == null - ? null - : Text( - "+" + prefix, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontFamily: context.fontFamily, - fontWeight: FontWeight.w500, - color: const Color(0xff2E303A), - letterSpacing: -0.2, - ), - ), - contentPadding: EdgeInsets.zero, - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - ), - ), ], ), ), @@ -579,30 +564,35 @@ Widget inputWidget(String _labelText, ); } -Widget newInputWidget(String _labelText, - String _hintText, - TextEditingController? _controller, { - Function(String?)? onChange, - String? prefix, - bool isEnable = true, - bool hasSelection = false, - bool hasSelectionCustomIcon = false, - String? selectionCustomIcon, - bool isBorderAllowed = true, - bool isAllowLeadingIcon = false, - bool isLeadingCountry = false, - String? leadingIcon, - bool removePadding = false, - bool isAllowRadius = true, - bool isReadOnly = false, - TextInputType keyboardType = TextInputType.number, - List? dropdownItems, - String? selectedValue, - SelectionType? selectionType, - Function(bool)? onCalendarTypeChanged, - EdgeInsetsGeometry? padding, - String lang = 'en', - }) { +Widget newInputWidget( + String _labelText, + String _hintText, + TextEditingController? _controller, { + Function(String?)? onChange, + String? prefix, + bool isEnable = true, + bool hasSelection = false, + bool hasSelectionCustomIcon = false, + String? selectionCustomIcon, + bool isBorderAllowed = true, + bool isAllowLeadingIcon = false, + bool isLeadingCountry = false, + String? leadingIcon, + bool removePadding = false, + bool isAllowRadius = true, + bool isReadOnly = false, + TextInputType keyboardType = TextInputType.number, + List? dropdownItems, + String? selectedValue, + SelectionType? selectionType, + Function(bool)? onCalendarTypeChanged, + EdgeInsetsGeometry? padding, + String lang = 'en', + bool isCountryDropDown = false, + List countryList = const [], + // Country? selectedCountry, + Function(Country)? onCountryChange, +}) { return Builder( builder: (context) { final isRtl = Directionality.of(context) == TextDirection.rtl; @@ -627,196 +617,193 @@ Widget newInputWidget(String _labelText, textDirection: Directionality.of(context), children: [ if (isAllowLeadingIcon && leadingIcon != null) - Directionality( - textDirection: Directionality.of(context), - child: Container( - height: 40, - width: 40, - margin: isRtl ? const EdgeInsets.only(left: 10) : const EdgeInsets.only(right: 10), - padding: isLeadingCountry ? null : const EdgeInsets.all(8), - decoration: const BoxDecoration( - color: Color(0xFFEFEFF0), - borderRadius: BorderRadius.all(Radius.circular(10)), - ), - child: SvgPicture.asset( - leadingIcon, - width: 24, - height: 24, - fit: BoxFit.cover, - ), - ), - ), + isCountryDropDown + ? _CustomCountryDropdown( + logo: SvgPicture.asset( + prefix == "966" ? "assets/images/svg/ksa.svg" : "assets/images/svg/uae.svg", + width: 40, + height: 40, + fit: BoxFit.cover, + ), + countryList: countryList, + onCountryChange: onCountryChange, + isRtl: isRtl, + ) + : Container( + height: 40, + width: 40, + margin: isRtl ? const EdgeInsets.only(left: 10) : const EdgeInsets.only(right: 10), + padding: isLeadingCountry ? null : const EdgeInsets.all(8), + decoration: const BoxDecoration( + color: Color(0xFFEFEFF0), + borderRadius: BorderRadius.all(Radius.circular(10)), + ), + child: SvgPicture.asset( + leadingIcon, + width: 24, + height: 24, + fit: BoxFit.cover, + ), + ), Expanded( child: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: isRtl ? CrossAxisAlignment.end : CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Directionality( - textDirection: Directionality.of(context), - child: Text( - _labelText, - // textAlign: isRtl ? TextAlign.right : TextAlign.left, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w500, - color: const Color(0xff898A8D), - fontFamily: context.fontFamily, - letterSpacing: -0.2, - height: 18 / 12, - ), + Text( + _labelText, + style: context.dynamicTextStyle( + fontSize: 12, + fontWeight: FontWeight.w500, + color: const Color(0xff898A8D), + letterSpacing: -0.2, + height: 18 / 12, ), ), hasSelection ? GestureDetector( - onTap: isEnable && !isReadOnly - ? () async { - if (selectionType == SelectionType.dropdown) { - final renderBox = context.findRenderObject() as RenderBox; - final offset = renderBox.localToGlobal(Offset.zero); - final selected = await showMenu( - context: context, - position: RelativeRect.fromLTRB( - offset.dx, - offset.dy + renderBox.size.height, - offset.dx + renderBox.size.width, - 0, - ), - items: dropdownItems - ?.map( - (e) => - PopupMenuItem( - value: e, - child: Text(e), - ), - ) - .toList() ?? - [], - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - ), - ); + onTap: isEnable && !isReadOnly + ? () async { + if (selectionType == SelectionType.dropdown) { + final renderBox = context.findRenderObject() as RenderBox; + final offset = renderBox.localToGlobal(Offset.zero); + final selected = await showMenu( + context: context, + position: RelativeRect.fromLTRB( + offset.dx, + offset.dy + renderBox.size.height, + offset.dx + renderBox.size.width, + 0, + ), + items: dropdownItems + ?.map( + (e) => PopupMenuItem( + value: e, + child: Text(e), + ), + ) + .toList() ?? + [], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ); - if (selected != null && onChange != null) { - onChange(selected); - } - } else if (selectionType == SelectionType.calendar) { - bool isGregorian = true; - // final picked = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: DateTime(1900), lastDate: DateTime(2100)); - final picked = await showHijriGregBottomSheet( - context, - switcherIcon: SvgPicture.asset("assets/images/svg/language.svg", width: 24), - fontFamily: context.fontFamily, - language: lang, - initialDate: DateTime.now(), - okWidget: Padding( - padding: const EdgeInsets.only(right: 8.0), - child: SvgPicture.asset( - "assets/images/svg/confirm.svg", - width: 24, - height: 24, - ), - ), - cancelWidget: Padding( - padding: const EdgeInsets.only(right: 8.0), - child: SvgPicture.asset( - "assets/images/svg/cancel.svg", - colorFilter: ColorFilter.mode( - Colors.white, - BlendMode.srcIn, + if (selected != null && onChange != null) { + onChange(selected); + } + } else if (selectionType == SelectionType.calendar) { + bool isGregorian = true; + // final picked = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: DateTime(1900), lastDate: DateTime(2100)); + final picked = await showHijriGregBottomSheet( + context, + switcherIcon: SvgPicture.asset("assets/images/svg/language.svg", width: 24), + // fontFamily: FontUtils.getFontFamily(context), + language: lang, + initialDate: DateTime.now(), + okWidget: Padding( + padding: const EdgeInsets.only(right: 8.0), + child: SvgPicture.asset( + "assets/images/svg/confirm.svg", + width: 24, + height: 24, + ), + ), + cancelWidget: Padding( + padding: const EdgeInsets.only(right: 8.0), + child: SvgPicture.asset( + "assets/images/svg/cancel.svg", + colorFilter: ColorFilter.mode( + Colors.white, + BlendMode.srcIn, + ), + width: 24, + height: 24, + ), + ), + onCalendarTypeChanged: (bool value) { + isGregorian = value; + }, + ); + if (picked != null && onChange != null) { + print(picked.toIso8601String()); + if (onCalendarTypeChanged != null) { + print(isGregorian.toString()); + onCalendarTypeChanged.call(isGregorian); + } + onChange(picked.toIso8601String()); + } + } + } + : null, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text((selectedValue == null || selectedValue.isEmpty) ? _hintText : selectedValue, + textAlign: isRtl ? TextAlign.right : TextAlign.left, + textDirection: isRtl ? TextDirection.rtl : TextDirection.ltr, + style: context.dynamicTextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: (selectedValue != null && selectedValue.isNotEmpty) ? const Color(0xff2E3039) : const Color(0xffB0B0B0), + letterSpacing: -0.2, + )), ), - width: 24, - height: 24, - ), + if (hasSelectionCustomIcon && selectionCustomIcon != null) + SvgPicture.asset(selectionCustomIcon, width: 24, height: 24) + else + const Icon(Icons.keyboard_arrow_down_outlined), + ], ), - onCalendarTypeChanged: (bool value) { - isGregorian = value; - }, - ); - if (picked != null && onChange != null) { - print(picked.toIso8601String()); - if (onCalendarTypeChanged != null) { - print(isGregorian.toString()); - onCalendarTypeChanged.call(isGregorian); - } - onChange(picked.toIso8601String()); - } - } - } - : null, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - (selectedValue == null || selectedValue.isEmpty) ? _hintText : selectedValue, - textAlign: isRtl ? TextAlign.right : TextAlign.left, - textDirection: isRtl ? TextDirection.rtl : TextDirection.ltr, - style: TextStyle( + ) + : TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: keyboardType, + controller: _controller, + readOnly: isReadOnly, + textAlignVertical: TextAlignVertical.top, + textAlign: isRtl ? TextAlign.right : TextAlign.left, + textDirection: isRtl ? TextDirection.rtl : TextDirection.ltr, + onChanged: onChange, + style: context.dynamicTextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: const Color(0xff2E3039), + letterSpacing: -0.2, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: context.dynamicTextStyle( fontSize: 14, - height: 21 / 14, + height: 21 / 16, fontWeight: FontWeight.w500, - fontFamily: context.fontFamily, - color: (selectedValue != null && selectedValue.isNotEmpty) ? const Color(0xff2E3039) : const Color(0xffB0B0B0), + color: const Color(0xff898A8D), letterSpacing: -0.2, ), + prefixIconConstraints: const BoxConstraints(minWidth: 45), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: context.dynamicTextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: const Color(0xff2E303A), + letterSpacing: -0.2, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, ), ), - if (hasSelectionCustomIcon && selectionCustomIcon != null) - SvgPicture.asset(selectionCustomIcon, width: 24, height: 24) - else - const Icon(Icons.keyboard_arrow_down_outlined), - ], - ), - ) - : TextField( - enabled: isEnable, - scrollPadding: EdgeInsets.zero, - keyboardType: keyboardType, - controller: _controller, - readOnly: isReadOnly, - textAlignVertical: TextAlignVertical.top, - textAlign: isRtl ? TextAlign.right : TextAlign.left, - textDirection: isRtl ? TextDirection.rtl : TextDirection.ltr, - onChanged: onChange, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontFamily: context.fontFamily, - fontWeight: FontWeight.w500, - color: const Color(0xff2E3039), - letterSpacing: -0.2, - ), - decoration: InputDecoration( - isDense: true, - hintText: _hintText, - hintStyle: TextStyle( - fontSize: 14, - height: 21 / 16, - fontFamily: context.fontFamily, - fontWeight: FontWeight.w500, - color: const Color(0xff898A8D), - letterSpacing: -0.2, - ), - prefixIconConstraints: const BoxConstraints(minWidth: 45), - prefixIcon: prefix == null - ? null - : Text( - "+" + prefix, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontFamily: context.fontFamily, - fontWeight: FontWeight.w500, - color: const Color(0xff2E303A), - letterSpacing: -0.2, - ), - ), - contentPadding: EdgeInsets.zero, - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - ), - ), ], ), ), @@ -829,8 +816,7 @@ Widget newInputWidget(String _labelText, } extension BorderedContainer on Widget { - Widget get withBorderedContainer => - Container( + Widget get withBorderedContainer => Container( padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), alignment: Alignment.center, decoration: BoxDecoration( @@ -844,3 +830,136 @@ extension BorderedContainer on Widget { child: this, ); } + +class _CustomCountryDropdown extends StatefulWidget { + final SvgPicture logo; + final List countryList; + final Function(Country)? onCountryChange; + final bool isRtl; + + const _CustomCountryDropdown({ + Key? key, + required this.logo, + required this.countryList, + this.onCountryChange, + required this.isRtl, + }) : super(key: key); + + @override + __CustomCountryDropdownState createState() => __CustomCountryDropdownState(); +} + +class __CustomCountryDropdownState extends State<_CustomCountryDropdown> { + Country? selectedCountry; + late OverlayEntry _overlayEntry; + bool _isDropdownOpen = false; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + if (_isDropdownOpen) { + _closeDropdown(); + } else { + _openDropdown(); + } + }, + child: Container( + height: 40, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + ), + child: Row( + children: [ + widget.logo, + SizedBox(width: 8), + SvgPicture.asset( + _isDropdownOpen ? "assets/images/svg/dropdow-icon.svg" : "assets/images/svg/dropdow-icon.svg", + width: 24, + height: 24, + ), + ], + ), + ), + ); + } + + void _openDropdown() { + RenderBox renderBox = context.findRenderObject() as RenderBox; + Offset offset = renderBox.localToGlobal(Offset.zero); + + _overlayEntry = OverlayEntry( + builder: (context) => Stack( + children: [ + // Dismiss dropdown when tapping outside + Positioned.fill( + child: GestureDetector( + onTap: _closeDropdown, + behavior: HitTestBehavior.translucent, + child: Container(), + ), + ), + Positioned( + top: offset.dy + renderBox.size.height, + left: widget.isRtl ? offset.dx + 15 : offset.dx - 15, + width: renderBox.size.width, + child: Material( + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Color(0xFFF8F8FA), + blurRadius: 8, + offset: Offset(0, 2), + ), + ], + ), + child: Column( + children: widget.countryList + .map( + (country) => GestureDetector( + onTap: () { + setState(() { + selectedCountry = country; + }); + widget.onCountryChange?.call(country); + _closeDropdown(); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 12, horizontal: 16), + child: Row( + children: [ + SvgPicture.asset( + country.iconPath, + width: 38, + height: 38, + fit: BoxFit.cover, + ), + ], + ), + ), + ), + ) + .toList(), + ), + ), + ), + ), + ], + ), + ); + + Overlay.of(context)?.insert(_overlayEntry); + setState(() { + _isDropdownOpen = true; + }); + } + + void _closeDropdown() { + _overlayEntry.remove(); + setState(() { + _isDropdownOpen = false; + }); + } +} diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 43c27f36..979ceab2 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -747,11 +747,14 @@ class _LandingPageState extends State with WidgetsBindingObserver { context: context, backgroundColor: Colors.transparent, isScrollControlled: true, - builder: (context) => QuickLoginBottomSheet( - isDone:isDone, - onPressed: (){ - loginWithFingerPrintFace(3, 1, user, deviceToken); - },), + builder: (context) => Padding( + padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), + child: QuickLoginBottomSheet( + isDone:isDone, + onPressed: (){ + loginWithFingerPrintFace(3, 1, user, deviceToken); + },), + ), ); } loginWithFingerPrintFace(type, int isActive, AuthenticatedUser user, String deviceToken ) async { diff --git a/lib/pages/login/register_new.dart b/lib/pages/login/register_new.dart index 9a6497d3..b00e521e 100644 --- a/lib/pages/login/register_new.dart +++ b/lib/pages/login/register_new.dart @@ -21,6 +21,7 @@ import 'package:hmg_patient_app/services/authentication/auth_provider.dart'; import 'package:hmg_patient_app/theme/colors.dart'; import 'package:hmg_patient_app/uitl/app_shared_preferences.dart'; import 'package:hmg_patient_app/uitl/app_toast.dart'; +import 'package:hmg_patient_app/uitl/font_utils.dart'; import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; import 'package:hmg_patient_app/uitl/utils.dart'; @@ -54,7 +55,8 @@ class _RegisterNew extends State { final int loginType = LoginType.loginType; late String mobileNo; - String countryCode = '966'; + + // String countryCode = '966'; var isHijri; final util = Utils(); @@ -85,9 +87,6 @@ class _RegisterNew extends State { @override Widget build(BuildContext context) { return AppScaffold( - // extendBody: true, - // extendBodyBehindAppBar: true, - appBarTitle: TranslationBase.of(context).register, isShowDecPage: false, isShowAppBar: true, @@ -105,7 +104,7 @@ class _RegisterNew extends State { }, body: GestureDetector( onTap: () { - FocusScope.of(context).unfocus(); // Dismiss the keyboard when tapping outside + FocusScope.of(context).unfocus(); }, child: ScrollConfiguration( behavior: ScrollConfiguration.of(context).copyWith(overscroll: false, physics: const ClampingScrollPhysics()), @@ -115,7 +114,7 @@ class _RegisterNew extends State { return true; }, child: SingleChildScrollView( - physics: ClampingScrollPhysics(), // Remove NeverScrollableScrollPhysics() + physics: ClampingScrollPhysics(), padding: EdgeInsets.only( left: 24, right: 24, @@ -135,7 +134,13 @@ class _RegisterNew extends State { Text( TranslationBase.of(context).prepareToElevate, textScaler: TextScaler.linear(MediaQuery.textScalerOf(context).scale(1)), - style: TextStyle(fontSize: 28, fontFamily: context.fontFamily, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.4, height: 40 / 28), + style: context.dynamicTextStyle( + fontSize: 28, + fontWeight: FontWeight.bold, + color: Color(0xff2B353E), + letterSpacing: -0.4, + height: 40 / 28, + ), ), SizedBox(height: 24), Directionality( @@ -147,7 +152,7 @@ class _RegisterNew extends State { children: [ newInputWidget( TranslationBase.of(context).country, - "Kingdom Of Saudi Arabia", + TranslationBase.of(context).ksa, nationalIDorFile, isEnable: true, prefix: null, @@ -157,6 +162,7 @@ class _RegisterNew extends State { selectionType: SelectionType.dropdown, onChange: (val) { if (val != null) { + print(val); setState(() { selectedCountry = CountryExtension.fromDisplayName(val); }); @@ -200,16 +206,13 @@ class _RegisterNew extends State { lang: context.selectedLanguage, padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), leadingIcon: "assets/images/svg/birthday-cake.svg", onChange: (value) { - print("=========== " + value!); - selectedDOB = DateTime.parse(value); + selectedDOB = DateTime.parse(value!); setState(() {}); }, onCalendarTypeChanged: (bool value) { if (value) { - print("gregorian"); - isHijri = 0; // Hijri + isHijri = 0; } else { - print("hijri"); - isHijri = 1; // Gregorian + isHijri = 1; } }).withVerticalPadding(8), ], @@ -256,23 +259,27 @@ class _RegisterNew extends State { onPressed: () { // bool isValid = Utils.validateIqama(nationalIDorFile.text); if (nationalIDorFile == null) { - Utils.showErrorToast("Please enter your national id."); + Utils.showErrorToast(TranslationBase.of(context).pleaseEnterNationalId); return; } if (selectedCountry == null) { - Utils.showErrorToast("Please select your country."); + Utils.showErrorToast(TranslationBase.of(context).pleaseSelectCountry); return; } if (selectedDOB == null) { - Utils.showErrorToast("Please enter your date of birth."); + Utils.showErrorToast(TranslationBase.of(context).pleaseSelectDOB); return; } if (!isTermsAccepted) { - Utils.showErrorToast("Please accept the terms and conditions."); + Utils.showErrorToast(TranslationBase.of(context).pleaseAcceptTermsConditions); return; } + if (phoneController != null) { + phoneController.clear(); + } + showModalBottomSheet( context: context, isScrollControlled: true, @@ -289,14 +296,14 @@ class _RegisterNew extends State { Padding( padding: const EdgeInsets.only(bottom: 10), child: CustomButton( - text: "Send me OTP on SMS", + text: TranslationBase.of(context).sendOTPSMS, onPressed: () { int? val = Utils.onOtpBtnPressed(OTPType.sms, phoneController); registerUser(val); //if (val != null) checkUserAuthentication(val); }, - backgroundColor: Colors.red, - borderColor: Colors.red, + backgroundColor: CustomColors.bgRedColor, + borderColor: CustomColors.bgRedBorderColor, textColor: Colors.white, icon: "assets/images/svg/message.svg", ), @@ -308,7 +315,7 @@ class _RegisterNew extends State { Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: AppText( - "OR", + TranslationBase.of(context).oR, fontSize: 16, fontFamily: context.fontFamily, color: Color(0xFF2E3039), @@ -320,7 +327,7 @@ class _RegisterNew extends State { Padding( padding: const EdgeInsets.only(bottom: 10, top: 10), child: CustomButton( - text: "Send me OTP on WhatsApp", + text: TranslationBase.of(context).sendOTPWHATSAPP, onPressed: () { int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, phoneController); registerUser(val); @@ -345,28 +352,21 @@ class _RegisterNew extends State { child: RichText( textAlign: TextAlign.center, text: TextSpan( - style: TextStyle( + style: context.dynamicTextStyle( color: Colors.black, fontSize: 16, height: 26 / 16, - fontFamily: context.fontFamily, fontWeight: FontWeight.w500, ), children: [ - TextSpan( - text: TranslationBase.of(context).alreadyHaveAccount, - style: TextStyle( - fontFamily: context.fontFamily, - ), - ), + TextSpan(text: TranslationBase.of(context).alreadyHaveAccount, style: context.dynamicTextStyle()), TextSpan(text: " "), TextSpan( text: TranslationBase.of(context).loginNow, - style: TextStyle( - color: Colors.red, + style: context.dynamicTextStyle( + color: CustomColors.bgRedColor, fontSize: 16, height: 26 / 16, - fontFamily: context.fontFamily, fontWeight: FontWeight.w500, ), recognizer: TapGestureRecognizer() @@ -466,8 +466,8 @@ class _RegisterNew extends State { var request = CheckPatientForRegistration(); request.patientMobileNumber = int.parse(mobileNo); - request.zipCode = countryCode; - request.patientOutSA = countryCode == '966' ? 0 : 1; + request.zipCode = selectedCountry.countryCode; + request.patientOutSA = selectedCountry.countryCode == '966' ? 0 : 1; request.patientIdentificationID = int.parse(nationalIDorFile.text); request.patientID = 0; request.isRegister = true; @@ -528,9 +528,7 @@ class _RegisterNew extends State { if (request.patientOutSA == 0) { this.chekUserData(response['LogInTokenID'], type); // ظ ; } else { - //Dubai registration page should be navigate from here.. - - // Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex, fromRegistration: true, isDubai: true))); + sendActivationCode(type, response['LogInTokenID'], null); } } } else { @@ -549,31 +547,25 @@ class _RegisterNew extends State { } chekUserData(loginToken, int type) { - // let m = hijri(this.dateOfBirth).locale('en'); - // // const dateHijri = m.format('iDD/iMM/iYYYY'); - // const request = { - // PatientIdentificationID: this.id.toString(), - // // TokenID: token, - // DOB: this.dateOption === '1' ? this.dateOfBirth : moment(this.dateOfBirth).format('DD/MM/YYYY'), - // IsHijri: Number(this.dateOption) - // } - GifLoaderDialogUtils.showMyDialog(context); var request = CheckUserStatusRequest(); request.patientIdentificationID = nationalIDorFile.text; request.dOB = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); request.isHijri = isHijri; - request.patientOutSA = countryCode == '966' ? 0 : 1; + request.patientOutSA = selectedCountry.countryCode == '966' ? 0 : 1; this.authService.checkUserStatus(request).then((result) { GifLoaderDialogUtils.hideDialog(context); if (result is Map) { + RegisterInfoResponse? resultSet; + CheckUserStatusResponse res = CheckUserStatusResponse.fromJson(result as Map); nHICData = res; sharedPref.setObject(NHIC_DATA, res.toJson()); + resultSet = RegisterInfoResponse.fromJson(res.toJson()); + // widget.changePageViewIndex!(1), // Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex, fromRegistration: true))), - RegisterInfoResponse resultSet = RegisterInfoResponse.fromJson(res.toJson()); sendActivationCode(type, loginToken, resultSet); } else { AppToast.showErrorToast(message: result != null ? result : TranslationBase.of(context).somethingWentWrong); @@ -581,7 +573,7 @@ class _RegisterNew extends State { }); } - sendActivationCode(type, loginTokenID, RegisterInfoResponse nHICData) async { + sendActivationCode(type, loginTokenID, RegisterInfoResponse? nHICData) async { LoginTokenID = loginTokenID; var request = authService.getCommonRequest( registerd_data: null, @@ -593,21 +585,19 @@ class _RegisterNew extends State { selectedOption: type, user: SelectDeviceIMEIRES()); request.isRegister = true; - // request.searchType =1 ; request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); request.sMSSignature = await SMSOTP.getSignature(); - - // selectedOption = type; GifLoaderDialogUtils.showMyDialog(context); - // if (healthId != null || isDubai) { - // if (!isDubai) { - // // request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); - // request.dob = nHICData.isHijri == true ? nHICData.dateOfBirth : dateFormat.format(dateFormat.parse(nHICData.dateOfBirth!)); - // } - request.healthId = nHICData.healthId; + + if (selectedCountry.countryCode == "966") { + request.healthId = nHICData!.healthId; + request.nationalID = nHICData.idNumber; + request.patientIdentificationID = nHICData.idNumber; + } else { + request.nationalID = nationalIDorFile.text; + request.patientIdentificationID = nationalIDorFile.text; + } request.isHijri = isHijri ?? 0; - request.nationalID = nHICData.idNumber; - request.patientIdentificationID = nHICData.idNumber; request.oTPSendType = type; await this.authService.sendActivationCodeRegister(request).then((result) { GifLoaderDialogUtils.hideDialog(context); @@ -640,10 +630,12 @@ class _RegisterNew extends State { // request['DOB'] = dob; // } request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); - request.healthId = nHICData!.healthId!; + if (selectedCountry.countryCode == "966") { + request.healthId = nHICData!.healthId!; + } request.isHijri = isHijri ?? 0; - request.nationalID = nHICData!.idNumber; - request.patientIdentificationID = nHICData!.idNumber; + request.nationalID = selectedCountry.countryCode == "966" ? nHICData!.idNumber : nationalIDorFile.text; + request.patientIdentificationID = selectedCountry.countryCode == "966" ? nHICData!.idNumber : nationalIDorFile.text; request.isRegister = true; authService @@ -656,7 +648,7 @@ class _RegisterNew extends State { //next registration page navigate from here. Navigator.of(context).push( - FadePage(page: RegisterNewStep2(nHICData!, request)), + FadePage(page: RegisterNewStep2(nHICData, request)), ) // // if(widget.isDubai ==false){ diff --git a/lib/pages/login/register_new_step_2.dart b/lib/pages/login/register_new_step_2.dart index 06ac2cc5..77476fa2 100644 --- a/lib/pages/login/register_new_step_2.dart +++ b/lib/pages/login/register_new_step_2.dart @@ -6,18 +6,21 @@ import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; import 'package:hmg_patient_app/extensions/string_extensions.dart'; import 'package:hmg_patient_app/locator.dart'; import 'package:hmg_patient_app/models/Appointments/toDoCountProviderModel.dart'; -import 'package:hmg_patient_app/models/Authentication/check_activation_code_response.dart'; +import 'package:hmg_patient_app/models/Authentication/check_activation_code_response.dart' hide List; import 'package:hmg_patient_app/models/Authentication/check_user_status_reponse.dart'; import 'package:hmg_patient_app/models/Authentication/register_info_response.dart'; import 'package:hmg_patient_app/models/Authentication/send_activation_request.dart'; +import 'package:hmg_patient_app/models/Nationality_countires_model.dart'; import 'package:hmg_patient_app/new_ui/otp/otp_validation_bootmsheet_widget.dart'; import 'package:hmg_patient_app/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart'; +import 'package:hmg_patient_app/pages/Blood/blood_donation.dart'; import 'package:hmg_patient_app/pages/login/login-type.dart'; import 'package:hmg_patient_app/pages/login/register-info.dart'; import 'package:hmg_patient_app/pages/login/register.dart'; import 'package:hmg_patient_app/pages/login/register_new.dart'; import 'package:hmg_patient_app/pages/login/welcome.dart'; import 'package:hmg_patient_app/services/authentication/auth_provider.dart'; +import 'package:hmg_patient_app/services/clinic_services/get_clinic_service.dart'; import 'package:hmg_patient_app/theme/colors.dart'; import 'package:hmg_patient_app/uitl/app_shared_preferences.dart'; import 'package:hmg_patient_app/uitl/app_toast.dart'; @@ -28,17 +31,14 @@ import 'package:hmg_patient_app/uitl/utils.dart'; import 'package:hmg_patient_app/uitl/utils_new.dart'; import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; -import 'package:hmg_patient_app/widgets/text/app_texts_widget.dart'; import 'package:hmg_patient_app/widgets/transitions/fade_page.dart'; import 'package:provider/provider.dart'; - import '../../widgets/dialogs/confirm_dialog.dart'; import 'package:hijri/hijri_calendar.dart'; import 'package:intl/intl.dart'; -import 'package:provider/provider.dart'; class RegisterNewStep2 extends StatefulWidget { - CheckUserStatusResponse nHICData; + CheckUserStatusResponse? nHICData; SendActivationRequest payload; RegisterNewStep2(this.nHICData, this.payload, {Key? key}) : super(key: key); @@ -49,77 +49,133 @@ class RegisterNewStep2 extends StatefulWidget { class _RegisterNew extends State { final emailAddress = TextEditingController(); - final int loginType = LoginType.loginType; - late String mobileNo; - String countryCode = '966'; final authService = new AuthProvider(); final sharedPref = new AppSharedPreferences(); AuthenticatedUserObject authenticatedUserObject = locator(); late ProjectViewModel projectViewModel; + bool isFromDubai = false; + List countriesList = []; + + // TextEditingController nationality = TextEditingController(); + String? name, nationalId; + + NationalityCountries? selectedCountry; + GenderType? selectedGenderType; + MaritalStatusType? selectedMaritalStatusType; @override void initState() { super.initState(); + isFromDubai = widget.payload.zipCode!.contains("971") || widget.payload.zipCode!.contains("+971"); + if (isFromDubai) { + getCountries(); + } + // isFromDubai = widget.payload.zipCode!.contains("971") || widget.payload.zipCode!.contains("+971"); + } + + getCountries() { + ClinicListService service = ClinicListService(); + service.getCountries().then((res) { + if (res['MessageStatus'] == 1) { + print(res['ListNationality']); + countriesList = (res['ListNationality'] as List).map((e) => NationalityCountries.fromJson(e)).toList(); + setState(() {}); + } + }).catchError((err) { + print(err); + }); } @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); return AppScaffold( - appBarTitle: "Personal Details Verification", - isShowDecPage: false, - isShowAppBar: true, - isshowBackButton: true, - showNewAppBar: true, - backgroundColor: Color(0xffF8F8F8), - showNewAppBarTitle: true, - showDropDown: false, - isShowLanguageChanger: false, - showHomeAppBarIcon: false, - resizeToAvoidBottomInset: true, - appBarIcons: [], - dropDownIndexChange: (value) { - Utils.changeAppLanguage(context: context); - }, - body: SafeArea( - child: SingleChildScrollView( - reverse: false, - padding: EdgeInsets.only(left: 24, right: 24, top: 24), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Directionality( - textDirection: Directionality.of(context), - child: Container( - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(24)), - padding: EdgeInsets.only(left: 16, right: 16), - child: Column( - children: [ - inputWidget(TranslationBase.of(context).name, (widget.nHICData.firstNameEn!.toUpperCase() + " " + widget.nHICData.lastNameEn!.toUpperCase()), null, + appBarTitle: TranslationBase.of(context).personalDetailsVerificaion, + isShowDecPage: false, + isShowAppBar: true, + isshowBackButton: true, + showNewAppBar: true, + backgroundColor: Color(0xffF8F8F8), + showNewAppBarTitle: true, + showDropDown: false, + isShowLanguageChanger: false, + showHomeAppBarIcon: false, + resizeToAvoidBottomInset: true, + appBarIcons: [], + dropDownIndexChange: (value) { + Utils.changeAppLanguage(context: context); + }, + body: SingleChildScrollView( + reverse: false, + padding: EdgeInsets.only(left: 24, right: 24, top: 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Directionality( + textDirection: Directionality.of(context), + child: Container( + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(24)), + padding: EdgeInsets.only(left: 16, right: 16), + child: Column( + children: [ + inputWidget(isFromDubai ? TranslationBase.of(context).fullName : TranslationBase.of(context).name, + isFromDubai ? name ?? "" : (widget.nHICData!.firstNameEn!.toUpperCase() + " " + widget.nHICData!.lastNameEn!.toUpperCase()), null, + isEnable: true, + prefix: null, + removePadding: true, + isAllowRadius: false, + hasSelection: false, + isBorderAllowed: false, + keyboardType: TextInputType.text, + isAllowLeadingIcon: true, + isReadOnly: isFromDubai ? false : true, + leadingIcon: "assets/images/svg/user-circle.svg", onChange: (value) { + name = value; + setState(() {}); + }), + Divider(height: 1), + inputWidget(TranslationBase.of(context).nationalIdNumber, isFromDubai ? widget.payload.nationalID! : (widget.nHICData!.idNumber ?? ""), null, + isEnable: true, + prefix: null, + removePadding: true, + isAllowRadius: false, + hasSelection: false, + isBorderAllowed: false, + isAllowLeadingIcon: true, + isReadOnly: true, + leadingIcon: "assets/images/svg/student-card.svg", + onChange: (value) {}), + Divider(height: 1), + isFromDubai + ? inputWidget( + TranslationBase.of(context).gender, + TranslationBase.of(context).male, + null, isEnable: true, prefix: null, - removePadding: true, - isAllowRadius: false, - hasSelection: false, + hasSelection: true, + dropdownItems: GenderType.values.map((e) => context.selectedLanguage == "ar" ? e.typeAr : e.type).toList(), + selectedValue: context.selectedLanguage == "ar" ? selectedGenderType!.typeAr : selectedGenderType?.type, + selectionType: SelectionType.dropdown, + onChange: (val) { + if (val != null) { + print(val); + setState(() { + selectedGenderType = GenderTypeExtension.fromType(val); + }); + } + }, isBorderAllowed: false, isAllowLeadingIcon: true, - isReadOnly: true, - leadingIcon: "assets/images/svg/user-circle.svg", - onChange: (value) {}), - Divider(height: 1), - inputWidget(TranslationBase.of(context).nationalIdNumber, (widget.nHICData.idNumber ?? ""), null, - isEnable: true, - prefix: null, + hasSelectionCustomIcon: true, removePadding: true, + isLeadingCountry: false, isAllowRadius: false, - hasSelection: false, - isBorderAllowed: false, - isAllowLeadingIcon: true, - isReadOnly: true, - leadingIcon: "assets/images/svg/student-card.svg", - onChange: (value) {}), - Divider(height: 1), - inputWidget(TranslationBase.of(context).gender, (widget.nHICData.gender ?? ""), null, + padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), + selectionCustomIcon: "assets/images/svg/arrow-down.svg", + leadingIcon: 'assets/images/svg/user-full.svg', + ).withVerticalPadding(8) + : inputWidget(TranslationBase.of(context).gender, (widget.nHICData!.gender ?? ""), null, isEnable: true, prefix: null, removePadding: true, @@ -127,23 +183,39 @@ class _RegisterNew extends State { hasSelection: false, isBorderAllowed: false, isAllowLeadingIcon: true, - isReadOnly: true, + isReadOnly: isFromDubai ? false : true, leadingIcon: "assets/images/svg/user-full.svg", onChange: (value) {}), - Divider(height: 1), - inputWidget(TranslationBase.of(context).maritalStatus, (widget.nHICData.maritalStatus ?? ""), null, + Divider(height: 1), + isFromDubai + ? inputWidget( + TranslationBase.of(context).maritalStatus, + TranslationBase.of(context).married, + null, isEnable: true, prefix: null, - removePadding: true, - isAllowRadius: false, - hasSelection: false, + hasSelection: true, + dropdownItems: MaritalStatusType.values.map((e) => context.selectedLanguage == "ar" ? e.typeAr : e.type).toList(), + selectedValue: context.selectedLanguage == "ar" ? selectedMaritalStatusType!.typeAr : selectedMaritalStatusType?.type, + selectionType: SelectionType.dropdown, + onChange: (val) { + if (val != null) { + setState(() { + selectedMaritalStatusType = MaritalStatusTypeExtension.fromType(val); + }); + } + }, isBorderAllowed: false, isAllowLeadingIcon: true, - isReadOnly: true, - leadingIcon: "assets/images/svg/smart-phone.svg", - onChange: (value) {}), - Divider(height: 1), - inputWidget(TranslationBase.of(context).nationality, (widget.nHICData.nationality ?? ""), null, + hasSelectionCustomIcon: true, + removePadding: true, + isLeadingCountry: false, + isAllowRadius: false, + padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), + selectionCustomIcon: "assets/images/svg/arrow-down.svg", + leadingIcon: 'assets/images/svg/smart-phone.svg', + ).withVerticalPadding(8) + : inputWidget(TranslationBase.of(context).maritalStatus, (widget.nHICData!.maritalStatus ?? ""), null, isEnable: true, prefix: null, removePadding: true, @@ -152,108 +224,168 @@ class _RegisterNew extends State { isBorderAllowed: false, isAllowLeadingIcon: true, isReadOnly: true, - leadingIcon: "assets/images/svg/globe.svg", + leadingIcon: "assets/images/svg/smart-phone.svg", onChange: (value) {}), - Divider(height: 1), - inputWidget(TranslationBase.of(context).mobileNumber, (widget.payload.mobileNo ?? ""), null, + Divider(height: 1), + isFromDubai + ? inputWidget( + TranslationBase.of(context).country, + TranslationBase.of(context).uae, + null, isEnable: true, prefix: null, - removePadding: true, - isAllowRadius: false, - hasSelection: false, + hasSelection: true, + dropdownItems: countriesList.map((e) => context.selectedLanguage == "ar" ? e.nameN ?? "" : e.name ?? "").toList(), + selectedValue: context.selectedLanguage == "ar" ? selectedCountry!.nameN ?? "" : selectedCountry?.name ?? "", + selectionType: SelectionType.dropdown, + onChange: (val) { + if (val != null) { + setState(() { + selectedCountry = countriesList.firstWhere((element) => element.name == val); + }); + } + }, isBorderAllowed: false, isAllowLeadingIcon: true, - isReadOnly: true, - leadingIcon: "assets/images/svg/call.svg", - onChange: (value) {}), - Divider(height: 1), - inputWidget(TranslationBase.of(context).dob, (widget.nHICData.dateOfBirth ?? ""), null, + hasSelectionCustomIcon: true, + removePadding: true, + isLeadingCountry: false, + isAllowRadius: false, + padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), + selectionCustomIcon: "assets/images/svg/arrow-down.svg", + leadingIcon: 'assets/images/svg/globe.svg', + ).withVerticalPadding(8) + : inputWidget(TranslationBase.of(context).nationality, (widget.nHICData!.nationality ?? ""), null, isEnable: true, prefix: null, - hasSelection: false, removePadding: true, + isAllowRadius: false, + hasSelection: false, isBorderAllowed: false, isAllowLeadingIcon: true, - hasSelectionCustomIcon: false, isReadOnly: true, - selectionType: SelectionType.calendar, - selectedValue: widget.payload.dob != null ? Utils.formatDateToDisplay(widget.payload.dob.toString()) : null, - selectionCustomIcon: "assets/images/svg/calendar.svg", - leadingIcon: "assets/images/svg/birthday-cake.svg", + leadingIcon: "assets/images/svg/globe.svg", onChange: (value) {}), - ], - ), + Divider(height: 1), + inputWidget(TranslationBase.of(context).mobileNumber, (widget.payload.mobileNo ?? ""), null, + isEnable: true, + prefix: null, + removePadding: true, + isAllowRadius: false, + hasSelection: false, + isBorderAllowed: false, + isAllowLeadingIcon: true, + isReadOnly: true, + leadingIcon: "assets/images/svg/call.svg", + onChange: (value) {}), + Divider(height: 1), + inputWidget(TranslationBase.of(context).dob, isFromDubai ? widget.payload.dob! : (widget.nHICData!.dateOfBirth ?? ""), null, + isEnable: true, + prefix: null, + hasSelection: false, + removePadding: true, + isBorderAllowed: false, + isAllowLeadingIcon: true, + hasSelectionCustomIcon: false, + isReadOnly: true, + selectionType: SelectionType.calendar, + selectedValue: widget.payload.dob != null ? Utils.formatDateToDisplay(widget.payload.dob.toString()) : null, + selectionCustomIcon: "assets/images/svg/calendar.svg", + leadingIcon: "assets/images/svg/birthday-cake.svg", + onChange: (value) {}), + ], + ), + ), + ), + SizedBox( + height: 50, + ), + Row( + children: [ + Expanded( + child: CustomButton( + text: TranslationBase.of(context).cancel, + icon: "assets/images/svg/cancel.svg", + onPressed: () { + Navigator.of(context).pop(); + }, + fontFamily: context.fontFamily, + backgroundColor: Color(0xFFFEE9EA), + borderColor: Color(0xFFFEE9EA), + textColor: Color(0xFFED1C2B), ), ), - SizedBox(height: 150), - Row( - children: [ - Expanded( - child: CustomButton( - text: TranslationBase.of(context).cancel, - icon: "assets/images/svg/cancel.svg", - onPressed: () { - Navigator.of(context).pop(); - }, - fontFamily: context.fontFamily, - backgroundColor: Color(0xFFFEE9EA), - borderColor: Color(0xFFFEE9EA), - textColor: Color(0xFFED1C2B), - ), - ), - SizedBox( - width: 16, - ), - Expanded( - child: CustomButton( - text: TranslationBase.of(context).confirm, - icon: "assets/images/svg/confirm.svg", - onPressed: () { - showModalBottomSheet( - context: context, - isScrollControlled: true, - isDismissible: false, - backgroundColor: Colors.transparent, - builder: (bottomSheetContext) => Padding( - padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), - child: SingleChildScrollView( - child: GenericBottomSheet( - textController: emailAddress, - isForEmail: true, - buttons: [ - Padding( - padding: const EdgeInsets.only(bottom: 10), - child: CustomButton( - text: "Submit", - onPressed: () { - if (emailAddress.text.isEmpty) { - Utils.showErrorToast("Please enter your email address."); - return; - } else { - Navigator.of(context).pop(); - registerNow(); - } - }, - backgroundColor: Colors.red, - borderColor: Colors.red, - textColor: Colors.white), - ), - ], + SizedBox( + width: 16, + ), + Expanded( + child: CustomButton( + text: TranslationBase.of(context).confirm, + icon: "assets/images/svg/confirm.svg", + onPressed: () { + if (isFromDubai) { + if (name == null) { + AppToast.showErrorToast(message: TranslationBase.of(context).enterFullName); + return; + } + if (!name!.contains(" ")) if (selectedGenderType == null) { + AppToast.showErrorToast(message: TranslationBase.of(context).enterFullName); + return; + } + if (selectedMaritalStatusType == null) { + AppToast.showErrorToast(message: TranslationBase.of(context).chooseMaritalStatus); + return; + } + if (selectedCountry == null) { + AppToast.showErrorToast(message: TranslationBase.of(context).chooseCountry); + return; + } + } + + showModalBottomSheet( + context: context, + isScrollControlled: true, + isDismissible: false, + backgroundColor: Colors.transparent, + builder: (bottomSheetContext) => Padding( + padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), + child: SingleChildScrollView( + child: GenericBottomSheet( + textController: emailAddress, + isForEmail: true, + buttons: [ + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: CustomButton( + text: TranslationBase.of(context).submiT, + onPressed: () { + if (emailAddress.text.isEmpty) { + Utils.showErrorToast(TranslationBase.of(context).enterEmailAddress); + return; + } else { + Navigator.of(context).pop(); + registerNow(); + } + }, + backgroundColor: Color(0xFFED1C2B), + borderColor: Color(0xFFED1C2B), + textColor: Colors.white), ), - ), + ], ), - ); - }, - fontFamily: context.fontFamily, - ), - ) - ], - ), - SizedBox(height: 14), + ), + ), + ); + }, + fontFamily: context.fontFamily, + ), + ) ], ), - ), - )); + ], + ), + ), + ); } Widget showProgress({String? title, String? status, Color? color, bool isNeedBorder = true}) { @@ -314,7 +446,7 @@ class _RegisterNew extends State { registerNow() { dynamic request; - if (!widget.payload.zipCode!.contains("966")) + if (isFromDubai) request = getTempUserRequestDubai(); else request = getTempUserRequest(); @@ -363,6 +495,7 @@ class _RegisterNew extends State { } }) .catchError((err) { + print(err); // GifLoaderDialogUtils.hideDialog(context); ConfirmDialog dialog = ConfirmDialog( context: context, @@ -378,39 +511,39 @@ class _RegisterNew extends State { getTempUserRequest() { DateFormat dateFormat = DateFormat("mm/dd/yyyy"); - print(dateFormat.parse(widget.nHICData.dateOfBirth!)); - var hDate = new HijriCalendar.fromDate(dateFormat.parse(widget.nHICData.dateOfBirth!)); + print(dateFormat.parse(widget.nHICData!.dateOfBirth!)); + var hDate = new HijriCalendar.fromDate(dateFormat.parse(widget.nHICData!.dateOfBirth!)); var date = hDate.toString(); return { "Patientobject": { "TempValue": true, - "PatientIdentificationType": widget.nHICData.idNumber!.substring(0, 1) == "1" ? 1 : 2, - "PatientIdentificationNo": widget.nHICData.idNumber, + "PatientIdentificationType": widget.nHICData!.idNumber!.substring(0, 1) == "1" ? 1 : 2, + "PatientIdentificationNo": widget.nHICData!.idNumber, "MobileNumber": int.parse(widget.payload.mobileNo!), "PatientOutSA": (widget.payload.zipCode == '966' || widget.payload.zipCode == '+966') ? 0 : 1, - "FirstNameN": widget.nHICData.firstNameAr, - "FirstName": widget.nHICData.firstNameEn, - "MiddleNameN": widget.nHICData.secondNameAr, - "MiddleName": widget.nHICData.secondNameEn, - "LastNameN": widget.nHICData.lastNameAr, - "LastName": widget.nHICData.lastNameEn, - "StrDateofBirth": widget.nHICData.dateOfBirth, - "DateofBirth": DateUtil.convertISODateToJsonDate(widget.nHICData.dateOfBirth!.replaceAll('/', '-')), - "Gender": widget.nHICData.gender == 'M' ? 1 : 2, - "NationalityID": widget.nHICData.nationalityCode, - "eHealthIDField": widget.nHICData.healthId, + "FirstNameN": widget.nHICData!.firstNameAr, + "FirstName": widget.nHICData!.firstNameEn, + "MiddleNameN": widget.nHICData!.secondNameAr, + "MiddleName": widget.nHICData!.secondNameEn, + "LastNameN": widget.nHICData!.lastNameAr, + "LastName": widget.nHICData!.lastNameEn, + "StrDateofBirth": widget.nHICData!.dateOfBirth, + "DateofBirth": DateUtil.convertISODateToJsonDate(widget.nHICData!.dateOfBirth!.replaceAll('/', '-')), + "Gender": widget.nHICData!.gender == 'M' ? 1 : 2, + "NationalityID": widget.nHICData!.nationalityCode, + "eHealthIDField": widget.nHICData!.healthId, "DateofBirthN": date, "EmailAddress": emailAddress.text, "SourceType": (widget.payload.zipCode == '966' || widget.payload.zipCode == '+966') ? 1 : 2, "PreferredLanguage": context.selectedLanguage == "ar" ? 1 : 2, // "OccupationID": registerInfo.occupationID, - "Marital": widget.nHICData.maritalStatusCode == 'U' + "Marital": widget.nHICData!.maritalStatusCode == 'U' ? '0' - : widget.nHICData.maritalStatusCode == 'M' + : widget.nHICData!.maritalStatusCode == 'M' ? '1' : '2', }, - "PatientIdentificationID": widget.nHICData.idNumber, + "PatientIdentificationID": widget.nHICData!.idNumber, "PatientMobileNumber": widget.payload.mobileNo.toString()[0] == '0' ? widget.payload.mobileNo : '0' + widget.payload.mobileNo.toString() }; } @@ -418,43 +551,45 @@ class _RegisterNew extends State { getTempUserRequestDubai() { DateFormat dateFormat = DateFormat("mm/dd/yyyy"); // print(dateFormat.parse(registerd_data.dob!)); - var hDate = new HijriCalendar.fromDate(dateFormat.parse(widget.nHICData.dateOfBirth!)); + var hDate = new HijriCalendar.fromDate(dateFormat.parse(widget.payload.dob!)); var date = hDate.toString(); final DateFormat dateFormat1 = DateFormat('MM/dd/yyyy'); final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); - + List names = name!.split(" "); return { "Patientobject": { "TempValue": true, - "PatientIdentificationType": widget.nHICData.idNumber!.substring(0, 1) == "1" ? "1" : "2", - "PatientIdentificationNo": widget.nHICData.idNumber, + "PatientIdentificationType": widget.payload.nationalID!.substring(0, 1) == "1" ? 1 : 2, + "PatientIdentificationNo": widget.payload.nationalID, "MobileNumber": int.parse(widget.payload.mobileNo ?? ""), "PatientOutSA": (widget.payload.zipCode == '966' || widget.payload.zipCode == '+966') ? 0 : 1, - "FirstNameN": widget.nHICData.firstNameAr ?? "", - "FirstName": widget.nHICData.firstNameEn ?? "", - "MiddleNameN": widget.nHICData.secondNameAr ?? ".", - "MiddleName": widget.nHICData.secondNameEn ?? ".", - "LastNameN": widget.nHICData.lastNameAr ?? "", - "LastName": widget.nHICData.lastNameEn ?? "", - "StrDateofBirth": dateFormat1.format(dateFormat2.parse(widget.nHICData.dateOfBirth!)), - "DateofBirth": DateUtil.convertISODateToJsonDate(widget.nHICData.dateOfBirth!.replaceAll('/', '-')), - "Gender": widget.nHICData.gender == 'M' ? 1 : 2, - "NationalityID": widget.nHICData.nationalityCode, + "FirstNameN": "...", + "FirstName": names[0], + "MiddleNameN": "...", + "MiddleName": "...", + "LastNameN": "...", + "LastName": names.length > 1 ? names[1] : "...", + "StrDateofBirth": dateFormat1.format(dateFormat2.parse(widget.payload.dob!)), + "DateofBirth": DateUtil.convertISODateToJsonDate(widget.payload.dob!.replaceAll('/', '-')), + "Gender": selectedGenderType == GenderType.male ? 1 : 2, + "NationalityID": "UAE", "eHealthIDField": null, "DateofBirthN": date, "EmailAddress": emailAddress.text, "SourceType": (widget.payload.zipCode == '966' || widget.payload.zipCode == '+966') ? 1 : 2, - "PreferredLanguage": context.selectedLanguage == "ar" ? 1 : 2, - "Marital": widget.nHICData.maritalStatusCode == 'U' + "PreferredLanguage": context.selectedLanguage == "ar" ? "1" : "2", + "Marital": selectedMaritalStatusType == MaritalStatusType.single ? '0' - : widget.nHICData.maritalStatusCode == 'M' + : selectedMaritalStatusType == MaritalStatusType.married ? '1' : '2', }, - "PatientIdentificationID": widget.nHICData.idNumber, + "PatientIdentificationID": widget.payload.nationalID, "PatientMobileNumber": widget.payload.mobileNo.toString()[0] == '0' ? widget.payload.mobileNo : '0' + widget.payload.mobileNo.toString(), - "DOB": widget.nHICData.dateOfBirth, + "DOB": widget.payload.dob, "IsHijri": widget.payload.isHijri }; } + + getName() {} } diff --git a/lib/pages/login/saved_login.dart b/lib/pages/login/saved_login.dart index bd056b9f..03a81c3c 100644 --- a/lib/pages/login/saved_login.dart +++ b/lib/pages/login/saved_login.dart @@ -22,20 +22,23 @@ import 'package:hmg_patient_app/pages/login/welcome.dart'; import 'package:hmg_patient_app/pages/rateAppointment/rate_appointment_doctor.dart'; import 'package:hmg_patient_app/services/authentication/auth_provider.dart' hide sharedPref; import 'package:hmg_patient_app/services/clinic_services/get_clinic_service.dart'; +import 'package:hmg_patient_app/theme/colors.dart'; import 'package:hmg_patient_app/uitl/app_toast.dart'; import 'package:hmg_patient_app/uitl/date_uitl.dart'; +import 'package:hmg_patient_app/uitl/font_utils.dart'; import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; import 'package:hmg_patient_app/uitl/utils.dart' hide sharedPref; +import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart'; import 'package:hmg_patient_app/widgets/otp/sms-popup.dart'; import 'package:hmg_patient_app/widgets/text/app_texts_widget.dart'; import 'package:hmg_patient_app/widgets/transitions/fade_page.dart'; import 'package:local_auth/local_auth.dart'; import 'package:provider/provider.dart'; - class SavedLogin extends StatefulWidget { final SelectDeviceIMEIRES savedLoginData; + const SavedLogin(this.savedLoginData, {Key? key}) : super(key: key); @override @@ -43,155 +46,191 @@ class SavedLogin extends StatefulWidget { } class _SavedLogin extends State { - TextEditingController get phoneController => - TextEditingController( - text: widget.savedLoginData.mobile!.startsWith('0') - ? widget.savedLoginData.mobile!.substring(1) - : widget.savedLoginData.mobile, + TextEditingController get phoneController => TextEditingController( + text: widget.savedLoginData.mobile!.startsWith('0') ? widget.savedLoginData.mobile!.substring(1) : widget.savedLoginData.mobile, ); final authService = new AuthProvider(); late ProjectViewModel projectViewModel; late ToDoCountProviderModel toDoProvider; + Country selectedCountry = Country.saudiArabia; AppointmentRateViewModel appointmentRateViewModel = locator(); + @override Widget build(BuildContext context) { - projectViewModel = Provider.of(context); toDoProvider = Provider.of(context); - return Scaffold( - backgroundColor: const Color(0xFFF8F8FA), - body: SafeArea( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 24.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Spacer(flex: 2), - // Welcome back text - const Text( - 'Welcome back', - style: TextStyle( - fontSize: 22, - color: Color(0xFF6C757D), - fontWeight: FontWeight.w400, + return AppScaffold( + appBarTitle: TranslationBase.of(context).register, + isShowDecPage: false, + isShowAppBar: true, + isshowBackButton: false, + showNewAppBar: true, + backgroundColor: Color(0xffF8F8F8), + showNewAppBarTitle: false, + showDropDown: true, + isShowLanguageChanger: true, + appBarIcons: [], + dropDownList: [], + resizeToAvoidBottomInset: true, + showCenteredLogo: true, + dropDownIndexChange: (value) { + Utils.changeAppLanguage(context: context); + }, + // backgroundColor: const Color(0xFFF8F8FA), + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Spacer(flex: 2), + // Welcome back text + Text( + TranslationBase.of(context).welcomeBack, + style: context.dynamicTextStyle( + fontSize: 22, + color: Color(0xFF898A8D), + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 16), + // Names + Column( + children: [ + Text( + widget.savedLoginData.name!.toLowerCase().capitalizeFirstofEach, + style: context.dynamicTextStyle( + fontSize: 26, + fontWeight: FontWeight.bold, + color: Color(0xFF2E3039), + height: 26 / 36, + letterSpacing: -0.4, + ), ), + // Text( + // 'Abdul Ghaffar', + // style: TextStyle( + // fontSize: 28, + // fontWeight: FontWeight.bold, + // color: Colors.grey[800], + // ), + // ), + ], + ), + const SizedBox(height: 24), + Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(color: Colors.white), + borderRadius: BorderRadius.circular(24.0), + boxShadow: [ + BoxShadow( + color: Color(0x0D000000), + blurRadius: 16, + offset: Offset(0, 0), + spreadRadius: 5, + ), + ], ), - const SizedBox(height: 16), - // Names - Column( + child: Column( children: [ + // Last login info + Text( + TranslationBase.of(context).lastloginBy + ' ${getType(widget.savedLoginData.logInType!, context)}', + style: const TextStyle( + fontSize: 16, + color: Color(0xFF8F9AA3), + fontWeight: FontWeight.w600, + ), + ), Text( - widget.savedLoginData.name!.toLowerCase().capitalizeFirstofEach, - style: TextStyle( - fontSize: 28, - fontWeight: FontWeight.bold, - color: Colors.grey[800], + widget.savedLoginData.createdOn != null ? DateUtil.getFormattedDate(DateUtil.convertStringToDate(widget.savedLoginData.createdOn!), "d MMMM, y 'at' HH:mm") : '--', + style: const TextStyle( + fontSize: 16, + color: Color(0xFF2E3039), + fontWeight: FontWeight.w600, ), ), - // Text( - // 'Abdul Ghaffar', - // style: TextStyle( - // fontSize: 28, - // fontWeight: FontWeight.bold, - // color: Colors.grey[800], - // ), - // ), + Container( + margin: EdgeInsets.all(16), + child: SvgPicture.asset( + getTypeIcons(widget.savedLoginData.logInType!, context), + color: Color(0xFFED1C2B), + height: 64, + width: 64, + ), + ), + // Face ID login button + CustomButton( + text: "${TranslationBase.of(context).loginBy} ${getType(widget.savedLoginData.logInType!, context)}", + onPressed: () { + if (widget.savedLoginData.logInType! == 2 || widget.savedLoginData.logInType! == 3) { + loginWithFingerPrintFace(widget.savedLoginData.logInType!, widget.savedLoginData.iMEI!); + } else { + int? val = widget.savedLoginData.logInType!; + checkUserAuthentication(val); + } + }, + backgroundColor: Color(0xffFEE9EA), + borderColor: Color(0xffFEE9EA), + textColor: Color(0xffED1C2B), + fontSize: 12, + fontWeight: FontWeight.w500, + borderRadius: 12, + padding: EdgeInsets.fromLTRB(0, 10, 0, 10), + // icon: "assets/images/svg/apple-finder.svg", + ), ], ), - const SizedBox(height: 24), - Container( - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - color: Colors.white, - border: Border.all(color: Colors.white), - borderRadius: BorderRadius.circular(8.0), - ), - child: Column(children: [ - - // Last login info - Text( - 'Last Login by ${getType(widget.savedLoginData!.logInType!, context)}', - style: const TextStyle( - fontSize: 14, - color: Color(0xFF6C757D), - ), - ), - Text( - widget.savedLoginData.createdOn != null ? DateUtil.getFormattedDate(DateUtil.convertStringToDate( widget.savedLoginData!.createdOn!), "d MMMM, y 'at' HH:mm") : '--', - style: const TextStyle( - fontSize: 16, - ), - ), - Container( - margin: EdgeInsets.all(16), - child: SvgPicture.asset(getTypeIcons(widget.savedLoginData!.logInType!, context), color: Colors.red, height: 54, width: 54,),), - // Face ID login button - CustomButton( - text: "${TranslationBase.of(context).loginBy} ${getType(widget.savedLoginData!.logInType!, context)}", - onPressed: (){ - if(widget.savedLoginData!.logInType! == 2 || widget.savedLoginData!.logInType! == 3) { - loginWithFingerPrintFace(widget.savedLoginData! - .logInType!, widget.savedLoginData!.iMEI!); - }else { - int? val = widget.savedLoginData! - .logInType!; - checkUserAuthentication(val); - } - }, - backgroundColor:Color(0xffFEE9EA), - borderColor:Color(0xffFEE9EA), - textColor: Color(0xffED1C2B), - fontSize: 12, - padding : EdgeInsets.fromLTRB(0, 10, 0, 10), - // icon: "assets/images/svg/apple-finder.svg", - ), - ],),), - const SizedBox(height: 24), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.0), - - child: Text( - 'OR', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500 - ), - ), + ), + const SizedBox(height: 24), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.0), + child: Text( + TranslationBase.of(context).oR, + style: context.dynamicTextStyle(fontSize: 16, fontWeight: FontWeight.w500), ), - const SizedBox(height: 24), - // OTP login button - CustomButton( - text:TranslationBase.of(context).loginByOTP, - onPressed: (){ - - showModalBottomSheet( - context: context, - isScrollControlled: true, - isDismissible: false, - backgroundColor: Colors.transparent, - builder: (bottomSheetContext) => Padding( + ), + const SizedBox(height: 24), + // OTP login button + CustomButton( + text: TranslationBase.of(context).loginByOTP, + onPressed: () { + showModalBottomSheet( + context: context, + isScrollControlled: true, + isDismissible: false, + useSafeArea: true, + backgroundColor: Colors.transparent, + builder: (bottomSheetContext) => StatefulBuilder(builder: (BuildContext context, StateSetter setModalState) { + return Padding( padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), child: SingleChildScrollView( child: GenericBottomSheet( - countryCode: "966", - initialPhoneNumber: "", - textController: phoneController!, // Assumed to be a TextEditingController + countryCode: selectedCountry.countryCode, + initialPhoneNumber: phoneController.text, + textController: phoneController, + isEnableCountryDropdown: false, + isFromSavedLogin: true, + onCountryChange: (value) { + selectedCountry = value; + setModalState(() {}); + }, buttons: [ Padding( padding: const EdgeInsets.only(bottom: 10), child: CustomButton( - text: "Send me OTP on SMS", + text: TranslationBase.of(context).sendOTPSMS, onPressed: () { - int? val = Utils.onOtpBtnPressed(OTPType.sms, phoneController); - if (val != null) { - checkUserAuthentication(val); - } + int? val = Utils.onOtpBtnPressed(OTPType.sms, phoneController); + if (val != null) checkUserAuthentication(val); }, - backgroundColor: Colors.red, - borderColor: Colors.red, + backgroundColor: CustomColors.bgRedColor, + borderColor: CustomColors.bgRedBorderColor, textColor: Colors.white, icon: "assets/images/svg/message.svg", ), @@ -202,25 +241,25 @@ class _SavedLogin extends State { children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 8), - child: AppText( - "OR", - fontSize: 16, - fontFamily: 'poppins', - color: Color(0xFF2E3039), - fontWeight: FontWeight.w500, + child: Text( + TranslationBase.of(context).oR, + style: context.dynamicTextStyle( + fontSize: 16, + color: Color(0xFF2E3039), + fontWeight: FontWeight.w500, + ), + ), ), ], ), Padding( - padding: const EdgeInsets.only(bottom: 10), + padding: const EdgeInsets.only(bottom: 10, top: 10), child: CustomButton( - text: "Send me OTP on WhatsApp", + text: TranslationBase.of(context).sendOTPWHATSAPP, onPressed: () { int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, phoneController); - if (val != null) { - checkUserAuthentication(val); - } + if (val != null) checkUserAuthentication(val); }, backgroundColor: Colors.white, borderColor: Color(0xFF2E3039), @@ -231,65 +270,59 @@ class _SavedLogin extends State { ], ), ), - ));}, - backgroundColor:Colors.white, - borderColor:Colors.black, - textColor: Colors.black, - padding : EdgeInsets.fromLTRB(0, 14, 0, 14), - // icon: "assets/images/svg/apple-finder.svg", - ), - const Spacer(flex: 2), - // OR divider - - const SizedBox(height: 24), - // Guest and Switch account - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - TextButton( - onPressed: () { Navigator.of(context).pushReplacement( + ); + }), + ); + }, + backgroundColor: Colors.white, + borderColor: Color(0xFF2E3039), + textColor: Color(0xFF2E3039), + borderWidth: 2, + padding: EdgeInsets.fromLTRB(0, 14, 0, 14), + icon: "assets/images/svg/password-validation.svg", + ), + const Spacer(flex: 2), + // OR divider + + const SizedBox(height: 24), + // Guest and Switch account + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + TextButton( + onPressed: () { + Navigator.of(context).pushReplacement( MaterialPageRoute( builder: (BuildContext context) => LandingPage(), - - ), - );}, - child: Text( - TranslationBase.of(context).guest, - style: TextStyle( - color: Color(0xFFED1C2B), - fontSize: 16, - fontWeight: FontWeight.w500, ), - ), + ); + }, + child: Text( + TranslationBase.of(context).guest, + style: context.dynamicTextStyle(color: CustomColors.bgRedColor, fontSize: 16, fontWeight: FontWeight.w500, height: 16 / 26), ), - const SizedBox(width: 24), - TextButton( - onPressed: () { - Navigator.of(context).pushReplacement( - MaterialPageRoute( - builder: (BuildContext context) => WelcomeLogin(), - - ), - ); - - }, - child: Text( - TranslationBase.of(context).switchAccount, - style: TextStyle( - color: Color(0xFFED1C2B), - fontSize: 16, - fontWeight: FontWeight.w500, + ), + const SizedBox(width: 24), + TextButton( + onPressed: () { + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) => WelcomeLogin(), ), - ), + ); + }, + child: Text( + TranslationBase.of(context).switchAccount, + style: context.dynamicTextStyle(color: CustomColors.bgRedColor, fontSize: 16, fontWeight: FontWeight.w500, height: 16 / 26), ), - ], - ), - const SizedBox(height: 20), - ], - ), + ), + ], + ), + const SizedBox(height: 20), + ], ), ), - + ), ); } @@ -306,7 +339,7 @@ class _SavedLogin extends State { //need to move this function on provider to avoid multiple repeat - loginWithFingerPrintFace(type, String deviceToken ) async { + loginWithFingerPrintFace(type, String deviceToken) async { bool authenticated = false; final LocalAuthentication auth = LocalAuthentication(); @@ -333,10 +366,9 @@ class _SavedLogin extends State { return; } - if (authenticated) { int lastLogin = 1; - var availableBiometrics = await auth.getAvailableBiometrics(); + var availableBiometrics = await auth.getAvailableBiometrics(); if (availableBiometrics.contains(BiometricType.strong)) { lastLogin = 3; // Assume Face or secure fingerprint @@ -358,11 +390,10 @@ class _SavedLogin extends State { getMobileInfo(request, lastLogin); } -} - + } - getMobileInfo(request,int lastLogin) async{ - GifLoaderDialogUtils.showMyDialog(context); + getMobileInfo(request, int lastLogin) async { + GifLoaderDialogUtils.showMyDialog(context); this.authService.getLoginInfo(request).then((result) { GifLoaderDialogUtils.hideDialog(context); if (result['SMSLoginRequired'] == false) { @@ -370,7 +401,7 @@ class _SavedLogin extends State { // this.patientOutSA = result['PatientOutSA']; // setDefault(); sharedPref.setInt(LAST_LOGIN, lastLogin); - checkActivationCode(null, lastLogin,result['LogInTokenID']); + checkActivationCode(null, lastLogin, result['LogInTokenID']); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); @@ -378,72 +409,71 @@ class _SavedLogin extends State { }); } - checkActivationCode(String? value, int loginType, String? loginToken) async { AppGlobal.context = context; GifLoaderDialogUtils.showMyDialog(context); - var request = authService.getCommonRequest( - type: loginType, - registerd_data: null, - deviceToken: widget.savedLoginData.iMEI, - mobileNumber: int.parse(widget.savedLoginData.mobile!), - zipCode: widget.savedLoginData.outSA == 1 ? '971' : '966', - patientOutSA: widget.savedLoginData.outSA, - loginTokenID: loginToken ??"", - selectedOption: loginType, - user: widget.savedLoginData, - ).toJson(); + var request = authService + .getCommonRequest( + type: loginType, + registerd_data: null, + deviceToken: widget.savedLoginData.iMEI, + mobileNumber: int.parse(widget.savedLoginData.mobile!), + zipCode: widget.savedLoginData.outSA == 1 ? '971' : '966', + patientOutSA: widget.savedLoginData.outSA, + loginTokenID: loginToken ?? "", + selectedOption: loginType, + user: widget.savedLoginData, + ) + .toJson(); dynamic res; - authService - .checkActivationCode(request, value) - .then((result) async => { - res = result, - if (result is Map) - { - result = CheckActivationCode.fromJson(result as Map), - if (result.errorCode == '699') - { - //699 block run here - GifLoaderDialogUtils.hideDialog(context), - Future.delayed(Duration(seconds: 2), () { - AppToast.showErrorToast(message: result.errorEndUserMessage); - Navigator.pop(context); - }) - } - else - { - sharedPref.remove(FAMILY_FILE), - result.list.isFamily = false, - // userData = result.list, - sharedPref.setString(BLOOD_TYPE, result.patientBloodType ?? ""), - //Remove o+ from here Added by Aamir - authenticatedUserObject.user = result.list, - projectViewModel.setPrivilege(privilegeList: res), - await sharedPref.setObject(MAIN_USER, result.list), - await sharedPref.setObject(USER_PROFILE, result.list), - // loginTokenID = result.logInTokenID, - await sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), - await sharedPref.setString(TOKEN, result.authenticationTokenID), - checkIfUserAgreedBefore(result, loginType), - projectViewModel.analytics.loginRegistration.login_successful(), - } - } - // else - // { - // // Navigator.of(context).pop(), - // GifLoaderDialogUtils.hideDialog(context), - // Future.delayed(Duration(seconds: 1), () { - // Navigator.of(context).pop(); - // AppToast.showErrorToast(message: result, localContext: context); - // startSMSService(tempType); - // }), - // - // projectViewModel.analytics.loginRegistration.login_fail(error: result), - // projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result) - // } - }); - } + authService.checkActivationCode(request, value).then((result) async => { + res = result, + if (result is Map) + { + result = CheckActivationCode.fromJson(result as Map), + if (result.errorCode == '699') + { + //699 block run here + GifLoaderDialogUtils.hideDialog(context), + Future.delayed(Duration(seconds: 2), () { + AppToast.showErrorToast(message: result.errorEndUserMessage); + Navigator.pop(context); + }) + } + else + { + sharedPref.remove(FAMILY_FILE), + result.list.isFamily = false, + // userData = result.list, + sharedPref.setString(BLOOD_TYPE, result.patientBloodType ?? ""), + //Remove o+ from here Added by Aamir + authenticatedUserObject.user = result.list, + projectViewModel.setPrivilege(privilegeList: res), + await sharedPref.setObject(MAIN_USER, result.list), + await sharedPref.setObject(USER_PROFILE, result.list), + // loginTokenID = result.logInTokenID, + await sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), + await sharedPref.setString(TOKEN, result.authenticationTokenID), + checkIfUserAgreedBefore(result, loginType), + projectViewModel.analytics.loginRegistration.login_successful(), + } + } + // else + // { + // // Navigator.of(context).pop(), + // GifLoaderDialogUtils.hideDialog(context), + // Future.delayed(Duration(seconds: 1), () { + // Navigator.of(context).pop(); + // AppToast.showErrorToast(message: result, localContext: context); + // startSMSService(tempType); + // }), + // + // projectViewModel.analytics.loginRegistration.login_fail(error: result), + // projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result) + // } + }); + } checkIfUserAgreedBefore(CheckActivationCode result, int type) { if (projectViewModel.havePrivilege(109)) { @@ -464,7 +494,7 @@ class _SavedLogin extends State { isArabic: projectViewModel.isArabic, ), ), - (r) => false); + (r) => false); }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); @@ -503,13 +533,13 @@ class _SavedLogin extends State { Navigator.pushAndRemoveUntil( context, FadePage(page: RateAppointmentDoctor()), - (route) => false, + (route) => false, ); } else { Navigator.pushAndRemoveUntil( context, FadePage(page: LandingPage()), - (route) => false, + (route) => false, ); } insertIMEI(type); @@ -531,24 +561,25 @@ class _SavedLogin extends State { }); } - insertIMEI(lastLogin) { - authService.insertDeviceImei(lastLogin).then((value) => {}).catchError((err) { print(err); }); } + checkUserAuthentication(type) { GifLoaderDialogUtils.showMyDialog(context); - var req = this.authService.getCommonRequest(type: type, - registerd_data: null, - deviceToken: widget.savedLoginData.iMEI, - mobileNumber: int.parse(widget.savedLoginData.mobile!), - zipCode: widget.savedLoginData.outSA == 1 ? '971' : '966', - patientOutSA: widget.savedLoginData.outSA, - loginTokenID: "", - selectedOption: type, - user: widget.savedLoginData,); + var req = this.authService.getCommonRequest( + type: type, + registerd_data: null, + deviceToken: widget.savedLoginData.iMEI, + mobileNumber: int.parse(widget.savedLoginData.mobile!), + zipCode: widget.savedLoginData.outSA == 1 ? '971' : '966', + patientOutSA: widget.savedLoginData.outSA, + loginTokenID: "", + selectedOption: type, + user: widget.savedLoginData, + ); var request = CheckPatientAuthenticationReq.fromJson(req.toJson()); @@ -556,29 +587,31 @@ class _SavedLogin extends State { authService .checkPatientAuthentication(request) .then((value) => { - if (value['isSMSSent']) - { - sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']), - // this.loginTokenID = value['LogInTokenID'], - sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request), - // Future.delayed(Duration(seconds: 1), () { - this.sendActivationCode(type, value['LogInTokenID']) - // }) - } - else - { - if (value['IsAuthenticated']) {this.checkActivationCode(null, type, value['LogInTokenID'])} - else { - AppToast.showErrorToast(message: value['errorMessage']), - Navigator.pushAndRemoveUntil( - context, - FadePage( - page: WelcomeLogin(), - ), - (r) => false) - } - } - }) + if (value['isSMSSent']) + { + sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']), + // this.loginTokenID = value['LogInTokenID'], + sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request), + // Future.delayed(Duration(seconds: 1), () { + this.sendActivationCode(type, value['LogInTokenID']) + // }) + } + else + { + if (value['IsAuthenticated']) + {this.checkActivationCode(null, type, value['LogInTokenID'])} + else + { + AppToast.showErrorToast(message: value['errorMessage']), + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: WelcomeLogin(), + ), + (r) => false) + } + } + }) .catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); @@ -586,29 +619,31 @@ class _SavedLogin extends State { } sendActivationCode(type, String loginToken) async { - var request = this.authService.getCommonRequest(type: type, - registerd_data: null, - deviceToken: widget.savedLoginData.iMEI, - mobileNumber: int.parse(widget.savedLoginData.mobile!), - zipCode: widget.savedLoginData.outSA == 1 ? '971' : '966', - patientOutSA: widget.savedLoginData.outSA, - loginTokenID: loginToken, - selectedOption: type, - user: widget.savedLoginData,); + var request = this.authService.getCommonRequest( + type: type, + registerd_data: null, + deviceToken: widget.savedLoginData.iMEI, + mobileNumber: int.parse(widget.savedLoginData.mobile!), + zipCode: widget.savedLoginData.outSA == 1 ? '971' : '966', + patientOutSA: widget.savedLoginData.outSA, + loginTokenID: loginToken, + selectedOption: type, + user: widget.savedLoginData, + ); request.sMSSignature = await SMSOTP.getSignature(); GifLoaderDialogUtils.showMyDialog(context); - request.dob = ""; - request.healthId = ""; - request.isHijri = 0; - await this.authService.sendActivationCode(request).then((result) { - GifLoaderDialogUtils.hideDialog(context); - if (result != null && result['isSMSSent'] == true) { - this.startSMSService(type, loginToken); - } - }).catchError((r) { - GifLoaderDialogUtils.hideDialog(context); - AppToast.showErrorToast(message: r.toString()); - }); + request.dob = ""; + request.healthId = ""; + request.isHijri = 0; + await this.authService.sendActivationCode(request).then((result) { + GifLoaderDialogUtils.hideDialog(context); + if (result != null && result['isSMSSent'] == true) { + this.startSMSService(type, loginToken); + } + }).catchError((r) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: r.toString()); + }); } var tempType; @@ -619,10 +654,10 @@ class _SavedLogin extends State { context, type, phoneController.text, - (value) { + (value) { this.checkActivationCode(value, type, loginToken); }, - () => { + () => { Navigator.pop(context), }, ).displayDialog(context); @@ -654,15 +689,15 @@ class _SavedLogin extends State { } }); } + String getTypeIcons(int type, BuildContext context) { - String path='assets/images/svg/'; + String path = 'assets/images/svg/'; final types = { - 1: path + 'sms.svg', + 1: path + 'sms.svg', 2: path + 'fingerprint.svg', - 3:path + 'apple-finder.svg', - 4: path + 'whatsapp.svg', + 3: path + 'apple-finder.svg', + 4: path + 'whatsapp.svg', }; - return types[type] ?? path +'sms.svg'; + return types[type] ?? path + 'sms.svg'; } - -} \ No newline at end of file +} diff --git a/lib/pages/login/user-login-agreement-page.dart b/lib/pages/login/user-login-agreement-page.dart index 7c8bc6a4..5044b5a8 100644 --- a/lib/pages/login/user-login-agreement-page.dart +++ b/lib/pages/login/user-login-agreement-page.dart @@ -125,7 +125,7 @@ class _UserLoginAgreementPageState extends State { ), ], ), - padding: EdgeInsets.only(left: 21, right: 21, top: 15, bottom: 15), + padding: EdgeInsets.only(left: 21, right: 21, top: 15, bottom: 50), width: double.infinity, // color: Colors.white, child: Column( @@ -174,8 +174,10 @@ class _UserLoginAgreementPageState extends State { child: CustomTextButton( backgroundColor: CustomColors.green, elevation: 0, - onPressed: isPageLoaded - ? () { + onPressed: + // isPageLoaded + // ? + () { // if (isTermsAndConditionsPage) { if (acceptTerms) { addUsageAgreement(); @@ -189,7 +191,8 @@ class _UserLoginAgreementPageState extends State { // addUsageAgreement(); // } } - : null, + // : null + , child: Text(TranslationBase.of(context).acceptLbl.toUpperCase(), style: TextStyle( fontSize: 18.0, @@ -209,8 +212,10 @@ class _UserLoginAgreementPageState extends State { child: CustomTextButton( backgroundColor: Color(0xffc5272d), elevation: 0, - onPressed: isPageLoaded - ? () { + onPressed: + // isPageLoaded + // ? + () { Navigator.pushAndRemoveUntil( context, FadePage( @@ -218,7 +223,8 @@ class _UserLoginAgreementPageState extends State { ), (r) => false); } - : null, + // : null + , child: Text(TranslationBase.of(context).declineLbl.toUpperCase(), style: TextStyle(fontSize: 18.0, color: Colors.white)), ), ), diff --git a/lib/pages/login/welcome.dart b/lib/pages/login/welcome.dart index 3522d9b8..ef448004 100644 --- a/lib/pages/login/welcome.dart +++ b/lib/pages/login/welcome.dart @@ -1,4 +1,5 @@ import 'package:flutter/gestures.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:hmg_patient_app/analytics/google-analytics.dart'; import 'package:hmg_patient_app/config/config.dart'; import 'package:hmg_patient_app/config/shared_pref_kay.dart'; @@ -21,8 +22,10 @@ import 'package:hmg_patient_app/pages/login/user-login-agreement-page.dart'; import 'package:hmg_patient_app/pages/rateAppointment/rate_appointment_doctor.dart'; import 'package:hmg_patient_app/services/authentication/auth_provider.dart'; import 'package:hmg_patient_app/services/clinic_services/get_clinic_service.dart'; +import 'package:hmg_patient_app/theme/colors.dart'; import 'package:hmg_patient_app/uitl/app_shared_preferences.dart'; import 'package:hmg_patient_app/uitl/app_toast.dart'; +import 'package:hmg_patient_app/uitl/font_utils.dart'; import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; import 'package:hmg_patient_app/uitl/utils.dart'; @@ -45,6 +48,7 @@ class _WelcomeLogin extends State { bool isLoading = true; TextEditingController nationIdController = TextEditingController(); TextEditingController phoneController = TextEditingController(); + Country selectedCountry = Country.saudiArabia; //checkUserAuthentication(); bool isDubai = false; @@ -75,9 +79,6 @@ class _WelcomeLogin extends State { bool onlySMSBox = false; var userData; - late BuildContext _context; - - late bool _loading; int fingrePrintBefore = 0; @@ -124,7 +125,10 @@ class _WelcomeLogin extends State { }, child: SingleChildScrollView( physics: ClampingScrollPhysics(), // Remove NeverScrollableScrollPhysics() - padding: EdgeInsets.only(left: 24, right: 24, ), + padding: EdgeInsets.only( + left: 24, + right: 24, + ), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -144,105 +148,112 @@ class _WelcomeLogin extends State { ), Text( TranslationBase.of(context).welcomeToDrSulaiman, - style: TextStyle( + style: context.dynamicTextStyle( fontSize: 28, - fontFamily: (projectViewModel.currentLanguage == 'ar' ? 'Cairo' : 'Poppins'), - fontWeight: FontWeight.w600, + fontWeight: FontWeight.bold, color: Color(0xff2B353E), letterSpacing: -0.4, height: 40 / 28, ), ), SizedBox(height: 32), - Directionality( - textDirection: TextDirection.ltr, - child: newInputWidget( - "National ID. or File No", - "1xxxxxxxx", - nationIdController, - isEnable: true, - removePadding: true, - prefix: null, - hasSelection: false, - isBorderAllowed: false, - isAllowLeadingIcon: true, - padding: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8), - leadingIcon: "assets/images/svg/student-card.svg", - ), + newInputWidget( + TranslationBase.of(context).idNo + " / " + TranslationBase.of(context).fileNo, + "1xxxxxxxx", + nationIdController, + isEnable: true, + removePadding: true, + prefix: null, + hasSelection: false, + isBorderAllowed: false, + isAllowLeadingIcon: true, + padding: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8), + leadingIcon: "assets/images/svg/student-card.svg", ), SizedBox(height: 16), CustomButton( text: TranslationBase.of(context).login, + // fontFamily: FontUtils.getFontFamily(context), + // padding: EdgeInsets.all(10), + // padding: , icon: "assets/images/svg/login1.svg", onPressed: () { - bool isValid = Utils.validateIqama(nationIdController.text); - if (isValid) { + // bool isValid = Utils.validateIqama(nationIdController.text); + if (true) { showModalBottomSheet( context: context, isScrollControlled: true, isDismissible: false, useSafeArea: true, backgroundColor: Colors.transparent, - builder: (bottomSheetContext) => Padding( - padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), - child: SingleChildScrollView( - child: GenericBottomSheet( - countryCode: "966", - initialPhoneNumber: "", - textController: phoneController, - buttons: [ - Padding( - padding: const EdgeInsets.only(bottom: 10), - child: CustomButton( - text: "Send me OTP on SMS", - onPressed: () { - int? val = Utils.onOtpBtnPressed(OTPType.sms, phoneController); - if (val != null) checkUserAuthentication(val); - }, - // backgroundColor: Colors.red, - // borderColor: Colors.red, - textColor: Colors.white, - icon: "assets/images/svg/message.svg", + builder: (bottomSheetContext) => StatefulBuilder(builder: (BuildContext context, StateSetter setModalState) { + return Padding( + padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), + child: SingleChildScrollView( + child: GenericBottomSheet( + countryCode: selectedCountry.countryCode, + initialPhoneNumber: "", + textController: phoneController, + isEnableCountryDropdown: true, + onCountryChange: (value) { + print(value); + selectedCountry = value; + setModalState(() {}); + }, + buttons: [ + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: CustomButton( + text: TranslationBase.of(context).sendOTPSMS, + onPressed: () { + int? val = Utils.onOtpBtnPressed(OTPType.sms, phoneController); + if (val != null) checkUserAuthentication(val); + }, + backgroundColor: CustomColors.bgRedColor, + borderColor: CustomColors.bgRedBorderColor, + textColor: Colors.white, + icon: "assets/images/svg/message.svg", + ), ), - ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), - child: AppText( - "OR", - fontSize: 16, - fontFamily: 'poppins', - color: Color(0xFF2E3039), - fontWeight: FontWeight.w500, + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: AppText( + TranslationBase.of(context).oR, + fontSize: 16, + color: Color(0xFF2E3039), + fontWeight: FontWeight.w500, + ), ), + ], + ), + Padding( + padding: const EdgeInsets.only(bottom: 10, top: 10), + child: CustomButton( + text: TranslationBase.of(context).sendOTPWHATSAPP, + onPressed: () { + int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, phoneController); + if (val != null) checkUserAuthentication(val); + }, + backgroundColor: Colors.white, + borderColor: Color(0xFF2E3039), + textColor: Color(0xFF2E3039), + icon: "assets/images/svg/whatsapp.svg", ), - ], - ), - Padding( - padding: const EdgeInsets.only(bottom: 10), - child: CustomButton( - text: "Send me OTP on WhatsApp", - onPressed: () { - int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, phoneController); - if (val != null) checkUserAuthentication(val); - }, - backgroundColor: Colors.white, - borderColor: Color(0xFF2E3039), - textColor: Color(0xFF2E3039), - icon: "assets/images/svg/whatsapp.svg", ), - ), - ], + ], + ), ), - ), - ), + ); + }), ); - } else { - Utils.showErrorToast("Please enter a valid Iqama number.", context); } + // } else { + // Utils.showErrorToast(TranslationBase.of(context).validIQama, context); + // } }, ), SizedBox(height: 14), @@ -250,27 +261,22 @@ class _WelcomeLogin extends State { child: RichText( textAlign: TextAlign.center, text: TextSpan( - style: TextStyle( + + style: context.dynamicTextStyle( color: Colors.black, fontSize: 16, height: 26 / 16, - fontFamily: context.fontFamily, fontWeight: FontWeight.w500, ), children: [ - TextSpan( - text: TranslationBase.of(context).dontHaveAccount, - style: TextStyle( - fontFamily: context.fontFamily, - )), + TextSpan(text: TranslationBase.of(context).dontHaveAccount, style: context.dynamicTextStyle()), TextSpan(text: " "), TextSpan( text: TranslationBase.of(context).registerNow, - style: TextStyle( - color: Colors.red, + style: context.dynamicTextStyle( + color: CustomColors.bgRedColor, fontSize: 16, height: 26 / 16, - fontFamily: context.fontFamily, fontWeight: FontWeight.w500, ), recognizer: TapGestureRecognizer() @@ -550,7 +556,7 @@ class _WelcomeLogin extends State { request.projectOutSA = this.patientOutSA == true ? true : false; request.loginType = type == 1 ? type : 2; request.oTPSendType = type == 1 ? type : 2; //this.selectedOption == 1 ? 1 : 2; - request.zipCode = "966"; + request.zipCode = selectedCountry.countryCode; request.logInTokenID = this.loginTokenID ?? ""; diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 1a5da8ab..b6c09d13 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -413,23 +413,21 @@ class AuthProvider with ChangeNotifier { RegisterUserRequest requestN = RegisterUserRequest(patientobject: Patientobject.fromJson(request["Patientobject"])); // var requestN = RegisterUserRequest.fromJson(request); requestN.patientOutSA = requestN.patientobject!.patientOutSa!; - + final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); + final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); if (nhic != null) { // requestN.dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); // requestN.isHijri = nhic['IsHijri'] ? 1 : 0; // requestN.healthId = requestN.patientobject!.eHealthIDField!; // } - final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); - final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); - requestN.dob = nhic['IsHijri'] ? requestN.patientobject!.dateofBirth :dateFormat2.format(dateFormat.parse(requestN.patientobject!.strDateofBirth!)); - requestN.isHijri = nhic['IsHijri'] ? 1 : 0; requestN.healthId = requestN.patientobject!.eHealthIdField; - requestN.patientIdentificationID = requestN.patientobject!.patientIdentificationNo; - requestN.patientMobileNumber = requestN.patientobject!.mobileNumber.toString(); - requestN.logInTokenID = await sharedPref.getString(LOGIN_TOKEN_ID); } - + requestN.dob =requestN.isHijri ==1 ? requestN.patientobject!.dateofBirth :dateFormat2.format(dateFormat.parse(requestN.patientobject!.strDateofBirth!)); + requestN.isHijri =requestN.isHijri; + requestN.patientIdentificationID = requestN.patientobject!.patientIdentificationNo; + requestN.patientMobileNumber = requestN.patientobject!.mobileNumber.toString(); + requestN.logInTokenID = await sharedPref.getString(LOGIN_TOKEN_ID); requestN.zipCode = requestN.patientOutSA == 1 ? '971' : '966'; await sharedPref.remove(USER_PROFILE); @@ -1995,7 +1993,7 @@ class AuthProvider with ChangeNotifier { request.isRegister = registerd_data.isRegister; } else { request.searchType = request.searchType != null ? request.searchType : 2; - request.patientID = user!.patientID != null ? user!.patientID : 0; + request.patientID = user.patientID != null ? user.patientID : 0; request.nationalID = request.nationalID != null ? request.nationalID : '0'; request.patientIdentificationID = request.patientIdentificationID != null ? request.patientIdentificationID : '0'; request.isRegister = false; diff --git a/lib/theme/colors.dart b/lib/theme/colors.dart index a9d4e437..8fd52a1b 100644 --- a/lib/theme/colors.dart +++ b/lib/theme/colors.dart @@ -25,4 +25,14 @@ class CustomColors { static const Color femaleColor = Color(0xFF359846); static const Color maleColor = Color(0xFFCC9B14); + + + + // New UI Colors + static const Color bgRedColor = Color(0xFFED1C2B); + static const Color bgRedBorderColor = Color(0xFFED1C2B); + + + + } diff --git a/lib/theme/theme_value.dart b/lib/theme/theme_value.dart index 3d45b6cb..6302079a 100644 --- a/lib/theme/theme_value.dart +++ b/lib/theme/theme_value.dart @@ -1,4 +1,3 @@ - import 'package:hmg_patient_app/Constants.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -12,8 +11,11 @@ final blueAccent = Color(0xFFFF9800); final blueBackground = Color(0xFFFFFFFF); defaultTheme({fontName}) { + // Use Poppins as default fallback + final defaultFontFamily = fontName ?? 'Poppins'; + return ThemeData( - fontFamily: fontName, + fontFamily: defaultFontFamily, useMaterial3: false, //projectProvider.isArabic ? 'Cairo' : 'WorkSans', primarySwatch: Colors.red, @@ -40,10 +42,11 @@ defaultTheme({fontName}) { // primaryTextTheme: TextTheme(bodyText2: TextStyle(color: Colors.white)), iconTheme: IconThemeData(), textTheme: TextTheme( - // bodyText1: TextStyle(color: Colors.black, letterSpacing: 0.6), - // headline1: TextStyle(color: Colors.white, letterSpacing: 0.6), - // headline2: TextStyle(color: Colors.white, letterSpacing: 0.6), - ), + // Apply font family to all text styles + ).apply(fontFamily: defaultFontFamily), + primaryTextTheme: TextTheme( + // Apply font family to primary text theme as well + ).apply(fontFamily: defaultFontFamily), floatingActionButtonTheme: FloatingActionButtonThemeData(highlightElevation: 2, disabledElevation: 0, elevation: 2), appBarTheme: AppBarTheme( diff --git a/lib/uitl/font_utils.dart b/lib/uitl/font_utils.dart new file mode 100644 index 00000000..f9c1e29c --- /dev/null +++ b/lib/uitl/font_utils.dart @@ -0,0 +1,148 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:provider/provider.dart'; +import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; + +/// Font utility class to manage consistent font selection across the app +class FontUtils { + /// Get the appropriate font family based on the current language + static bool getFontFamily(BuildContext context) { + final projectViewModel = Provider.of(context, listen: false); + return projectViewModel.isArabic ? true : false; + } + + /// Get the appropriate font family for a specific language + static String getFontFamilyForLanguage(bool isArabic) { + return isArabic ? 'Cairo' : 'Poppins'; + } +} + +extension DynamicTextStyleExtension on BuildContext { + TextStyle dynamicTextStyle( + {double? fontSize, + FontWeight? fontWeight, + Color? color, + double? letterSpacing, + double? wordSpacing, + double? height, + List? shadows, + Color? backgroundColor, + TextDecoration? decoration, + Color? decorationColor, + TextDecorationStyle? decorationStyle, + double? decorationThickness, + Locale? locale, + TextBaseline? textBaseline, + FontStyle? fontStyle, + bool isLanguageSwitcher = false}) { + final family = FontUtils.getFontFamily(this); + + return isLanguageSwitcher + ? (family + ? GoogleFonts.poppins( + fontSize: fontSize, + fontWeight: fontWeight, + color: color, + letterSpacing: letterSpacing, + wordSpacing: wordSpacing, + height: height, + shadows: shadows, + backgroundColor: backgroundColor, + decoration: decoration, + decorationColor: decorationColor, + decorationStyle: decorationStyle, + decorationThickness: decorationThickness, + locale: locale ?? Localizations.localeOf(this), + textBaseline: textBaseline, + fontStyle: fontStyle, + ) + : GoogleFonts.cairo( + fontSize: fontSize, + fontWeight: fontWeight, + color: color, + letterSpacing: letterSpacing, + wordSpacing: wordSpacing, + height: height, + shadows: shadows, + backgroundColor: backgroundColor, + decoration: decoration, + decorationColor: decorationColor, + decorationStyle: decorationStyle, + decorationThickness: decorationThickness, + locale: locale ?? Localizations.localeOf(this), + textBaseline: textBaseline, + fontStyle: fontStyle, + )) + : (family + ? GoogleFonts.cairo( + fontSize: fontSize, + fontWeight: fontWeight, + color: color, + letterSpacing: letterSpacing, + wordSpacing: wordSpacing, + height: height, + shadows: shadows, + backgroundColor: backgroundColor, + decoration: decoration, + decorationColor: decorationColor, + decorationStyle: decorationStyle, + decorationThickness: decorationThickness, + locale: locale ?? Localizations.localeOf(this), + textBaseline: textBaseline, + fontStyle: fontStyle, + ) + : GoogleFonts.poppins( + fontSize: fontSize, + fontWeight: fontWeight, + color: color, + letterSpacing: letterSpacing, + wordSpacing: wordSpacing, + height: height, + shadows: shadows, + backgroundColor: backgroundColor, + decoration: decoration, + decorationColor: decorationColor, + decorationStyle: decorationStyle, + decorationThickness: decorationThickness, + locale: locale ?? Localizations.localeOf(this), + textBaseline: textBaseline, + fontStyle: fontStyle, + )); + + // return family + // ? GoogleFonts.cairo( + // fontSize: fontSize, + // fontWeight: fontWeight, + // color: color, + // letterSpacing: letterSpacing, + // wordSpacing: wordSpacing, + // height: height, + // shadows: shadows, + // backgroundColor: backgroundColor, + // decoration: decoration, + // decorationColor: decorationColor, + // decorationStyle: decorationStyle, + // decorationThickness: decorationThickness, + // locale: locale ?? Localizations.localeOf(this), + // textBaseline: textBaseline, + // fontStyle: fontStyle, + // ) + // : GoogleFonts.poppins( + // fontSize: fontSize, + // fontWeight: fontWeight, + // color: color, + // letterSpacing: letterSpacing, + // wordSpacing: wordSpacing, + // height: height, + // shadows: shadows, + // backgroundColor: backgroundColor, + // decoration: decoration, + // decorationColor: decorationColor, + // decorationStyle: decorationStyle, + // decorationThickness: decorationThickness, + // locale: locale ?? Localizations.localeOf(this), + // textBaseline: textBaseline, + // fontStyle: fontStyle, + // ); + } +} diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index f1f2d17b..0a25d042 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -3487,6 +3487,28 @@ class TranslationBase { String get enableQuickLogin => localizedValues["enableQuickLogin"][locale.languageCode]; String get enableMsg => localizedValues["enableMsg"][locale.languageCode]; String get notNow => localizedValues["notNow"][locale.languageCode]; + String get fullName => localizedValues["fullName"][locale.languageCode]; + String get personalDetailsVerificaion => localizedValues["personalDetailsVerificaion"][locale.languageCode]; + String get married => localizedValues["married"][locale.languageCode]; + String get uae => localizedValues["uae"][locale.languageCode]; + String get enterFullName => localizedValues["enterFullName"][locale.languageCode]; + String get chooseMaritalStatus => localizedValues["chooseMaritalStatus"][locale.languageCode]; + String get chooseCountry => localizedValues["chooseCountry"][locale.languageCode]; + String get enterEmailAddress => localizedValues["enterEmailAddress"][locale.languageCode]; + String get sendOTPSMS => localizedValues["sendOTPSMS"][locale.languageCode]; + String get sendOTPWHATSAPP => localizedValues["sendOTPWHATSAPP"][locale.languageCode]; + String get validIQama => localizedValues["validIQama"][locale.languageCode]; + String get oR => localizedValues["oR"][locale.languageCode]; + String get pleaseEnterNationalId => localizedValues["pleaseEnterNationalId"][locale.languageCode]; + String get pleaseSelectCountry => localizedValues["pleaseSelectCountry"][locale.languageCode]; + String get pleaseSelectDOB => localizedValues["pleaseSelectDOB"][locale.languageCode]; + String get pleaseAcceptTermsConditions => localizedValues["pleaseAcceptTermsConditions"][locale.languageCode]; + String get lastloginBy => localizedValues["lastLoginBy"][locale.languageCode]; + String get enterPhoneNumber => localizedValues["enterPhoneNumber"][locale.languageCode]; + String get enterEmailDesc => localizedValues["enterEmailDesc"][locale.languageCode]; + String get enterPhoneDesc => localizedValues["enterPhoneDesc"][locale.languageCode]; + String get otpVerfication => localizedValues["otpVerification"][locale.languageCode]; + String get submiT => localizedValues["submiT"][locale.languageCode]; } diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 4c02da3e..754caf40 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -72,6 +72,11 @@ enum Country { saudiArabia, unitedArabEmirates } enum SelectionType { dropdown, calendar } +enum GenderType { male, female } + +enum MaritalStatusType { single, married, divorced, widowed } + + class Utils { static int? onOtpBtnPressed(OTPType type, TextEditingController controller) { if (controller.text.isEmpty) { @@ -1236,8 +1241,10 @@ extension CountryExtension on Country { static Country fromDisplayName(String name) { switch (name) { case "Kingdom Of Saudi Arabia": + case "المملكة العربية السعودية": return Country.saudiArabia; case "United Arab Emirates": + case "الإمارات العربية المتحدة": return Country.unitedArabEmirates; default: throw Exception("Invalid country name"); @@ -1262,6 +1269,110 @@ extension SelectedLanguageExtension on BuildContext { double getLottieScaledHeight(double value) => MediaQuery.of(this).size.height * (value / MediaQuery.of(this).size.height); } +extension GenderTypeExtension on GenderType { + String get value => this == GenderType.male ? "M" : "F"; + String get type => this == GenderType.male ? "Male" : "Female"; + String get typeAr => this == GenderType.male ? "ذكر" : "أنثى"; + static GenderType? fromValue(String? value) { + switch (value) { + case "M": + return GenderType.male; + case "F": + return GenderType.female; + default: + return null; + } + } + + static GenderType? fromType(String? type) { + switch (type) { + case "Male": + return GenderType.male; + case "Female": + return GenderType.female; + default: + return null; + } + } + +} + + + +extension MaritalStatusTypeExtension on MaritalStatusType { + String get value { + switch (this) { + case MaritalStatusType.single: + return "U"; + case MaritalStatusType.married: + return "M"; + case MaritalStatusType.divorced: + return "D"; + case MaritalStatusType.widowed: + return "W"; + } + } + + String get type { + switch (this) { + case MaritalStatusType.single: + return "Single"; + case MaritalStatusType.married: + return "Married"; + case MaritalStatusType.divorced: + return "Divorced"; + case MaritalStatusType.widowed: + return "Widowed"; + } + } + + String get typeAr { + switch (this) { + case MaritalStatusType.single: + return "أعزب"; + case MaritalStatusType.married: + return "متزوج"; + case MaritalStatusType.divorced: + return "مطلق"; + case MaritalStatusType.widowed: + return "أرمل"; + } + } + + static MaritalStatusType? fromValue(String? value) { + switch (value) { + case "U": + return MaritalStatusType.single; + case "M": + return MaritalStatusType.married; + case "D": + return MaritalStatusType.divorced; + case "W": + return MaritalStatusType.widowed; + default: + return null; + } + } + + + static MaritalStatusType? fromType(String? type) { + switch (type) { + case "Single": + return MaritalStatusType.single; + case "Married": + return MaritalStatusType.married; + case "Divorced": + return MaritalStatusType.divorced; + case "Widowed": + return MaritalStatusType.widowed; + default: + return null; + } + } +} + + + /* userBoard.asMap().map((i, element) => MapEntry(i, Stack( GestureDetector(onTap: () { diff --git a/lib/widgets/drawer/langauge_picker.dart b/lib/widgets/drawer/langauge_picker.dart index b4cc024b..5de2d546 100644 --- a/lib/widgets/drawer/langauge_picker.dart +++ b/lib/widgets/drawer/langauge_picker.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:hmg_patient_app/uitl/font_utils.dart'; class LanguageSelector extends StatefulWidget { final String currentLanguage; @@ -50,13 +51,13 @@ class _LanguageSelectorState extends State { const SizedBox(width: 6), Text( currentLangData['name']?.toUpperCase() ?? 'EN', - style: TextStyle( + style: context.dynamicTextStyle( fontWeight: FontWeight.w500, - // fontFamily: 'GESSTwo', - fontFamily: (widget.currentLanguage == 'ar' ? 'Cairo' : 'Poppins'), fontSize: 14, color: const Color(0xFFED1C2B), - letterSpacing: 0.1), + letterSpacing: 0.1, + isLanguageSwitcher: true, + ), ), ], ), diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index ce0e2abd..d3478112 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -1,6 +1,7 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:badges/badges.dart' as badge_import; import 'package:barcode_scan2/barcode_scan2.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:hmg_patient_app/config/config.dart'; import 'package:hmg_patient_app/config/shared_pref_kay.dart'; import 'package:hmg_patient_app/core/model/ImagesInfo.dart'; @@ -87,58 +88,60 @@ class AppScaffold extends StatefulWidget { final Widget? customAppBar; final bool isShowLanguageChanger; final bool resizeToAvoidBottomInset; + final bool showCenteredLogo; AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; return this; } - AppScaffold( - {required this.body, - this.appBarTitle = '', - this.isLoading = false, - this.isShowAppBar = false, - this.showNewAppBar = false, - this.showNewAppBarTitle = false, - this.isMainPharmacyPages = false, - this.extendBody = false, - this.hasAppBarParam, - this.bottomSheet, - this.bottomNavigationBar, - this.baseViewModel, - this.floatingActionButton, - this.isPharmacy = false, - this.showPharmacyCart = true, - this.isOfferPackages = false, - this.showDropDown = false, - this.showOfferPackagesCart = false, - this.title, - this.description, - this.isShowDecPage = true, - this.isBottomBar = false, - this.backgroundColor, - this.preferredSize = 0.0, - this.appBarIcons, - this.infoList, - this.isHelp = false, - this.icon, - this.showHomeAppBarIcon = true, - this.imagesInfo, - this.dropDownList, - this.dropdownIndexValue, - this.dropDownIndexChange, - this.onTap, - appBar, - this.customAppBar, - this.isLocalLoader = false, - this.isshowBackButton = true, - this.backButtonTab, - this.changeCurrentTab, - this.currentTab, - this.isShowPharmacyAppbar = false, - this.isShowLanguageChanger = false, - this.resizeToAvoidBottomInset = false - }); + AppScaffold({ + required this.body, + this.appBarTitle = '', + this.isLoading = false, + this.isShowAppBar = false, + this.showNewAppBar = false, + this.showNewAppBarTitle = false, + this.isMainPharmacyPages = false, + this.extendBody = false, + this.hasAppBarParam, + this.bottomSheet, + this.bottomNavigationBar, + this.baseViewModel, + this.floatingActionButton, + this.isPharmacy = false, + this.showPharmacyCart = true, + this.isOfferPackages = false, + this.showDropDown = false, + this.showOfferPackagesCart = false, + this.title, + this.description, + this.isShowDecPage = true, + this.isBottomBar = false, + this.backgroundColor, + this.preferredSize = 0.0, + this.appBarIcons, + this.infoList, + this.isHelp = false, + this.icon, + this.showHomeAppBarIcon = true, + this.imagesInfo, + this.dropDownList, + this.dropdownIndexValue, + this.dropDownIndexChange, + this.onTap, + appBar, + this.customAppBar, + this.isLocalLoader = false, + this.isshowBackButton = true, + this.backButtonTab, + this.changeCurrentTab, + this.currentTab, + this.isShowPharmacyAppbar = false, + this.isShowLanguageChanger = false, + this.resizeToAvoidBottomInset = false, + this.showCenteredLogo = false, + }); @override _AppScaffoldState createState() => _AppScaffoldState(); @@ -228,7 +231,7 @@ class _AppScaffoldState extends State { return Scaffold( backgroundColor: widget.backgroundColor ?? CustomColors.appBackgroudGrey2Color, -resizeToAvoidBottomInset: widget.resizeToAvoidBottomInset, + resizeToAvoidBottomInset: widget.resizeToAvoidBottomInset, // appBar: widget.isShowPharmacyAppbar // ? pharmacyAppbar() // : widget.isShowAppBar @@ -251,6 +254,7 @@ resizeToAvoidBottomInset: widget.resizeToAvoidBottomInset, isShowBackButton: widget.isshowBackButton, dropDownIndexChange: widget.dropDownIndexChange, appBarIcons: widget.appBarIcons, + showCenterLogo: widget.showCenteredLogo, isShowLanguageChanger: widget.isShowLanguageChanger, onTap: () { widget.onTap; @@ -356,6 +360,7 @@ class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget { final void Function(int?)? dropDownIndexChange; final List? appBarIcons; final bool isShowLanguageChanger; + final bool showCenterLogo; String currentLang = 'ar'; @@ -372,7 +377,8 @@ class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget { this.dropDownIndexChange, this.onTap, this.isShowBackButton = true, - this.isShowLanguageChanger = false}) + this.isShowLanguageChanger = false, + this.showCenterLogo = false}) : super(key: key); @override @@ -389,12 +395,14 @@ class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget { onTap: onTap, ) : null, + // centerTitle: showCenterLogo, titleSpacing: -8, // centerTitle: false, title: Row( crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + if (showCenterLogo) SvgPicture.asset('assets/images/svg/habiblogo.svg', height: 32, width: 32).withHorizontalPadding(25), if (showTitle) Expanded( child: Text( @@ -443,7 +451,7 @@ class NewAppBarWidget extends StatelessWidget implements PreferredSizeWidget { ), if (showDropDown! && isShowLanguageChanger) Padding( - padding: EdgeInsets.symmetric(horizontal: 24), + padding: EdgeInsets.symmetric(horizontal: 25), child: Directionality( textDirection: TextDirection.ltr, child: LanguageSelector( @@ -545,7 +553,7 @@ class AppBarWidgetState extends State { // ), title: Text(widget.authenticatedUserObject.isLogin || !widget.isShowDecPage ? widget.appBarTitle!.toUpperCase() : TranslationBase.of(context).serviceInformationTitle, // style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).textTheme.headline1!.color, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), - style: TextStyle(fontWeight: FontWeight.bold, color: CustomColors.white, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), + style: TextStyle(fontWeight: FontWeight.bold, color: CustomColors.white, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins')), leading: widget.isshowBackButton ? Builder( builder: (BuildContext context) { diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 590fc073..9dff5c51 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:hmg_patient_app/config/size_config.dart'; import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; import 'package:hmg_patient_app/theme/colors.dart'; +import 'package:hmg_patient_app/uitl/font_utils.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; import 'package:hmg_patient_app/uitl/utils.dart'; import 'package:hmg_patient_app/uitl/whatsapp_method_channel.dart'; @@ -101,7 +102,7 @@ class SMSOTP { } return AppScaffold( - appBarTitle: "OTP Verification", + appBarTitle: TranslationBase.of(context).otpVerfication, isShowDecPage: false, isShowAppBar: true, isshowBackButton: true, @@ -125,7 +126,7 @@ class SMSOTP { SizedBox(height: 22), Text( TranslationBase.of(context).pleaseEnterTheVerificationCode + ' xxxxxxxx' + mobileNo.toString().substring(mobileNo.toString().length - 3), - style: TextStyle( + style: context.dynamicTextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), @@ -151,7 +152,6 @@ class SMSOTP { pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition, pinTextAnimatedSwitcherDuration: Duration(milliseconds: 300), pinBoxRadius: 18, - keyboardType: TextInputType.number, ), ), @@ -160,7 +160,7 @@ class SMSOTP { RichText( text: TextSpan( text: TranslationBase.of(context).validationMessage + '\n', - style: TextStyle( + style: context.dynamicTextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), @@ -169,7 +169,7 @@ class SMSOTP { children: [ TextSpan( text: displayTime, - style: TextStyle( + style: context.dynamicTextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xffD02127), diff --git a/lib/widgets/text/app_texts_widget.dart b/lib/widgets/text/app_texts_widget.dart index 05180e47..47405ebf 100644 --- a/lib/widgets/text/app_texts_widget.dart +++ b/lib/widgets/text/app_texts_widget.dart @@ -1,6 +1,7 @@ import 'package:hmg_patient_app/config/size_config.dart'; import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; import 'package:hmg_patient_app/theme/colors.dart'; +import 'package:hmg_patient_app/uitl/font_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -61,21 +62,23 @@ class _AppTextState extends State { widget.data, textAlign: widget.textAlign, overflow: TextOverflow.clip, - - style: TextStyle( + style: context.dynamicTextStyle( color: widget.color == null ? CustomColors.black : widget.color, fontWeight: widget.fontWeight, fontSize: widget.fontSize ?? (SizeConfig.textMultiplier! * 2), height: widget.height, - fontFamily: "Poppins", + // fontFamily: widget.fontFamily ?? Theme.of(context).textTheme.bodyLarge?.fontFamily, letterSpacing: widget.letterSpacing, - // fontFamily: widget.fontFamily == null - // ? projectViewModel.isArabic - // ? 'Cairo' - // : 'WorkSans' - // : widget.fontFamily, - decoration: widget.underline == true ? TextDecoration.underline : TextDecoration.none - ), + decoration: widget.underline == true ? TextDecoration.underline : TextDecoration.none), + // style: TextStyle( + // color: widget.color == null ? CustomColors.black : widget.color, + // fontWeight: widget.fontWeight, + // fontSize: widget.fontSize ?? (SizeConfig.textMultiplier! * 2), + // height: widget.height, + // fontFamily: widget.fontFamily ?? Theme.of(context).textTheme.bodyLarge?.fontFamily, + // letterSpacing: widget.letterSpacing, + // decoration: widget.underline == true ? TextDecoration.underline : TextDecoration.none + // ), ), ), ); diff --git a/pubspec.yaml b/pubspec.yaml index f4f16275..94981682 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -63,8 +63,9 @@ dependencies: url: https://github.com/crasowas/hms-flutter-plugin.git path: flutter-hms-push # huawei_push: ^6.12.0+303 - hijri_gregorian_calendar: - path: /Users/aamir/StudioProjects/hijri_gregorian_calendar +# hijri_gregorian_calendar: +# path: /Users/aamir/StudioProjects/hijri_gregorian_calendar + hijri_gregorian_calendar: ^0.0.3 # Qr code Scanner location: ^8.0.1 @@ -134,6 +135,7 @@ dependencies: cloudflare_turnstile: ^3.2.0 device_info_plus: ^11.5.0 lottie: ^3.3.1 + google_fonts: ^6.2.1 google_maps_place_picker_mb_v2: ^1.0.1 # vital_sign_camera: