diff --git a/android/app/build.gradle b/android/app/build.gradle index d0cb39c8..3c1e3442 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -27,10 +27,6 @@ android { versionCode = flutter.versionCode versionName = flutter.versionName multiDexEnabled true - - ndk { - abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' - } } buildFeatures { @@ -75,12 +71,16 @@ android { } packagingOptions { jniLibs { - pickFirsts += ['**/libc++_shared.so', '**/libzoom_util.so', '**/libzoom_video_sdk.so', '**/libzoom_annotation.so', '**/libzoom_videoeffects.so'] + pickFirsts += ['lib/x86/libc++_shared.so', 'lib/x86_64/libc++_shared.so', 'lib/armeabi-v7a/libc++_shared.so', 'lib/arm64-v8a/libc++_shared.so', '**/*.so'] useLegacyPackaging true } resources { excludes += ['META-INF/proguard/androidx-annotations.pro'] } + pickFirst '**/libzoom_util.so' + pickFirst '**/libzoom_video_sdk.so' + pickFirst '**/libzoom_annotation.so' + pickFirst '**/libzoom_videoeffects.so' } // Enable core library desugaring diff --git a/assets/json/countriesList.json b/assets/json/countriesList.json new file mode 100644 index 00000000..25a65b30 --- /dev/null +++ b/assets/json/countriesList.json @@ -0,0 +1,1212 @@ +[ + { + "ID": "AFG", + "Name": "Afghan", + "NameN": "أفغاني" + }, + { + "ID": "CAF", + "Name": "African", + "NameN": "أفريقي" + }, + { + "ID": "ALB", + "Name": "Albanian", + "NameN": "ألباني" + }, + { + "ID": "DZA", + "Name": "Algerian", + "NameN": "جزائري" + }, + { + "ID": "USA", + "Name": "American", + "NameN": "أمريكي" + }, + { + "ID": "UMI", + "Name": "American (Minor Outlying Islands)", + "NameN": "أمريكي (الجزر الصغرى النائية)" + }, + { + "ID": "ASM", + "Name": "American Samoa", + "NameN": "ساموا الأمريكية" + }, + { + "ID": "AND", + "Name": "Andorrian", + "NameN": "أندوري" + }, + { + "ID": "AGO", + "Name": "Angolan", + "NameN": "أنغولي" + }, + { + "ID": "AIA", + "Name": "Anguillan", + "NameN": "أنغيلي" + }, + { + "ID": "ATA", + "Name": "Antarctica", + "NameN": "أنتاركتيكا" + }, + { + "ID": "ATG", + "Name": "Antiguans, Barbudans", + "NameN": "أنتيغوي، باربودي" + }, + { + "ID": "ARG", + "Name": "Argentine", + "NameN": "أرجنتيني" + }, + { + "ID": "ARM", + "Name": "Armenian", + "NameN": "أرمني" + }, + { + "ID": "ABW", + "Name": "Arubian", + "NameN": "أروبي" + }, + { + "ID": "AUS", + "Name": "Australian", + "NameN": "أسترالي" + }, + { + "ID": "AUT", + "Name": "Austrian", + "NameN": "نمساوي" + }, + { + "ID": "AZE", + "Name": "Azeri", + "NameN": "أذربيجاني" + }, + { + "ID": "BHS", + "Name": "Bahamian", + "NameN": "باهامي" + }, + { + "ID": "BHR", + "Name": "Bahraini", + "NameN": "بحريني" + }, + { + "ID": "BRB", + "Name": "Barbadian or Bajuns", + "NameN": "باربادوسي" + }, + { + "ID": "BLR", + "Name": "Belarusian", + "NameN": "بيلاروسي" + }, + { + "ID": "BEL", + "Name": "Belgian", + "NameN": "بلجيكي" + }, + { + "ID": "BLZ", + "Name": "Belizean", + "NameN": "بليزي" + }, + { + "ID": "BGD", + "Name": "Bengali", + "NameN": "بنغلاديشي" + }, + { + "ID": "BEN", + "Name": "Beninese", + "NameN": "بنيني" + }, + { + "ID": "BMU", + "Name": "Bermudian", + "NameN": "برمودي" + }, + { + "ID": "BTN", + "Name": "Bhutanese", + "NameN": "بوتاني" + }, + { + "ID": "BOL", + "Name": "Bolivian", + "NameN": "بوليفي" + }, + { + "ID": "BIH", + "Name": "Bosnian And Herzegovinian", + "NameN": "بوسني وهرسكي" + }, + { + "ID": "BWA", + "Name": "Botswanian", + "NameN": "بوتسواني" + }, + { + "ID": "BVT", + "Name": "Bouvet Island (Bouvetoya)", + "NameN": "جزيرة بوفيه" + }, + { + "ID": "BRA", + "Name": "Brazilian", + "NameN": "برازيلي" + }, + { + "ID": "GBR", + "Name": "British", + "NameN": "بريطاني" + }, + { + "ID": "IOT", + "Name": "British (Chagos Archipelago)", + "NameN": "بريطاني (أرخبيل شاغوس)" + }, + { + "ID": "VGB", + "Name": "British (Virgin Islands)", + "NameN": "بريطاني (الجزر العذراء)" + }, + { + "ID": "BRN", + "Name": "Bruneian", + "NameN": "بروني" + }, + { + "ID": "BGR", + "Name": "Bulgarian", + "NameN": "بلغاري" + }, + { + "ID": "MMR", + "Name": "Burmese or Myanmarese", + "NameN": "بورمي أو ميانماري" + }, + { + "ID": "BFA", + "Name": "Burnikabe", + "NameN": "بوركيني" + }, + { + "ID": "BDI", + "Name": "Burundi", + "NameN": "بوروندي" + }, + { + "ID": "KHM", + "Name": "Cambodian", + "NameN": "كمبودي" + }, + { + "ID": "CMR", + "Name": "Cameroonian", + "NameN": "كاميروني" + }, + { + "ID": "CAN", + "Name": "Canadian", + "NameN": "كندي" + }, + { + "ID": "CPV", + "Name": "Cape Verdian or Cape Verdean", + "NameN": "رأس أخضري" + }, + { + "ID": "CYM", + "Name": "Cayman Islander", + "NameN": "جزر كايماني" + }, + { + "ID": "TCD", + "Name": "Chadian", + "NameN": "تشادي" + }, + { + "ID": "CHL", + "Name": "Chilean", + "NameN": "تشيلي" + }, + { + "ID": "HKG", + "Name": "Chinese (Hong Kong)", + "NameN": "صيني (هونغ كونغ)" + }, + { + "ID": "MAC", + "Name": "Chinese (Macao)", + "NameN": "صيني (ماكاو)" + }, + { + "ID": "CHN", + "Name": "Chinese", + "NameN": "صيني" + }, + { + "ID": "CXR", + "Name": "Christmas Island", + "NameN": "جزيرة الكريسماس" + }, + { + "ID": "CCK", + "Name": "Cocos (Keeling) Islands", + "NameN": "جزر كوكوس (كيلنغ)" + }, + { + "ID": "COL", + "Name": "Colombian", + "NameN": "كولومبي" + }, + { + "ID": "COM", + "Name": "Comoran", + "NameN": "قمري" + }, + { + "ID": "COG", + "Name": "Congolese", + "NameN": "كونغولي" + }, + { + "ID": "COD", + "Name": "Congolese (Zaire)", + "NameN": "كونغولي (زائير)" + }, + { + "ID": "COK", + "Name": "Cook Islander", + "NameN": "جزر كوك" + }, + { + "ID": "CRI", + "Name": "Costa Rican", + "NameN": "كوستاريكي" + }, + { + "ID": "HRV", + "Name": "Croat", + "NameN": "كرواتي" + }, + { + "ID": "CUB", + "Name": "Cuban", + "NameN": "كوبي" + }, + { + "ID": "CYP", + "Name": "Cypriot, Greek", + "NameN": "قبرصي، يوناني" + }, + { + "ID": "CZE", + "Name": "Czech", + "NameN": "تشيكي" + }, + { + "ID": "DNK", + "Name": "Danish", + "NameN": "دنماركي" + }, + { + "ID": "DJI", + "Name": "Djibouti", + "NameN": "جيبوتي" + }, + { + "ID": "DOM", + "Name": "Dominican", + "NameN": "دومينيكاني" + }, + { + "ID": "DMA", + "Name": "Dominican (Commonwealth)", + "NameN": "دومينيكي (الكومنولث)" + }, + { + "ID": "ANT", + "Name": "Dutch (Antilles)", + "NameN": "هولندي (الأنتيل)" + }, + { + "ID": "NLD", + "Name": "Dutch (Netherlands)", + "NameN": "هولندي (هولندا)" + }, + { + "ID": "ECU", + "Name": "Ecuadorean", + "NameN": "إكوادوري" + }, + { + "ID": "EGY", + "Name": "Egyptians", + "NameN": "مصري" + }, + { + "ID": "ARE", + "Name": "Emirati", + "NameN": "إماراتي" + }, + { + "ID": "GNQ", + "Name": "Equatorial Guinean or Equatoguinean", + "NameN": "غيني استوائي" + }, + { + "ID": "ERI", + "Name": "Eritrean", + "NameN": "إريتري" + }, + { + "ID": "EST", + "Name": "Estonian", + "NameN": "إستوني" + }, + { + "ID": "ETH", + "Name": "Ethiopian", + "NameN": "إثيوبي" + }, + { + "ID": "FRO", + "Name": "Faeroe Islander", + "NameN": "جزر فارو" + }, + { + "ID": "FLK", + "Name": "Falkland Islander", + "NameN": "جزر فوكلاند" + }, + { + "ID": "FJI", + "Name": "Fijian", + "NameN": "فيجي" + }, + { + "ID": "PHL", + "Name": "Filipino", + "NameN": "فلبيني" + }, + { + "ID": "FIN", + "Name": "Finnish", + "NameN": "فنلندي" + }, + { + "ID": "FRA", + "Name": "French", + "NameN": "فرنسي" + }, + { + "ID": "GUF", + "Name": "French Guianian", + "NameN": "غويانا الفرنسية" + }, + { + "ID": "PYF", + "Name": "French Polynesian", + "NameN": "بولينيزيا الفرنسية" + }, + { + "ID": "ATF", + "Name": "French Southern Territories", + "NameN": "الأقاليم الجنوبية الفرنسية" + }, + { + "ID": "GAB", + "Name": "Gabonese", + "NameN": "غابوني" + }, + { + "ID": "GMB", + "Name": "Gambian", + "NameN": "غامبي" + }, + { + "ID": "GEO", + "Name": "Georgian", + "NameN": "جورجي" + }, + { + "ID": "SGS", + "Name": "Georgian (South)", + "NameN": "جورجي (جنوبي)" + }, + { + "ID": "DEU", + "Name": "German", + "NameN": "ألماني" + }, + { + "ID": "GHA", + "Name": "Ghanaian", + "NameN": "غاني" + }, + { + "ID": "GIB", + "Name": "Gibraltarian", + "NameN": "جبل طارقي" + }, + { + "ID": "GRC", + "Name": "Greek", + "NameN": "يوناني" + }, + { + "ID": "GRL", + "Name": "Greenlander", + "NameN": "غرينلاندي" + }, + { + "ID": "GRD", + "Name": "Grenadian or Grenadan", + "NameN": "غرينادي" + }, + { + "ID": "GLP", + "Name": "Guadeloupian", + "NameN": "غوادلوبي" + }, + { + "ID": "GUM", + "Name": "Guamanian", + "NameN": "غوامي" + }, + { + "ID": "GTM", + "Name": "Guatemalan", + "NameN": "غواتيمالي" + }, + { + "ID": "GNB", + "Name": "Guinea-Bissauan", + "NameN": "غيني بيساوي" + }, + { + "ID": "GIN", + "Name": "Guinean", + "NameN": "غيني" + }, + { + "ID": "GUY", + "Name": "Guyanese", + "NameN": "غيانيزي" + }, + { + "ID": "HTI", + "Name": "Haitian", + "NameN": "هايتيني" + }, + { + "ID": "HMD", + "Name": "Heard and McDonald Islands", + "NameN": "جزر هيرد وماكدونالد" + }, + { + "ID": "HND", + "Name": "Honduran", + "NameN": "هندوراسي" + }, + { + "ID": "HUN", + "Name": "Hungarian", + "NameN": "مجري" + }, + { + "ID": "ISL", + "Name": "Icelander", + "NameN": "آيسلندي" + }, + { + "ID": "KIR", + "Name": "I-Kiribati", + "NameN": "كيريباتي" + }, + { + "ID": "IND", + "Name": "Indian", + "NameN": "هندي" + }, + { + "ID": "IDN", + "Name": "Indonesian", + "NameN": "إندونيسي" + }, + { + "ID": "IRN", + "Name": "Iranian", + "NameN": "إيراني" + }, + { + "ID": "IRQ", + "Name": "Iraqi", + "NameN": "عراقي" + }, + { + "ID": "IRL", + "Name": "Irish", + "NameN": "إيرلندي" + }, + { + "ID": "ITA", + "Name": "Italian", + "NameN": "إيطالي" + }, + { + "ID": "CIV", + "Name": "Ivoirian", + "NameN": "إيفواري" + }, + { + "ID": "JAM", + "Name": "Jamaican", + "NameN": "جامايكي" + }, + { + "ID": "JPN", + "Name": "Japanese", + "NameN": "ياباني" + }, + { + "ID": "JOR", + "Name": "Jordanian", + "NameN": "أردني" + }, + { + "ID": "KAZ", + "Name": "Kazakhstani", + "NameN": "كازاخستاني" + }, + { + "ID": "KEN", + "Name": "Kenyan", + "NameN": "كيني" + }, + { + "ID": "KGZ", + "Name": "Kirghiz", + "NameN": "قيرغيزي" + }, + { + "ID": "KOR", + "Name": "Korean", + "NameN": "كوري" + }, + { + "ID": "PRK", + "Name": "Korean", + "NameN": "كوري" + }, + { + "ID": "KWT", + "Name": "Kuwaiti", + "NameN": "كويتي" + }, + { + "ID": "LAO", + "Name": "Laotian", + "NameN": "لاوسي" + }, + { + "ID": "LVA", + "Name": "Latvian", + "NameN": "لاتفي" + }, + { + "ID": "LBN", + "Name": "Lebanese", + "NameN": "لبناني" + }, + { + "ID": "LBR", + "Name": "Liberian", + "NameN": "ليبيري" + }, + { + "ID": "LBY", + "Name": "Libyan", + "NameN": "ليبي" + }, + { + "ID": "LIE", + "Name": "Liechtensteiner", + "NameN": "ليختنشتايني" + }, + { + "ID": "LTU", + "Name": "Lithuanian", + "NameN": "ليتواني" + }, + { + "ID": "LUX", + "Name": "Luxembourger", + "NameN": "لوكسمبورغي" + }, + { + "ID": "MKD", + "Name": "Macedonia, the former Yugoslav Republic of", + "NameN": "مقدوني، جمهورية يوغوسلافيا السابقة" + }, + { + "ID": "MYT", + "Name": "Mahorais", + "NameN": "مايوتي" + }, + { + "ID": "MDG", + "Name": "Malagasy", + "NameN": "مدغشقري" + }, + { + "ID": "MWI", + "Name": "Malawian", + "NameN": "مالاوي" + }, + { + "ID": "MYS", + "Name": "Malaysian", + "NameN": "ماليزي" + }, + { + "ID": "MDV", + "Name": "Maldivan", + "NameN": "مالديفي" + }, + { + "ID": "MLI", + "Name": "Malian", + "NameN": "مالي" + }, + { + "ID": "MLT", + "Name": "Maltese", + "NameN": "مالطي" + }, + { + "ID": "MHL", + "Name": "Marshallese", + "NameN": "مارشالي" + }, + { + "ID": "MTQ", + "Name": "Martiniquais", + "NameN": "مارتينيكي" + }, + { + "ID": "MRT", + "Name": "Mauritanian", + "NameN": "موريتاني" + }, + { + "ID": "MUS", + "Name": "Mauritian", + "NameN": "موريشيوسي" + }, + { + "ID": "MEX", + "Name": "Mexican", + "NameN": "مكسيكي" + }, + { + "ID": "FSM", + "Name": "Micronesian", + "NameN": "ميكرونيزي" + }, + { + "ID": "MDA", + "Name": "Moldovian", + "NameN": "مولدوفي" + }, + { + "ID": "MCO", + "Name": "Monegasque or Monacan", + "NameN": "موناكي" + }, + { + "ID": "MNG", + "Name": "Mongolian", + "NameN": "منغولي" + }, + { + "ID": "MNE", + "Name": "Montenegrin", + "NameN": "جبل أسودي" + }, + { + "ID": "MSR", + "Name": "Montserratian", + "NameN": "مونتسيراتي" + }, + { + "ID": "MAR", + "Name": "Moroccan", + "NameN": "مغربي" + }, + { + "ID": "LSO", + "Name": "Mosotho", + "NameN": "ليسوتي" + }, + { + "ID": "MOZ", + "Name": "Mozambican", + "NameN": "موزمبيقي" + }, + { + "ID": "NAM", + "Name": "Namibian", + "NameN": "ناميبي" + }, + { + "ID": "NRU", + "Name": "Nauruan", + "NameN": "ناوروي" + }, + { + "ID": "NPL", + "Name": "Nepalese", + "NameN": "نيبالي" + }, + { + "ID": "NCL", + "Name": "New Caledonian", + "NameN": "كاليدوني جديد" + }, + { + "ID": "NZL", + "Name": "New Zealand", + "NameN": "نيوزيلندي" + }, + { + "ID": "VUT", + "Name": "Ni- Vanuatu", + "NameN": "فانواتي" + }, + { + "ID": "NIC", + "Name": "Nicaraguan", + "NameN": "نيكاراغوي" + }, + { + "ID": "NGA", + "Name": "Nigerian", + "NameN": "نيجيري" + }, + { + "ID": "NER", + "Name": "Nigerien", + "NameN": "نيجري" + }, + { + "ID": "NIU", + "Name": "Niuean", + "NameN": "نيوي" + }, + { + "ID": "VAT", + "Name": "None (Vatican City)", + "NameN": "لا شيء (مدينة الفاتيكان)" + }, + { + "ID": "NFK", + "Name": "Norfolk Islander", + "NameN": "جزيرة نورفولك" + }, + { + "ID": "MNP", + "Name": "Northern Mariana Islander", + "NameN": "جزر ماريانا الشمالية" + }, + { + "ID": "NOR", + "Name": "Norwegean", + "NameN": "نرويجي" + }, + { + "ID": "OMN", + "Name": "Omani", + "NameN": "عماني" + }, + { + "ID": "OTH", + "Name": "OTHERS", + "NameN": "آخرون" + }, + { + "ID": "PAK", + "Name": "Pakistani", + "NameN": "باكستاني" + }, + { + "ID": "PLW", + "Name": "Palauan", + "NameN": "بالاوي" + }, + { + "ID": "PSE", + "Name": "Palestinian", + "NameN": "فلسطيني" + }, + { + "ID": "PAN", + "Name": "Panamanian", + "NameN": "بنمي" + }, + { + "ID": "PNG", + "Name": "Papua New Guinean", + "NameN": "بابوا غيني جديد" + }, + { + "ID": "PRY", + "Name": "Paraguayan", + "NameN": "باراغوايي" + }, + { + "ID": "PER", + "Name": "Peruvian", + "NameN": "بيروفي" + }, + { + "ID": "PCN", + "Name": "Pitcairn Islander", + "NameN": "جزر بيتكايرن" + }, + { + "ID": "POL", + "Name": "Polish", + "NameN": "بولندي" + }, + { + "ID": "PRT", + "Name": "Portuguese", + "NameN": "برتغالي" + }, + { + "ID": "PRI", + "Name": "Puerto Rican", + "NameN": "بورتوريكي" + }, + { + "ID": "QAT", + "Name": "Qatari", + "NameN": "قطري" + }, + { + "ID": "RKS", + "Name": "Republic of Kosovo", + "NameN": "جمهورية كوسوفو" + }, + { + "ID": "REU", + "Name": "Reunionese", + "NameN": "ريونيوني" + }, + { + "ID": "ROU", + "Name": "Romanian", + "NameN": "روماني" + }, + { + "ID": "RUS", + "Name": "Russian", + "NameN": "روسي" + }, + { + "ID": "RWA", + "Name": "Rwandan", + "NameN": "رواندي" + }, + { + "ID": "ESH", + "Name": "Sahrawi", + "NameN": "صحراوي" + }, + { + "ID": "SLV", + "Name": "Salvadoran", + "NameN": "سلفادوري" + }, + { + "ID": "SMR", + "Name": "Sammarinese", + "NameN": "سان مارينو" + }, + { + "ID": "WSM", + "Name": "Samoan", + "NameN": "ساموي" + }, + { + "ID": "STP", + "Name": "Sao Tomean", + "NameN": "ساو تومي" + }, + { + "ID": "SAU", + "Name": "Saudi", + "NameN": "سعودي" + }, + { + "ID": "SCT", + "Name": "Scottish", + "NameN": "اسكتلندي" + }, + { + "ID": "SEN", + "Name": "Senegalese", + "NameN": "سنغالي" + }, + { + "ID": "SRB", + "Name": "Serbian", + "NameN": "صربي" + }, + { + "ID": "SYC", + "Name": "Seychellois", + "NameN": "سيشيلي" + }, + { + "ID": "SLE", + "Name": "Sierra Leonean", + "NameN": "سيراليوني" + }, + { + "ID": "SGP", + "Name": "Singaporian", + "NameN": "سنغافوري" + }, + { + "ID": "SVK", + "Name": "Slovak", + "NameN": "سلوفاكي" + }, + { + "ID": "SVN", + "Name": "Slovene", + "NameN": "سلوفيني" + }, + { + "ID": "SLB", + "Name": "Solomon Islander", + "NameN": "جزر سليمان" + }, + { + "ID": "SOM", + "Name": "Somalian", + "NameN": "صومالي" + }, + { + "ID": "ZAF", + "Name": "South African", + "NameN": "جنوب أفريقي" + }, + { + "ID": "ESP", + "Name": "Spanish", + "NameN": "إسباني" + }, + { + "ID": "LKA", + "Name": "Sri Lankan", + "NameN": "سريلانكي" + }, + { + "ID": "SHN", + "Name": "St. Helena", + "NameN": "سانت هيلينا" + }, + { + "ID": "KNA", + "Name": "St. Kitts and Nevis", + "NameN": "سانت كيتس ونيفيس" + }, + { + "ID": "LCA", + "Name": "St. Lucia", + "NameN": "سانت لوسيا" + }, + { + "ID": "SPM", + "Name": "St. Pierre and Miquelon", + "NameN": "سانت بيير وميكيلون" + }, + { + "ID": "VCT", + "Name": "St. Vincent and the Grenadines", + "NameN": "سانت فنسنت والغرينادين" + }, + { + "ID": "SDN", + "Name": "Sudanese", + "NameN": "سوداني" + }, + { + "ID": "SUR", + "Name": "Surinamer", + "NameN": "سورينامي" + }, + { + "ID": "SJM", + "Name": "Svalbard and Jan Mayen islander", + "NameN": "سفالبارد وجان ماين" + }, + { + "ID": "SWZ", + "Name": "Swazi", + "NameN": "سوازي" + }, + { + "ID": "SWE", + "Name": "Swedish", + "NameN": "سويدي" + }, + { + "ID": "CHE", + "Name": "Swiss", + "NameN": "سويسري" + }, + { + "ID": "SYR", + "Name": "Syrian", + "NameN": "سوري" + }, + { + "ID": "TWN", + "Name": "Taiwan, Province of China", + "NameN": "تايوان، مقاطعة الصين" + }, + { + "ID": "TJK", + "Name": "Tajik", + "NameN": "طاجيكي" + }, + { + "ID": "TZA", + "Name": "Tanzania, United Republic o", + "NameN": "تنزاني، الجمهورية المتحدة" + }, + { + "ID": "THA", + "Name": "Thai", + "NameN": "تايلندي" + }, + { + "ID": "TLS", + "Name": "Timorese", + "NameN": "تيموري" + }, + { + "ID": "TGO", + "Name": "Togolese", + "NameN": "توغولي" + }, + { + "ID": "TKL", + "Name": "Tokelauan", + "NameN": "توكيلاوي" + }, + { + "ID": "TON", + "Name": "Tongan", + "NameN": "تونغي" + }, + { + "ID": "TTO", + "Name": "Trinidadian", + "NameN": "ترينيدادي" + }, + { + "ID": "TUN", + "Name": "Tunisian", + "NameN": "تونسي" + }, + { + "ID": "TCA", + "Name": "Turk", + "NameN": "تركي" + }, + { + "ID": "TUR", + "Name": "Turkish", + "NameN": "تركي" + }, + { + "ID": "TKM", + "Name": "Turkmen", + "NameN": "تركماني" + }, + { + "ID": "TUV", + "Name": "Tuvaluan", + "NameN": "توفالوي" + }, + { + "ID": "UGA", + "Name": "Ugandan", + "NameN": "أوغندي" + }, + { + "ID": "UKR", + "Name": "Ukrainian", + "NameN": "أوكراني" + }, + { + "ID": "URY", + "Name": "Uruguayan", + "NameN": "أوروغوايي" + }, + { + "ID": "UZB", + "Name": "Uzbek", + "NameN": "أوزبكي" + }, + { + "ID": "VEN", + "Name": "Venenzuelan", + "NameN": "فنزويلي" + }, + { + "ID": "VNM", + "Name": "Vietnamese", + "NameN": "فيتنامي" + }, + { + "ID": "VIR", + "Name": "Virgin Islander", + "NameN": "جزر عذراء" + }, + { + "ID": "WLF", + "Name": "Wallis and Futuna Islander", + "NameN": "واليس وفوتونا" + }, + { + "ID": "YEM", + "Name": "Yemeni", + "NameN": "يمني" + }, + { + "ID": "ZMB", + "Name": "Zambian", + "NameN": "زامبي" + }, + { + "ID": "ZWE", + "Name": "Zimbabwean", + "NameN": "زيمبابوي" + } +] \ No newline at end of file diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 777f93b3..a4d89d0e 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -2329,7 +2329,7 @@ const Map localizedValues = { "clickPrivacyPolicy": {"en": "Please click here to view the privacy policy", "ar": "الرجاء الضغط هنا لعرض سياسة الخصوصية"}, "welcomeToDrSulaiman": {"en": "Welcome to Dr. Sulaiman Al Habib Medical Group", "ar": "مرحباً بكم في مجموعة الدكتور سليمان الحبيب الطبية"}, "dontHaveAccount": {"en": "Don’t have an account?", "ar": "ليس لديك حساب؟"}, - "loginByOTP": {"en": "Login By OTP", "ar":"تسجيل الدخول باستخدام OTP"}, + "loginByOTP": {"en": "Login By SMS", "ar":" تسجيل الدخول بواسطة الرسائل القصيرة"}, "loginBy": {"en": "Login By", "ar":"تسجيل الدخول بواسطة"}, "prepareToElevate": {"en": "Prepared to elevate your health and well-being?", "ar": "هل أنت مستعد لتحسين صحتك ورفاهتك؟"}, "alreadyHaveAccount": {"en": "Already have an account?", "ar": "هل لديك حساب بالفعل؟"}, @@ -2355,7 +2355,7 @@ const Map localizedValues = { "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":"الرجاء الموافقة على الشروط والأحكام"}, + "pleaseAcceptTermsConditions": {"en": "Please accept 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":"أدخل عنوان بريدك الإلكتروني لإكمال عملية إنشاء ملف طبي"}, diff --git a/lib/core/viewModels/auth_provider_view_model.dart b/lib/core/viewModels/auth_provider_view_model.dart new file mode 100644 index 00000000..73f747d4 --- /dev/null +++ b/lib/core/viewModels/auth_provider_view_model.dart @@ -0,0 +1,484 @@ +// import 'package:flutter/material.dart'; +// import 'package:hmg_patient_app/config/config.dart'; +// import 'package:hmg_patient_app/core/enum/viewstate.dart'; +// import 'package:hmg_patient_app/core/service/AuthenticatedUserObject.dart'; +// import 'package:hmg_patient_app/core/viewModels/appointment_rate_view_model.dart'; +// import 'package:hmg_patient_app/core/viewModels/base_view_model.dart'; +// import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; +// import 'package:hmg_patient_app/locator.dart'; +// import 'package:hmg_patient_app/models/Authentication/check_activation_code_response.dart'; +// import 'package:hmg_patient_app/models/Authentication/check_paitent_authentication_req.dart'; +// import 'package:hmg_patient_app/models/Authentication/select_device_imei_res.dart'; +// import 'package:hmg_patient_app/models/Authentication/send_activation_request.dart'; +// import 'package:hmg_patient_app/services/authentication/auth_provider.dart'; +// import 'package:hmg_patient_app/uitl/app_shared_preferences.dart'; +// import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart'; +// import 'package:hmg_patient_app/uitl/utils.dart'; +// import 'package:hmg_patient_app/config/shared_pref_kay.dart'; +// import 'package:hmg_patient_app/pages/landing/landing_page.dart'; +// import 'package:hmg_patient_app/widgets/transitions/fade_page.dart'; +// import 'package:hmg_patient_app/new_ui/otp/otp_validation_bootmsheet_widget.dart'; +// import 'package:hmg_patient_app/theme/colors.dart'; +// import 'package:hmg_patient_app/widgets/text/app_texts_widget.dart'; +// import 'package:intl/src/intl/date_format.dart'; +// import '../../models/Appointments/toDoCountProviderModel.dart'; +// import '../../models/InPatientServices/get_admission_info_response_model.dart'; +// import '../../models/InPatientServices/get_admission_request_info_response_model.dart'; +// import '../../pages/login/register_new.dart'; +// import '../../pages/login/user-login-agreement-page.dart'; +// import '../../pages/login/welcome.dart'; +// import '../../pages/rateAppointment/rate_appointment_doctor.dart'; +// import '../../services/clinic_services/get_clinic_service.dart'; +// import '../../uitl/app_toast.dart'; +// import '../../uitl/translations_delegate_base.dart'; +// import '../../widgets/dialogs/confirm_dialog.dart'; +// import '../../widgets/otp/sms-popup.dart'; +// +import 'base_view_model.dart'; + +class AuthProviderViewModel extends BaseViewModel { +// bool isLoading = true; +// TextEditingController nationIdController = TextEditingController(); +// TextEditingController? phoneController = TextEditingController(); +// String? phoneNumber; +// Country selectedCountry = Country.saudiArabia; +// bool isDubai = false; +// final authService = AuthProvider(); +// var sharedPref = AppSharedPreferences(); +// bool authenticated = false; +// late int mobileNumber; +// String errorMsg = ''; +// SelectDeviceIMEIRES? userDetails; +// var registerd_data; +// bool isMoreOption = false; +// var zipCode; +// var patientOutSA; +// var loginTokenID; +// var loginType; +// var deviceToken; +// var lastLogin; +// AuthenticatedUserObject authenticatedUserObject = locator(); +// AppointmentRateViewModel appointmentRateViewModel = locator(); +// ProjectViewModel projectViewModel = locator(); +// ToDoCountProviderModel toDoProvider = locator(); +// late int selectedOption; +// bool onlySMSBox = false; +// var userData; +// int fingrePrintBefore = 0; +// var dob; +// late int isHijri; +// var healthId; +// +// checkUserAuthentication(type, context) { +// GifLoaderDialogUtils.showMyDialog(context); +// var req = getCommonRequest(type: type); +// req.logInTokenID = ""; +// var request = CheckPatientAuthenticationReq.fromJson(req.toJson()); +// sharedPref.setObject(REGISTER_DATA_FOR_REGISTER, request); +// authService +// .checkPatientAuthentication(request) +// .then((value) => { +// if (value['isSMSSent']) +// { +// sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']), +// loginTokenID = value['LogInTokenID'], +// sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request), +// sendActivationCode(type, context) +// } +// else +// { +// if (value['IsAuthenticated']) {checkActivationCode(value: null, context: context)} +// } +// }) +// .catchError((err) { +// print(err); +// GifLoaderDialogUtils.hideDialog(context); +// ConfirmDialog dialog = ConfirmDialog( +// context: context, +// confirmMessage: err, +// okText: TranslationBase.of(context).confirm, +// cancelText: TranslationBase.of(context).cancel_nocaps, +// okFunction: () => { +// ConfirmDialog.closeAlertDialog(context), +// Navigator.of(context).push(FadePage(page: RegisterNew())), +// }, +// cancelFunction: () => {}); +// dialog.showAlertDialog(context); +// projectViewModel.analytics.loginRegistration.login_fail(error: err.toString()); +// }); +// } +// +// sendActivationCode(type, context) async { +// var request = getCommonRequest(type: type); +// 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.healthId = healthId; +// request.isHijri = isHijri; +// await authService.sendActivationCodeRegister(request).then((result) { +// // GifLoaderDialogUtils.hideDialog(context); +// if (result != null && result['isSMSSent'] == true) { +// startSMSService(type, context); +// } +// }).catchError((r) { +// GifLoaderDialogUtils.hideDialog(context); +// AppToast.showErrorToast(message: r); +// }); +// } else { +// request.dob = ""; +// request.healthId = ""; +// request.isHijri = 0; +// await authService.sendActivationCode(request).then((result) { +// GifLoaderDialogUtils.hideDialog(context); +// if (result != null && result['isSMSSent'] == true) { +// startSMSService(type, context); +// } +// }).catchError((r) { +// GifLoaderDialogUtils.hideDialog(context); +// AppToast.showErrorToast(message: r.toString()); +// }); +// } +// } +// +// checkActivationCode({value, context}) async { +// // Navigator.pop(context); +// GifLoaderDialogUtils.showMyDialog(context!); +// var request = getCommonRequest().toJson(); +// dynamic res; +// if (healthId != null || isDubai) { +// if (isDubai) { +// request['DOB'] = dob; +// } +// request['HealthId'] = healthId; +// request['IsHijri'] = isHijri; +// +// authService +// .checkActivationCodeRegister(request, value) +// .then((result) => { +// res = result, +// if (result is Map) +// { +// result = CheckActivationCode.fromJson(result as Map), +// if (registerd_data != null && registerd_data.isRegister == true) +// { +// // if(widget.isDubai ==false){ +// // widget.changePageViewIndex!(1), +// // if(widget.isDubai ==false){ +// +// Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), +// } +// } +// else +// { +// Navigator.of(context).pop(), +// GifLoaderDialogUtils.hideDialog(context), +// Future.delayed(Duration(seconds: 1), () { +// AppToast.showErrorToast(message: result); +// }), +// // projectViewModel.analytics.loginRegistration.login_fail(error: result), +// // projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result), +// } +// }) +// .catchError((err) { +// print(err); +// GifLoaderDialogUtils.hideDialog(context); +// Future.delayed(Duration(seconds: 1), () { +// AppToast.showErrorToast(message: err); +// // startSMSService(tempType); +// }); +// }); +// } else { +// 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.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin)); +// }) +// } +// else if (registerd_data != null && registerd_data.isRegister == true) +// { +// // widget.changePageViewIndex!(1), +// Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), +// } +// else +// { +// sharedPref.remove(FAMILY_FILE), +// result.list.isFamily = false, +// projectViewModel.user = userData = result.list, +// sharedPref.setString(BLOOD_TYPE, result.patientBloodType ?? ""), +// 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, context), +// 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, context); +// }), +// +// // projectViewModel.analytics.loginRegistration.login_fail(error: result), +// // projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result) +// } +// }) +// .catchError((err) { +// GifLoaderDialogUtils.hideDialog(context); +// Future.delayed(Duration(seconds: 1), () { +// print(err); +// AppToast.showErrorToast(message: err); +// // startSMSService(tempType); +// }); +// }); +// } +// } +// +// var tempType; +// +// startSMSService(type, context) { +// tempType = type; +// late SMSOTP smsOtp; // Declare the variable first +// +// smsOtp = SMSOTP( +// context, +// type, +// phoneNumber, +// (code) { +// smsOtp.dispose(); // Now we can reference it +// checkActivationCode(value: code, context: context); +// }, +// () { +// smsOtp.dispose(); // Now we can reference it +// Navigator.pop(context); +// }, +// ); +// smsOtp.displayDialog(context); +// } +// +// setDefault(context) async { +// // showLoader(true); +// if (await sharedPref.getObject(IMEI_USER_DATA) != null) userData = SelectDeviceIMEIRES.fromJson(await sharedPref.getObject(IMEI_USER_DATA)); +// +// if (await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN) != null) { +// isMoreOption = true; +// registerd_data = await CheckPatientAuthenticationReq.fromJson(await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); +// } +// +// mobileNumber = registerd_data != null ? registerd_data.patientMobileNumber : int.parse(userData.mobile!); +// zipCode = registerd_data != null +// ? registerd_data.zipCode +// : userData.outSA == true +// ? "971" +// : "966"; +// patientOutSA = registerd_data != null +// ? registerd_data.zipCode == "966" +// ? 0 +// : 1 +// : userData.outSA; +// if (registerd_data != null) { +// loginTokenID = await sharedPref.getString(LOGIN_TOKEN_ID); +// loginType = registerd_data.searchType; +// } +// var nhic = await sharedPref.getObject(NHIC_DATA); +// if (nhic != null) { +// final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); +// final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); +// dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); +// +// isHijri = nhic['IsHijri'] ? 1 : 0; +// healthId = nhic['HealthId']; +// } +// deviceToken = await sharedPref.getString(PUSH_TOKEN); +// lastLogin = await sharedPref.getInt(LAST_LOGIN) != null +// ? await sharedPref.getInt(LAST_LOGIN) +// : userData != null +// ? userData!.logInType +// : null; +// +// // showLoader(false); +// GifLoaderDialogUtils.hideDialog(context); +// //cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN); +// } +// +// getCommonRequest({type}) { +// bool fileNo = false; +// if (nationIdController.text != null && nationIdController.text.isNotEmpty) { +// fileNo = nationIdController.text.length < 10; +// } +// +// var request = SendActivationRequest(); +// request.patientMobileNumber = int.parse(phoneNumber!); +// request.mobileNo = '0' + phoneNumber.toString(); +// request.deviceToken = deviceToken; +// request.projectOutSA = patientOutSA == true ? true : false; +// request.loginType = type == 1 ? type : 2; +// request.oTPSendType = type == 1 ? type : 2; //selectedOption == 1 ? 1 : 2; +// request.zipCode = selectedCountry.countryCode; +// +// request.logInTokenID = loginTokenID ?? ""; +// +// if (registerd_data != null) { +// request.searchType = registerd_data.searchType != null ? registerd_data.searchType : 1; +// request.patientID = registerd_data.patientID != null ? registerd_data.patientID : 0; +// request.patientIdentificationID = request.nationalID = registerd_data.patientIdentificationID != null ? registerd_data.patientIdentificationID : '0'; +// request.dob = registerd_data.dob; +// request.isRegister = registerd_data.isRegister; +// } else { +// // request.searchType = request.searchType != null ? request.searchType : 1; +// if (fileNo) { +// request.patientID = userData != null && userData!.patientID != null ? userData!.patientID : int.parse(nationIdController.text); +// request.patientIdentificationID = request.nationalID = ""; +// request.searchType = 2; +// } else { +// request.patientID = 0; +// request.searchType = 1; +// request.patientIdentificationID = request.nationalID = nationIdController != null ? nationIdController.text : '0'; +// } +// request.isRegister = false; +// } +// request.deviceTypeID = request.searchType; +// return request; +// } +// +// insertIMEI() { +// authService.insertDeviceImei(selectedOption).then((value) => {}).catchError((err) { +// print(err); +// }); +// } +// +// void checkIfIsInPatient(context) { +// final service = ClinicListService(); +// service.checkIfInPatientAPI(context).then((res) { +// if (res['MessageStatus'] != 1) return; +// +// final isAdmitted = res['isAdmitted'] == true; +// final hasAdmissionRequest = res['hasAdmissionRequests'] == true; +// +// print("IS ADMITTED: $isAdmitted"); +// print("Has Admission Request: $hasAdmissionRequest"); +// +// if (isAdmitted && res['PatientAdmittedInformation']?.isNotEmpty == true) { +// final info = GetAdmissionInfoResponseModel.fromJson(res['PatientAdmittedInformation'][0]); +// projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']); +// projectViewModel.setInPatientAdmissionInfo(info); +// projectViewModel.setIsPatientAdmitted(true); +// } +// +// if (hasAdmissionRequest && res['MedicalInstruction']?.isNotEmpty == true) { +// final reqInfo = GetAdmissionRequestInfoResponseModel.fromJson(res['MedicalInstruction'][0]); +// projectViewModel.setInPatientProjectID(res['MedicalInstruction'][0]['projectId']); +// projectViewModel.setInPatientAdmissionRequest(reqInfo); +// projectViewModel.setPatientHasAdmissionRequest(true); +// } +// }); +// } +// +// Future goToHome(context) async { +// authenticatedUserObject.isLogin = true; +// appointmentRateViewModel.isLogin = true; +// projectViewModel.isLogin = true; +// projectViewModel.user = authenticatedUserObject.user; +// await authenticatedUserObject.getUser(getUser: true); +// +// getToDoCount(context); +// checkIfIsInPatient(context); +// +// appointmentRateViewModel.getIsLastAppointmentRatedList(projectViewModel.isArabic ? 1 : 2).then((_) { +// GifLoaderDialogUtils.hideDialog(AppGlobal.context); +// +// if (appointmentRateViewModel.isHaveAppointmentNotRate) { +// Navigator.pushAndRemoveUntil( +// context, +// FadePage(page: RateAppointmentDoctor()), +// (route) => false, +// ); +// } else { +// Navigator.pushAndRemoveUntil( +// context, +// FadePage(page: LandingPage()), +// (route) => false, +// ); +// } +// insertIMEI(); +// }).catchError((error) { +// print(error); +// }); +// } +// +// void getToDoCount(context) { +// toDoProvider.setState(0, 0, true, "0"); +// ClinicListService().getActiveAppointmentNo(context).then((res) { +// if (res['MessageStatus'] == 1) { +// toDoProvider.setState( +// res['AppointmentActiveNumber'], +// res['AncillaryOrderListCount'], +// true, +// "0", +// ); +// } +// }).catchError((err) => print(err)); +// } +// +// checkIfUserAgreedBefore(CheckActivationCode result, context) { +// if (projectViewModel.havePrivilege(109)) { +// authService.checkIfUserAgreed().then((result) { +// if (result['IsPatientAlreadyAgreed']) { +// goToHome(context); +// } else { +// authService.getUserAgreementContent().then((result) { +// GifLoaderDialogUtils.hideDialog(AppGlobal.context); +// Navigator.pushAndRemoveUntil( +// context, +// FadePage( +// page: UserLoginAgreementPage( +// userAgreementText: result['UserAgreementContent'], +// authenticatedUserObject: authenticatedUserObject, +// appointmentRateViewModel: appointmentRateViewModel, +// selectedOption: selectedOption, +// isArabic: projectViewModel.isArabic, +// ), +// ), +// (r) => false); +// }).catchError((err) { +// GifLoaderDialogUtils.hideDialog(context); +// print(err); +// }); +// } +// }).catchError((err) { +// GifLoaderDialogUtils.hideDialog(context); +// print(err); +// }); +// } else { +// goToHome(context); +// } +// } +// +// @override +// void dispose() { +// nationIdController.dispose(); +// phoneController?.dispose(); +// super.dispose(); +// } +} diff --git a/lib/locator.dart b/lib/locator.dart index 225145ff..dde820af 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -12,6 +12,7 @@ import 'package:hmg_patient_app/core/viewModels/pharmacyModule/MostViewedViewMod import 'package:hmg_patient_app/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart'; import 'package:hmg_patient_app/core/viewModels/product_categories_view_model.dart'; import 'package:hmg_patient_app/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; import 'package:hmg_patient_app/core/viewModels/weather/weather_view_model.dart'; import 'package:hmg_patient_app/services/payfort_services/payfort_service.dart'; import 'package:hmg_patient_app/services/payfort_services/payfort_view_model.dart'; @@ -90,6 +91,7 @@ import 'core/viewModels/AlHabibMedicalService/health-calculator/Bariatrics-viewm import 'core/viewModels/TermsConditionsViewModel.dart'; import 'core/viewModels/all_habib_medical_services/e_referral_view_model.dart'; import 'core/viewModels/appointment_rate_view_model.dart'; +import 'core/viewModels/auth_provider_view_model.dart'; import 'core/viewModels/blooddonation/blood_details_view_model.dart'; import 'core/viewModels/blooddonation/booddonation_view_model.dart'; import 'core/viewModels/child_vaccines/add_new_child_view_model.dart'; @@ -144,6 +146,7 @@ import 'core/viewModels/pharmacy_categorise_view_model.dart'; import 'core/viewModels/qr_view_model.dart'; import 'core/viewModels/vaccine_view_model.dart'; import 'core/viewModels/weather/weather_view_model.dart'; +import 'models/Appointments/toDoCountProviderModel.dart'; import 'services/pharmacy_services/brands_service.dart'; import 'services/pharmacy_services/orderDetails_service.dart'; import 'services/pharmacy_services/pharmacyAddress_service.dart'; @@ -313,6 +316,9 @@ void setupLocator() { locator.registerFactory(() => LastVisitedViewModel()); locator.registerFactory(() => MostViewedViewModel()); locator.registerFactory(() => PayfortViewModel()); + locator.registerFactory(() => ProjectViewModel()); + locator.registerFactory(() => AuthProviderViewModel()); + locator.registerFactory(() => ToDoCountProviderModel()); // Offer And Packages //---------------------- diff --git a/lib/main.dart b/lib/main.dart index 9bdbd89d..645974a7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -23,6 +23,7 @@ import 'package:localstorage/localstorage.dart'; import 'package:provider/provider.dart'; import 'config/size_config.dart'; +import 'core/viewModels/auth_provider_view_model.dart'; import 'core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'core/viewModels/project_view_model.dart'; import 'locator.dart'; @@ -141,6 +142,8 @@ class _MyApp extends State { providers: [ ChangeNotifierProvider( create: (context) => PharmacyPagesViewModel(), + ), ChangeNotifierProvider( + create: (context) => AuthProviderViewModel(), ), ChangeNotifierProvider( create: (context) => ProjectViewModel(), diff --git a/lib/models/Authentication/check_activation_code_request.dart b/lib/models/Authentication/check_activation_code_request.dart index 8d2cd71e..29ff9266 100644 --- a/lib/models/Authentication/check_activation_code_request.dart +++ b/lib/models/Authentication/check_activation_code_request.dart @@ -24,6 +24,7 @@ class CheckActivationCodeReq { int? deviceTypeID; bool? forRegisteration; + CheckActivationCodeReq({ this.patientMobileNumber, this.mobileNo, @@ -48,7 +49,7 @@ class CheckActivationCodeReq { this.sessionID, this.isDentalAllowedBackend, this.deviceTypeID, - this.forRegisteration, + this.forRegisteration }); CheckActivationCodeReq.fromJson(Map json) { diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart index 892b858f..112b079e 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart @@ -692,13 +692,14 @@ Widget newInputWidget( onChange(selected); } } else if (selectionType == SelectionType.calendar) { - bool isGregorian = true; + 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, + initialShowGregorian: true, initialDate: DateTime.now(), okWidget: Padding( padding: const EdgeInsets.only(right: 8.0), diff --git a/lib/pages/login/register_new.dart b/lib/pages/login/register_new.dart index 0d46ccd6..3f2ff485 100644 --- a/lib/pages/login/register_new.dart +++ b/lib/pages/login/register_new.dart @@ -1,21 +1,28 @@ +import 'dart:convert'; + import 'package:flutter/gestures.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:hijri_gregorian_calendar/hijri_gregorian_calendar.dart'; import 'package:hmg_patient_app/config/config.dart'; import 'package:hmg_patient_app/config/shared_pref_kay.dart'; import 'package:hmg_patient_app/config/size_config.dart'; +import 'package:hmg_patient_app/core/service/client/base_app_client.dart'; import 'package:hmg_patient_app/core/viewModels/project_view_model.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_paitent_authentication_req.dart'; import 'package:hmg_patient_app/models/Authentication/check_user_status_reponse.dart'; import 'package:hmg_patient_app/models/Authentication/check_user_status_req.dart'; import 'package:hmg_patient_app/models/Authentication/checkpatient_for_registration.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/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/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_step_2.dart'; +import 'package:hmg_patient_app/pages/login/user-login-agreement-page.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/theme/colors.dart'; @@ -33,12 +40,21 @@ import 'package:hmg_patient_app/widgets/otp/sms-popup.dart'; import 'package:hmg_patient_app/widgets/text/app_texts_widget.dart'; import 'package:provider/provider.dart'; +import '../../core/viewModels/appointment_rate_view_model.dart'; +import '../../locator.dart'; +import '../../models/Authentication/authenticated_user.dart'; import '../../models/Authentication/select_device_imei_res.dart'; +import '../../models/InPatientServices/get_admission_info_response_model.dart'; +import '../../models/InPatientServices/get_admission_request_info_response_model.dart'; +import '../../services/clinic_services/get_clinic_service.dart'; import '../../widgets/dialogs/alert_dialog.dart'; import '../../widgets/dialogs/confirm_dialog.dart'; import '../../widgets/transitions/fade_page.dart'; import 'package:intl/intl.dart' as intl; +import '../landing/landing_page.dart'; +import '../rateAppointment/rate_appointment_doctor.dart'; + class RegisterNew extends StatefulWidget { @override _RegisterNew createState() => _RegisterNew(); @@ -47,6 +63,8 @@ class RegisterNew extends StatefulWidget { class _RegisterNew extends State { final nationalIDorFile = TextEditingController(); final phoneController = TextEditingController(); + AppointmentRateViewModel appointmentRateViewModel = locator(); + Country selectedCountry = Country.saudiArabia; OTPType? otpType; bool isTermsAccepted = false; @@ -55,6 +73,7 @@ class _RegisterNew extends State { final int loginType = LoginType.loginType; late String mobileNo; + var loginTokenID; // String countryCode = '966'; var isHijri; @@ -68,6 +87,13 @@ class _RegisterNew extends State { String? LoginTokenID; bool isDubai = false; final intl.DateFormat dateFormat = intl.DateFormat('dd/MM/yyyy'); + SelectDeviceIMEIRES? user; + AuthenticatedUser? userdata; + late int selectedOption; + bool isSkipRegistration = false; + + late ProjectViewModel projectViewModel; + late ToDoCountProviderModel toDoProvider; @override void initState() { @@ -86,6 +112,8 @@ class _RegisterNew extends State { @override Widget build(BuildContext context) { + projectViewModel = context.read(); + toDoProvider = context.read(); return AppScaffold( appBarTitle: TranslationBase.of(context).register, isShowDecPage: false, @@ -184,7 +212,7 @@ class _RegisterNew extends State { Divider(height: 1), Directionality( textDirection: TextDirection.ltr, - child: newInputWidget(TranslationBase.of(context).nationalIdNumber, "1xxxxxxxx", nationalIDorFile, + child: newInputWidget(TranslationBase.of(context).nationalIdNumber, "xxxxxxxxx", nationalIDorFile, isEnable: true, prefix: null, removePadding: true, @@ -209,12 +237,23 @@ class _RegisterNew extends State { isAllowLeadingIcon: true, hasSelectionCustomIcon: true, selectionType: SelectionType.calendar, - selectedValue: selectedDOB != null ? Utils.formatDateToDisplay(selectedDOB.toString()) : null, + selectedValue: selectedDOB != null + ? isHijri == 1 + ? Utils.formatHijriDateToDisplay(selectedDOB!.toIso8601String()) + : Utils.formatDateToDisplay(selectedDOB.toString()) + : null, selectionCustomIcon: "assets/images/svg/calendar.svg", lang: context.selectedLanguage, padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), leadingIcon: "assets/images/svg/birthday-cake.svg", onChange: (value) { selectedDOB = DateTime.parse(value!); + if (isHijri == 1) { + var hijriDate = HijriGregConverter.gregorianToHijri(DateTime.parse(value)); + selectedDOB = DateTime(hijriDate.year, hijriDate.month, hijriDate.day, DateTime.now().hour, DateTime.now().minute, DateTime.now().second); + } else { + selectedDOB = DateTime.parse(value); + } + print(selectedDOB!.toIso8601String()); setState(() {}); }, onCalendarTypeChanged: (bool value) { if (value) { @@ -465,15 +504,10 @@ class _RegisterNew extends State { } else { print("OTP sent successfully to ${mobileNo} using Whatsapp"); } - - // mobileNo = phoneController.text; startRegistration(value); - - // Navigator.of(context).push(FadePage(page: RegisterNewStep2())); } startRegistration(type) { - // if (isButtonDisabled == false) { var request = CheckPatientForRegistration(); request.patientMobileNumber = int.parse(mobileNo); @@ -484,7 +518,6 @@ class _RegisterNew extends State { request.isRegister = true; request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); request.isHijri = isHijri ?? 0; - // request.tokenID = LoginTokenID; this.checkPatientForRegisteration(registrationData: request, type: type); // } } @@ -514,7 +547,7 @@ class _RegisterNew extends State { var nRequest = request.toJson(); nRequest['LogInTokenID'] = response['LogInTokenID']; if (response['hasFile'] == true) { - ConfirmDialog dialog = new ConfirmDialog( + await ConfirmDialog( context: context, confirmMessage: response['ErrorEndUserMessage'], okText: TranslationBase.of(context).ok, @@ -522,8 +555,10 @@ class _RegisterNew extends State { okFunction: () { AlertDialogBox.closeAlertDialog(context); sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, nRequest); - // LoginRegistration.loginMethod = type; // 1=NationalID, by default from Registration - Navigator.of(context).push(FadePage(page: WelcomeLogin())); + setState(() { + isSkipRegistration = true; + }); + sendActivationCode(type, "", null, isSkipRegistration); }, cancelFunction: () {}) .showAlertDialog(context); @@ -539,7 +574,7 @@ class _RegisterNew extends State { if (request.patientOutSA == 0) { this.chekUserData(response['LogInTokenID'], type); // ظ ; } else { - sendActivationCode(type, response['LogInTokenID'], null); + sendActivationCode(type, response['LogInTokenID'], null, isSkipRegistration); } } } else { @@ -577,18 +612,18 @@ class _RegisterNew extends State { // widget.changePageViewIndex!(1), // Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex, fromRegistration: true))), - sendActivationCode(type, loginToken, resultSet); + sendActivationCode(type, loginToken, resultSet, isSkipRegistration); } else { AppToast.showErrorToast(message: result != null ? result : TranslationBase.of(context).somethingWentWrong); } }); } - sendActivationCode(type, loginTokenID, RegisterInfoResponse? nHICData) async { + sendActivationCode(type, loginTokenID, RegisterInfoResponse? nHICData, skipRegistration) async { LoginTokenID = loginTokenID; var request = authService.getCommonRequest( registerd_data: null, - deviceToken: DEVICE_TOKEN, + deviceToken: skipRegistration ? null : DEVICE_TOKEN, mobileNumber: int.parse(mobileNo), zipCode: selectedCountry.countryCode, patientOutSA: selectedCountry.countryCode == "966" ? 0 : 1, @@ -600,7 +635,7 @@ class _RegisterNew extends State { request.sMSSignature = await SMSOTP.getSignature(); GifLoaderDialogUtils.showMyDialog(context); - if (selectedCountry.countryCode == "966") { + if (selectedCountry.countryCode == "966" && !skipRegistration) { request.healthId = nHICData!.healthId; request.nationalID = nHICData.idNumber; request.patientIdentificationID = nHICData.idNumber; @@ -610,84 +645,345 @@ class _RegisterNew extends State { } request.isHijri = isHijri ?? 0; request.oTPSendType = type; - await this.authService.sendActivationCodeRegister(request).then((result) { - GifLoaderDialogUtils.hideDialog(context); - if (result != null && result['isSMSSent'] == true) { - print(result); - // LoginTokenID = result["LogInTokenID"]; - startSMSService(type); - } - }).catchError((r) { - GifLoaderDialogUtils.hideDialog(context); - AppToast.showErrorToast(message: r); - }); + if (skipRegistration) { + var req = getCommonRequest(type: type); + req.logInTokenID = ""; + var request = CheckPatientAuthenticationReq.fromJson(req.toJson()); + authService.checkPatientAuthentication(request).then((value) async { + if (value['isSMSSent']) { + sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']); + LoginTokenID = value['LogInTokenID']; + var request = this.getCommonRequest(type: type); + request.sMSSignature = await SMSOTP.getSignature(); + selectedOption = type; + request.dob = ""; + request.healthId = ""; + request.isHijri = 0; + + await authService.sendActivationCode(request).then((result) { + GifLoaderDialogUtils.hideDialog(context); + if (result != null && result['isSMSSent'] == true) { + startSMSService(request.loginType, skipRegistration); + } + }).catchError((r) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: r.toString()); + }); + + // sendActivationCodeForLogin(type, value['LogInTokenID'], null, false) + // request.loginTokenID = value['LogInTokenID'], + // request.dob = "", + // request.healthId = "", + // request.isHijri = 0, + // request.tokenID = value['LogInTokenID'], + // authService.sendActivationCode(request).then((result) { + // GifLoaderDialogUtils.hideDialog(context); + // if (result != null && result['isSMSSent'] == true) { + // this.startSMSService(type); + // } + // }).catchError((r) { + // GifLoaderDialogUtils.hideDialog(context); + // AppToast.showErrorToast(message: r.toString()); + // }) + } else { + if (value['IsAuthenticated']) { + checkActivationCode(); + } + } + }).catchError((err) { + print(err); + GifLoaderDialogUtils.hideDialog(context); + ConfirmDialog dialog = new ConfirmDialog( + context: context, + confirmMessage: err, + okText: TranslationBase.of(context).confirm, + cancelText: TranslationBase.of(context).cancel_nocaps, + okFunction: () => { + ConfirmDialog.closeAlertDialog(context), + Navigator.of(context).push(FadePage(page: RegisterNew())), + }, + cancelFunction: () => {}); + dialog.showAlertDialog(context); + }); + } else { + await this.authService.sendActivationCodeRegister(request).then((result) { + GifLoaderDialogUtils.hideDialog(context); + if (result != null && result['isSMSSent'] == true) { + print(result); + // LoginTokenID = result["LogInTokenID"]; + startSMSService(type, skipRegistration); + } + }).catchError((r) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: r); + }); + } } - checkActivationCode({value, type}) async { - // Navigator.pop(context); - // GifLoaderDialogUtils.showMyDialog(context); - var request = authService.getCommonRequest( + Future checkActivationCode({value, type, skipRegistration}) async { + final isSaudi = selectedCountry.countryCode == "966"; + final isHijriDate = isHijri == 1; + final dobString = isHijriDate ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); + var req; + if (skipRegistration) { + req = getCommonRequest(type: type); + } else { + req = authService.getCommonRequest( registerd_data: null, deviceToken: DEVICE_TOKEN, mobileNumber: int.parse(mobileNo), zipCode: selectedCountry.countryCode, - patientOutSA: selectedCountry.countryCode == "966" ? 0 : 1, + patientOutSA: isSaudi ? 0 : 1, loginTokenID: LoginTokenID, selectedOption: type, - user: SelectDeviceIMEIRES()); - dynamic res; - // if (healthId != null || isDubai) { - // if (isDubai) { - // request['DOB'] = dob; - // } - request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); - if (selectedCountry.countryCode == "966") { - request.healthId = nHICData!.healthId!; + user: SelectDeviceIMEIRES(), + ); } - request.isHijri = isHijri ?? 0; - request.nationalID = selectedCountry.countryCode == "966" ? nHICData!.idNumber : nationalIDorFile.text; - request.patientIdentificationID = selectedCountry.countryCode == "966" ? nHICData!.idNumber : nationalIDorFile.text; - request.isRegister = true; + req.dob = dobString; + req.isHijri = isHijri ?? 0; - authService - .checkActivationCodeRegister(request.toJson(), value) - .then((result) => { - res = result, - if (result is Map) - { - result = CheckActivationCode.fromJson(result as Map), + if (isSaudi && !skipRegistration) { + req.healthId = nHICData?.healthId ?? ""; + } else { + req.healthId = ""; + } - //next registration page navigate from here. - Navigator.of(context).push( - FadePage(page: RegisterNewStep2(nHICData, request)), - ) - - // // if(widget.isDubai ==false){ - // // widget.changePageViewIndex!(1), - // // if(widget.isDubai ==false){ - // - // Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), - // } - } - else - { - Navigator.of(context).pop(), - GifLoaderDialogUtils.hideDialog(context), - Future.delayed(Duration(seconds: 1), () { - AppToast.showErrorToast(message: result, localContext: context); - }), - // projectViewModel.analytics.loginRegistration.login_fail(error: result), - // projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result), - } - }) - .catchError((err) { - print(err); + if (!skipRegistration) { + req.nationalID = isSaudi ? nHICData?.idNumber : nationalIDorFile.text; + req.patientIdentificationID = isSaudi ? nHICData?.idNumber : nationalIDorFile.text; + req.isRegister = true; + } else { + req.patientIdentificationID = nationalIDorFile.text; + req.nationalID = nationalIDorFile.text; + req.deviceToken = null; + // req.loginType = type; + // req.healthId = ""; + // req.isHijri = isHijri ?? 0; + // req.dob = ""; + } + try { + dynamic result; + if (skipRegistration) { + result = await authService.checkActivationCode(req.toJson(), value); + if (result is Map) { + final activation = CheckActivationCode.fromJson(result as Map); + if (activation.errorCode == '699') { + GifLoaderDialogUtils.hideDialog(context); + await Future.delayed(const Duration(seconds: 2)); + AppToast.showErrorToast(message: activation.errorEndUserMessage); + Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin)); + } else { + await sharedPref.remove(FAMILY_FILE); + activation.list!.isFamily = false; + userdata = activation.list; + await sharedPref.setString(BLOOD_TYPE, activation.patientBloodType ?? ""); + authenticatedUserObject.user = activation.list!; + projectViewModel.setPrivilege(privilegeList: result); + await sharedPref.setObject(MAIN_USER, activation.list); + await sharedPref.setObject(USER_PROFILE, activation.list); + loginTokenID = activation.logInTokenID; + await sharedPref.setObject(LOGIN_TOKEN_ID, activation.logInTokenID); + await sharedPref.setString(TOKEN, activation.authenticationTokenID!); + + checkIfUserAgreedBefore(activation, context); + projectViewModel.analytics.loginRegistration.login_successful(); + } + } else { + GifLoaderDialogUtils.hideDialog(context); + await Future.delayed(const Duration(seconds: 1)); + Navigator.of(context).pop(); + AppToast.showErrorToast(message: result, localContext: context); + projectViewModel.analytics.loginRegistration.login_fail(error: result); + projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result); + } + } else { + result = await authService.checkActivationCodeRegister(req.toJson(), value); + if (result is Map) { + final activation = CheckActivationCode.fromJson(result as Map); + Navigator.of(context).push( + FadePage(page: RegisterNewStep2(nHICData, req)), + ); + // Optionally: Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)); + } else { + Navigator.of(context).pop(); + GifLoaderDialogUtils.hideDialog(context); + await Future.delayed(const Duration(seconds: 1)); + AppToast.showErrorToast(message: result, localContext: context); + // Optionally: log analytics here + } + } + } catch (err) { GifLoaderDialogUtils.hideDialog(context); - Future.delayed(Duration(seconds: 1), () { - AppToast.showErrorToast(message: err); - // startSMSService(tempType); - }); - }); + await Future.delayed(const Duration(seconds: 1)); + print(err); + AppToast.showErrorToast(message: err.toString()); + } + } + + // checkActivationCode({value, type, skipRegistration}) async { + // // Navigator.pop(context); + // // GifLoaderDialogUtils.showMyDialog(context); + // var request = authService.getCommonRequest( + // registerd_data: null, + // deviceToken: DEVICE_TOKEN, + // mobileNumber: int.parse(mobileNo), + // zipCode: selectedCountry.countryCode, + // patientOutSA: selectedCountry.countryCode == "966" ? 0 : 1, + // loginTokenID: LoginTokenID, + // selectedOption: type, + // user: SelectDeviceIMEIRES()); + // dynamic res; + // + // request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); + // if (selectedCountry.countryCode == "966" && !skipRegistration) { + // request.healthId = nHICData!.healthId!; + // } else { + // request.healthId = ""; + // } + // request.isHijri = isHijri ?? 0; + // if (!skipRegistration) { + // request.nationalID = selectedCountry.countryCode == "966" ? nHICData!.idNumber : nationalIDorFile.text; + // request.patientIdentificationID = selectedCountry.countryCode == "966" ? nHICData!.idNumber : nationalIDorFile.text; + // request.isRegister = true; + // } + // if (skipRegistration) { + // request.patientIdentificationID = nationalIDorFile.text; + // request.nationalID = nationalIDorFile.text; + // request.deviceToken = null; + // request.healthId = ""; + // request.isHijri = isHijri ?? 0; + // request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); + // authService + // .checkActivationCode(request.toJson(), 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.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin)); + // }) + // } + // else + // { + // sharedPref.remove(FAMILY_FILE), + // result.list.isFamily = false, + // user = result.list, + // sharedPref.setString(BLOOD_TYPE, result.patientBloodType ?? ""), + // authenticatedUserObject.user = result.list, + // context.read().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, context), + // context.read().analytics.loginRegistration.login_successful(), + // } + // } + // else + // { + // GifLoaderDialogUtils.hideDialog(context), + // Future.delayed(Duration(seconds: 1), () { + // Navigator.of(context).pop(); + // AppToast.showErrorToast(message: result, localContext: context); + // }), + // context.read().analytics.loginRegistration.login_fail(error: result), + // context.read().analytics.errorTracking.log('otp_verification_at_confirm_login', error: result) + // } + // }) + // .catchError((err) { + // GifLoaderDialogUtils.hideDialog(context); + // Future.delayed(Duration(seconds: 1), () { + // print(err); + // AppToast.showErrorToast(message: err); + // // startSMSService(tempType); + // }); + // }); + // } else { + // authService + // .checkActivationCodeRegister(request.toJson(), value) + // .then((result) => { + // res = result, + // if (result is Map) + // { + // result = CheckActivationCode.fromJson(result as Map), + // Navigator.of(context).push( + // FadePage(page: RegisterNewStep2(nHICData, request)), + // ) + // + // // // if(widget.isDubai ==false){ + // // // widget.changePageViewIndex!(1), + // // // if(widget.isDubai ==false){ + // // + // // Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), + // // } + // } + // else + // { + // Navigator.of(context).pop(), + // GifLoaderDialogUtils.hideDialog(context), + // Future.delayed(Duration(seconds: 1), () { + // AppToast.showErrorToast(message: result, localContext: context); + // }), + // // projectViewModel.analytics.loginRegistration.login_fail(error: result), + // // projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result), + // } + // }) + // .catchError((err) { + // print(err); + // GifLoaderDialogUtils.hideDialog(context); + // Future.delayed(Duration(seconds: 1), () { + // AppToast.showErrorToast(message: err); + // // startSMSService(tempType); + // }); + // }); + // } + // } + + getCommonRequest({type}) { + bool fileNo = false; + if (nationalIDorFile.text != null && nationalIDorFile.text.isNotEmpty) { + fileNo = nationalIDorFile.text.length < 10; + } + + var request = SendActivationRequest(); + request.patientMobileNumber = int.parse(mobileNo); + request.mobileNo = '0' + mobileNo.toString(); + request.deviceToken = DEVICE_TOKEN; + request.projectOutSA = selectedCountry.countryCode == "966" ? false : true; + request.loginType = type == 1 ? type : 2; + request.oTPSendType = type == 1 ? type : 2; //this.selectedOption == 1 ? 1 : 2; + request.zipCode = selectedCountry.countryCode; + + request.logInTokenID = LoginTokenID ?? ""; + + // if (this.registerd_data != null) { + // request.searchType = this.registerd_data.searchType != null ? this.registerd_data.searchType : 1; + // request.patientID = this.registerd_data.patientID != null ? this.registerd_data.patientID : 0; + // request.patientIdentificationID = request.nationalID = this.registerd_data.patientIdentificationID != null ? this.registerd_data.patientIdentificationID : '0'; + // request.dob = this.registerd_data.dob; + // request.isRegister = this.registerd_data.isRegister; + // } else { + // request.searchType = request.searchType != null ? request.searchType : 1; + if (fileNo) { + request.patientID = int.parse(nationalIDorFile.text); + request.patientIdentificationID = request.nationalID = ""; + request.searchType = 2; + } else { + request.patientID = 0; + request.searchType = 1; + request.patientIdentificationID = request.nationalID = nationalIDorFile != null ? nationalIDorFile.text : '0'; + } + request.isRegister = false; + + request.deviceTypeID = request.searchType; + return request; } // startSMSService(type) { @@ -704,7 +1000,7 @@ class _RegisterNew extends State { // ).displayDialog(context); // } - startSMSService(type) { + startSMSService(type, skipRegistration) { late SMSOTP smsOtp; // Declare the variable first smsOtp = SMSOTP( context, @@ -712,7 +1008,7 @@ class _RegisterNew extends State { mobileNo, (code) { smsOtp.dispose(); // Now we can reference it - this.checkActivationCode(value: code, type: type); + checkActivationCode(value: code, type: type, skipRegistration: skipRegistration); }, () { smsOtp.dispose(); // Now we can reference it @@ -721,4 +1017,175 @@ class _RegisterNew extends State { ); smsOtp.displayDialog(context); } + + checkActivationCodeMobile({value}) async { + GifLoaderDialogUtils.showMyDialog(context); + var request = this.getCommonRequest().toJson(); + var 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.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin)); + }) + } + else + { + sharedPref.remove(FAMILY_FILE), + result.list.isFamily = false, + user = result.list, + sharedPref.setString(BLOOD_TYPE, result.patientBloodType ?? ""), + authenticatedUserObject.user = result.list, + context.read().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, context), + context.read().analytics.loginRegistration.login_successful(), + } + } + else + { + GifLoaderDialogUtils.hideDialog(context), + Future.delayed(Duration(seconds: 1), () { + Navigator.of(context).pop(); + AppToast.showErrorToast(message: result, localContext: context); + }), + } + }) + .catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + Future.delayed(Duration(seconds: 1), () { + print(err); + AppToast.showErrorToast(message: err); + // startSMSService(tempType); + }); + }); + } + + checkIfUserAgreedBefore(CheckActivationCode result, context) { + if (projectViewModel.havePrivilege(109)) { + authService.checkIfUserAgreed().then((result) { + if (result['IsPatientAlreadyAgreed']) { + goToHome(context); + } else { + authService.getUserAgreementContent().then((result) { + GifLoaderDialogUtils.hideDialog(AppGlobal.context); + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: UserLoginAgreementPage( + userAgreementText: result['UserAgreementContent'], + authenticatedUserObject: authenticatedUserObject, + appointmentRateViewModel: appointmentRateViewModel, + selectedOption: selectedOption, + isArabic: projectViewModel.isArabic, + ), + ), + (r) => false); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } else { + goToHome(context); + } + } + + Future goToHome(context) async { + authenticatedUserObject.isLogin = true; + appointmentRateViewModel.isLogin = true; + projectViewModel.isLogin = true; + projectViewModel.user = authenticatedUserObject.user; + await authenticatedUserObject.getUser(getUser: true); + + getToDoCount(); + checkIfIsInPatient(); + + appointmentRateViewModel.getIsLastAppointmentRatedList(projectViewModel.isArabic ? 1 : 2).then((_) { + GifLoaderDialogUtils.hideDialog(AppGlobal.context); + + if (appointmentRateViewModel.isHaveAppointmentNotRate) { + Navigator.pushAndRemoveUntil( + context, + FadePage(page: RateAppointmentDoctor()), + (route) => false, + ); + } else { + Navigator.pushAndRemoveUntil( + context, + FadePage(page: LandingPage()), + (route) => false, + ); + } + insertIMEI(); + }).catchError((error) { + print(error); + }); + } + + void getToDoCount() { + context.read().setState(0, 0, true, "0"); + ClinicListService().getActiveAppointmentNo(context).then((res) { + if (res['MessageStatus'] == 1) { + context.read().setState( + res['AppointmentActiveNumber'], + res['AncillaryOrderListCount'], + true, + "0", + ); + } + }).catchError((err) => print(err)); + } + + insertIMEI() { + authService.insertDeviceImei(selectedOption).then((value) => {}).catchError((err) { + print(err); + }); + } + + void checkIfIsInPatient() { + final service = ClinicListService(); + service.checkIfInPatientAPI(context).then((res) { + if (res['MessageStatus'] != 1) return; + + final isAdmitted = res['isAdmitted'] == true; + final hasAdmissionRequest = res['hasAdmissionRequests'] == true; + + print("IS ADMITTED: $isAdmitted"); + print("Has Admission Request: $hasAdmissionRequest"); + + ProjectViewModel projectViewModel = context.read(); + + if (isAdmitted && res['PatientAdmittedInformation']?.isNotEmpty == true) { + final info = GetAdmissionInfoResponseModel.fromJson(res['PatientAdmittedInformation'][0]); + projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']); + projectViewModel.setInPatientAdmissionInfo(info); + projectViewModel.setIsPatientAdmitted(true); + } + + if (hasAdmissionRequest && res['MedicalInstruction']?.isNotEmpty == true) { + final reqInfo = GetAdmissionRequestInfoResponseModel.fromJson(res['MedicalInstruction'][0]); + projectViewModel.setInPatientProjectID(res['MedicalInstruction'][0]['projectId']); + projectViewModel.setInPatientAdmissionRequest(reqInfo); + projectViewModel.setPatientHasAdmissionRequest(true); + } + }); + } } diff --git a/lib/pages/login/register_new_step_2.dart b/lib/pages/login/register_new_step_2.dart index 77476fa2..892a1dbf 100644 --- a/lib/pages/login/register_new_step_2.dart +++ b/lib/pages/login/register_new_step_2.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:flutter/gestures.dart'; import 'package:hmg_patient_app/config/shared_pref_kay.dart'; import 'package:hmg_patient_app/config/size_config.dart'; @@ -67,25 +69,33 @@ class _RegisterNew extends State { void initState() { super.initState(); isFromDubai = widget.payload.zipCode!.contains("971") || widget.payload.zipCode!.contains("+971"); - if (isFromDubai) { - getCountries(); - } + loadCountriesList(); + // 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); - }); + loadCountriesList() async { + final String response = await DefaultAssetBundle.of(context).loadString('assets/json/countriesList.json'); + final List data = json.decode(response); + countriesList = data.map((e) => NationalityCountries.fromJson(e)).toList(); + setState(() {}); } + // 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); @@ -215,7 +225,12 @@ class _RegisterNew extends State { 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, + : inputWidget( + TranslationBase.of(context).maritalStatus, + context.selectedLanguage == "ar" + ? (MaritalStatusTypeExtension.fromValue(widget.nHICData!.maritalStatusCode)!.typeAr) + : (MaritalStatusTypeExtension.fromValue(widget.nHICData!.maritalStatusCode)!.type), + null, isEnable: true, prefix: null, removePadding: true, @@ -255,7 +270,15 @@ class _RegisterNew extends State { selectionCustomIcon: "assets/images/svg/arrow-down.svg", leadingIcon: 'assets/images/svg/globe.svg', ).withVerticalPadding(8) - : inputWidget(TranslationBase.of(context).nationality, (widget.nHICData!.nationality ?? ""), null, + : inputWidget( + TranslationBase.of(context).nationality, + context.selectedLanguage == "ar" + ? (countriesList.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).nameN ?? "") + : (countriesList.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).name ?? ""), + + // (widget.nHICData!.nationalityCode ?? "") + + null, isEnable: true, prefix: null, removePadding: true, diff --git a/lib/pages/login/saved_login.dart b/lib/pages/login/saved_login.dart index e4a540a0..327c2a43 100644 --- a/lib/pages/login/saved_login.dart +++ b/lib/pages/login/saved_login.dart @@ -62,9 +62,11 @@ class _SavedLogin extends State { @override void initState() { super.initState(); - print("==== Saved Login====="); phoneController = TextEditingController(text: widget.savedLoginData.mobile!.startsWith('0') ? widget.savedLoginData.mobile!.substring(1) : widget.savedLoginData.mobile); phoneNumber = widget.savedLoginData.mobile!.startsWith('0') ? widget.savedLoginData.mobile!.substring(1) : widget.savedLoginData.mobile; + if (widget.savedLoginData.logInType! == 2 || widget.savedLoginData.logInType! == 3) { + loginWithFingerPrintFace(widget.savedLoginData.logInType!, widget.savedLoginData.iMEI!); + } } @override @@ -169,7 +171,7 @@ class _SavedLogin extends State { margin: EdgeInsets.all(16), child: SvgPicture.asset( getTypeIcons(widget.savedLoginData.logInType!, context), - color: widget.savedLoginData.logInType == 4 ? null: Color(0xFFED1C2B) , + color: widget.savedLoginData.logInType == 4 ? null : Color(0xFFED1C2B), height: 64, width: 64, ), @@ -210,99 +212,43 @@ class _SavedLogin extends State { ), 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: selectedCountry.countryCode, - initialPhoneNumber: phoneController!.text, - textController: phoneController, - isEnableCountryDropdown: false, - isFromSavedLogin: true, - onCountryChange: (value) { - selectedCountry = value; - setModalState(() {}); - }, - onChange: (String? value) { - phoneNumber = value; - }, - buttons: [ - Padding( - padding: const EdgeInsets.only(bottom: 10), - child: CustomButton( - text: TranslationBase.of(context).sendOTPSMS, - onPressed: () { - int? val = Utils.onOtpBtnPressed(OTPType.sms, phoneNumber); - 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: Text( - TranslationBase.of(context).oR, - style: context.dynamicTextStyle( - 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, phoneNumber); - if (val != null) { - GifLoaderDialogUtils.showMyDialog(context); - checkUserAuthentication(val); - } - }, - backgroundColor: Colors.white, - borderColor: Color(0xFF2E3039), - textColor: Color(0xFF2E3039), - icon: "assets/images/svg/whatsapp.svg", - ), - ), - ], - ), - ), - ); - }), - ); - }, - 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", - ), + widget.savedLoginData.logInType != null && widget.savedLoginData.logInType != 1 + ? CustomButton( + text: TranslationBase.of(context).loginByOTP, + onPressed: () { + if (widget.savedLoginData.logInType! == 2 || widget.savedLoginData.logInType! == 3) { + loginWithFingerPrintFace(widget.savedLoginData.logInType!, widget.savedLoginData.iMEI!); + } else { + widget.savedLoginData.logInType = 1; + int? val = widget.savedLoginData.logInType!; + checkUserAuthentication(val); + } + }, + 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", + ) + : CustomButton( + text: "${TranslationBase.of(context).loginBy} ${getType(4, context)}", + onPressed: () { + if (widget.savedLoginData.logInType! == 2 || widget.savedLoginData.logInType! == 3) { + loginWithFingerPrintFace(widget.savedLoginData.logInType!, widget.savedLoginData.iMEI!); + } else { + widget.savedLoginData.logInType = 4; + int? val = widget.savedLoginData.logInType!; + checkUserAuthentication(val); + } + }, + backgroundColor: Colors.white, + borderColor: Color(0xFF2E3039), + textColor: Color(0xFF2E3039), + borderWidth: 2, + padding: EdgeInsets.fromLTRB(0, 14, 0, 14), + icon: "assets/images/svg/whatsapp.svg", + ), const Spacer(flex: 2), // OR divider @@ -424,17 +370,16 @@ class _SavedLogin extends State { // setDefault(); sharedPref.setInt(LAST_LOGIN, lastLogin); checkActivationCode(null, lastLogin, result['LogInTokenID']); - }else if(result['ErrorEndUserMessage'] != null) { + } else if (result['ErrorEndUserMessage'] != null) { ConfirmDialog dialog = new ConfirmDialog( context: context, confirmMessage: result['ErrorEndUserMessage'], okText: TranslationBase.of(context).confirm, cancelText: TranslationBase.of(context).cancel_nocaps, okFunction: () => { - ConfirmDialog.closeAlertDialog(context), - - Navigator.of(context).pushReplacement(FadePage(page: WelcomeLogin())), - }, + ConfirmDialog.closeAlertDialog(context), + Navigator.of(context).pushReplacement(FadePage(page: WelcomeLogin())), + }, cancelFunction: () => {}); dialog.showAlertDialog(context); } diff --git a/lib/pages/login/welcome.dart b/lib/pages/login/welcome.dart index d3227a9c..231c4138 100644 --- a/lib/pages/login/welcome.dart +++ b/lib/pages/login/welcome.dart @@ -39,6 +39,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:intl/src/intl/date_format.dart'; import 'package:provider/provider.dart'; +import '../../models/Authentication/authenticated_user.dart'; import '../../widgets/dialogs/confirm_dialog.dart'; class WelcomeLogin extends StatefulWidget { @@ -71,6 +72,8 @@ class _WelcomeLogin extends State { var deviceToken; var lastLogin; + + AuthenticatedUser? userData; AuthenticatedUserObject authenticatedUserObject = locator(); AppointmentRateViewModel appointmentRateViewModel = locator(); late ProjectViewModel projectViewModel; @@ -80,7 +83,6 @@ class _WelcomeLogin extends State { late int selectedOption; bool onlySMSBox = false; - var userData; int fingrePrintBefore = 0; @@ -312,21 +314,21 @@ class _WelcomeLogin extends State { authService .checkPatientAuthentication(request) .then((value) => { - // GifLoaderDialogUtils.hideDialog(context), - 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) - // }) - } - else - { - if (value['IsAuthenticated']) {this.checkActivationCode()} - } - }) + // GifLoaderDialogUtils.hideDialog(context), + 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) + // }) + } + else + { + if (value['IsAuthenticated']) {this.checkActivationCode()} + } + }) .catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); @@ -336,9 +338,9 @@ class _WelcomeLogin extends State { okText: TranslationBase.of(context).confirm, cancelText: TranslationBase.of(context).cancel_nocaps, okFunction: () => { - ConfirmDialog.closeAlertDialog(context), - Navigator.of(context).push(FadePage(page: RegisterNew())), - }, + ConfirmDialog.closeAlertDialog(context), + Navigator.of(context).push(FadePage(page: RegisterNew())), + }, cancelFunction: () => {}); dialog.showAlertDialog(context); projectViewModel.analytics.loginRegistration.login_fail(error: err.toString()); @@ -396,30 +398,30 @@ class _WelcomeLogin extends State { authService .checkActivationCodeRegister(request, value) .then((result) => { - res = result, - if (result is Map) - { - result = CheckActivationCode.fromJson(result as Map), - if (this.registerd_data != null && this.registerd_data.isRegister == true) - { - // if(widget.isDubai ==false){ - // widget.changePageViewIndex!(1), - // if(widget.isDubai ==false){ - - Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), - } - } - else - { - Navigator.of(context).pop(), - GifLoaderDialogUtils.hideDialog(context), - Future.delayed(Duration(seconds: 1), () { - AppToast.showErrorToast(message: result); - }), - // projectViewModel.analytics.loginRegistration.login_fail(error: result), - // projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result), - } - }) + res = result, + if (result is Map) + { + result = CheckActivationCode.fromJson(result as Map), + if (this.registerd_data != null && this.registerd_data.isRegister == true) + { + // if(widget.isDubai ==false){ + // widget.changePageViewIndex!(1), + // if(widget.isDubai ==false){ + + Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), + } + } + else + { + Navigator.of(context).pop(), + GifLoaderDialogUtils.hideDialog(context), + Future.delayed(Duration(seconds: 1), () { + AppToast.showErrorToast(message: result); + }), + // projectViewModel.analytics.loginRegistration.login_fail(error: result), + // projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result), + } + }) .catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); @@ -432,56 +434,56 @@ class _WelcomeLogin extends State { 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.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin)); - }) - } - else if (this.registerd_data != null && this.registerd_data.isRegister == true) - { - // widget.changePageViewIndex!(1), - Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), - } - 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), - // 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) - } - }) + 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.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin)); + }) + } + else if (this.registerd_data != null && this.registerd_data.isRegister == true) + { + // widget.changePageViewIndex!(1), + Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), + } + 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), + // 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) + } + }) .catchError((err) { GifLoaderDialogUtils.hideDialog(context); Future.delayed(Duration(seconds: 1), () { @@ -503,11 +505,11 @@ class _WelcomeLogin extends State { context, type, phoneNumber, - (code) { + (code) { smsOtp.dispose(); // Now we can reference it this.checkActivationCode(value: code); }, - () { + () { smsOtp.dispose(); // Now we can reference it Navigator.pop(context); }, @@ -515,11 +517,7 @@ class _WelcomeLogin extends State { smsOtp.displayDialog(context); } - // showLoader(bool isTrue) { - // setState(() { - // isLoading = isTrue; - // }); - // } + setDefault() async { // showLoader(true); @@ -534,12 +532,12 @@ class _WelcomeLogin extends State { this.zipCode = this.registerd_data != null ? this.registerd_data.zipCode : this.user!.outSA == true - ? "971" - : "966"; + ? "971" + : "966"; this.patientOutSA = this.registerd_data != null ? this.registerd_data.zipCode == "966" - ? 0 - : 1 + ? 0 + : 1 : this.user!.outSA; if (this.registerd_data != null) { this.loginTokenID = await sharedPref.getString(LOGIN_TOKEN_ID); @@ -558,8 +556,8 @@ class _WelcomeLogin extends State { this.lastLogin = await sharedPref.getInt(LAST_LOGIN) != null ? await sharedPref.getInt(LAST_LOGIN) : user != null - ? user!.logInType - : null; + ? user!.logInType + : null; // showLoader(false); GifLoaderDialogUtils.hideDialog(context); @@ -625,7 +623,7 @@ class _WelcomeLogin extends State { isArabic: projectViewModel.isArabic, ), ), - (r) => false); + (r) => false); }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); @@ -657,13 +655,13 @@ class _WelcomeLogin extends State { Navigator.pushAndRemoveUntil( context, FadePage(page: RateAppointmentDoctor()), - (route) => false, + (route) => false, ); } else { Navigator.pushAndRemoveUntil( context, FadePage(page: LandingPage()), - (route) => false, + (route) => false, ); } insertIMEI(); diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index b6c09d13..a85807c5 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -274,7 +274,6 @@ class AuthProvider with ChangeNotifier { Future checkActivationCode(request, [value]) async { var neRequest = CheckActivationCodeReq.fromJson(request); - neRequest.activationCode = value ?? "0000"; neRequest.isSilentLogin = value != null ? false : true; neRequest.versionID = VERSION_ID; diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index a057b179..76dfe15b 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -136,6 +136,33 @@ class Utils { } } + + static String formatHijriDateToDisplay(String hijriDateString) { + try { + // Assuming hijriDateString is in the format yyyy-MM-dd + final parts = hijriDateString.split('-'); + if (parts.length != 3) return ""; + + final day = parts[2].padLeft(2, '0'); + final year = parts[0]; + + // Map month number to short month name (Hijri months) + const hijriMonthNames = [ + 'Muharram', 'Safar', 'Rabi I', 'Rabi II', 'Jumada I', 'Jumada II', + 'Rajab', 'Sha\'ban', 'Ramadan', 'Shawwal', 'Dhu al-Qi\'dah', 'Dhu al-Hijjah' + ]; + final monthIndex = int.tryParse(parts[1]) ?? 1; + final month = hijriMonthNames[monthIndex - 1]; + + return '$day $month, $year'; + } catch (e) { + print("Error formatting hijri date: $e"); + return ""; + } + } + + + static String formatDateToUsage(String isoDateString) { try { final dateTime = DateTime.parse(isoDateString);