From c623b1e1f72738bec233e354b7b2ecc451ab0526 Mon Sep 17 00:00:00 2001 From: Kalonkarthik Date: Tue, 8 Apr 2025 15:22:02 +0530 Subject: [PATCH] Contact us and Notification UAT bug --- .../drawer_routes/Drawer Items/contactUs.dart | 162 +++++++++++++----- .../notification/notification.dart | 30 +++- 2 files changed, 146 insertions(+), 46 deletions(-) diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart b/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart index cc9d72f2..41ad29f8 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/contactUs.dart @@ -8,6 +8,7 @@ import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/enquiry_a import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:url_launcher/url_launcher.dart'; class Contact extends ConsumerStatefulWidget { const Contact({super.key}); @@ -57,43 +58,43 @@ class _ContactState extends ConsumerState { children: [ buildContactCard( context, - title: 'DUBAI - EMIRATES TOWER -32ND FLOOR', + title: 'DUBAI - EMIRATES TOWER - 32ND FLOOR', titleAr: 'دبي - أبراج الإمارات - الطابق 32', details: [ { 'icon': EnquiryAssetIconPath.building, - 'text': 'Office : Dubai - Emirates Tower -32nd Floor', - 'textAr': 'المقر الرئيسي : دبي - أبراج الإمارات - الطابق 32' + 'text': 'Office: Dubai - Emirates Tower - 32nd Floor', + 'textAr': 'المقر الرئيسي: دبي - أبراج الإمارات - الطابق 32' }, { 'icon': EnquiryAssetIconPath.phone, - 'text': 'Tel : 00971 46080000', - 'textAr': 'الهاتف : 0097146080000' + 'text': 'Tel: 00971 4608 0000', + 'textAr': 'الهاتف: 0097146080000' }, { 'icon': EnquiryAssetIconPath.fax, - 'text': 'Fax : 0097143273535', - 'textAr': 'فاكس : 0097143273535' + 'text': 'Fax: 00971 4327 3535', + 'textAr': 'فاكس: 0097143273535' }, { 'icon': EnquiryAssetIconPath.map, - 'text': 'P.O.Box : 127000 Dubai', - 'textAr': 'ص.ب: : 127000 دبي' + 'text': 'P.O.Box: 127000 Dubai', + 'textAr': 'ص.ب: 127000 دبي' }, { 'icon': EnquiryAssetIconPath.at, - 'text': 'Email Address : info@fcsc.gov.ae', - 'textAr': 'البريد الإلكتروني : info@fcsc.gov.ae' + 'text': 'Email Address: info@fcsc.gov.ae', + 'textAr': 'البريد الإلكتروني: info@fcsc.gov.ae' }, { 'icon': EnquiryAssetIconPath.map, - 'text': 'Latitude : 25.223926', - 'textAr': 'خط العرض : 25.223926' + 'text': 'Latitude: 25.223926', + 'textAr': 'خط العرض: 25.223926' }, { 'icon': EnquiryAssetIconPath.map, - 'text': 'Longitude : 55.350526', - 'textAr': 'خط الطول : 55.350526' + 'text': 'Longitude: 55.350526', + 'textAr': 'خط الطول: 55.350526' }, ], ), @@ -105,38 +106,38 @@ class _ContactState extends ConsumerState { details: [ { 'icon': EnquiryAssetIconPath.building, - 'text': 'Office : Media Section', - 'textAr': 'المقر الرئيسي : قسم الاعلام' + 'text': 'Office: Media Section', + 'textAr': 'المقر الرئيسي: قسم الاعلام' }, { 'icon': EnquiryAssetIconPath.phone, - 'text': 'Tel : 00971 46080000', - 'textAr': 'الهاتف : 0097146080000' + 'text': 'Tel: 00971 4608 0000', + 'textAr': 'الهاتف: 0097146080000' }, { 'icon': EnquiryAssetIconPath.fax, - 'text': 'Fax : 0097143273535', - 'textAr': 'فاكس : 0097143273535' + 'text': 'Fax: 00971 4327 3535', + 'textAr': 'فاكس: 0097143273535' }, { 'icon': EnquiryAssetIconPath.map, - 'text': 'P.O.Box : 127000 Dubai', - 'textAr': 'ص.ب: : 127000 دبي' + 'text': 'P.O.Box: 127000 Dubai', + 'textAr': 'ص.ب: 127000 دبي' }, { 'icon': EnquiryAssetIconPath.at, - 'text': 'Email Address : GCO@fcsc.gov.ae', - 'textAr': 'البريد الإلكتروني : GCO@fcsc.gov.ae' + 'text': 'Email Address: GCO@fcsc.gov.ae', + 'textAr': 'البريد الإلكتروني: GCO@fcsc.gov.ae' }, { 'icon': EnquiryAssetIconPath.map, - 'text': 'Latitude : 25.223926', - 'textAr': 'خط العرض : 25.223926' + 'text': 'Latitude: 25.223926', + 'textAr': 'خط العرض: 25.223926' }, { 'icon': EnquiryAssetIconPath.map, - 'text': 'Longitude : 55.350526', - 'textAr': 'خط الطول : 55.350526' + 'text': 'Longitude: 55.350526', + 'textAr': 'خط الطول: 55.350526' }, ], ), @@ -148,38 +149,38 @@ class _ContactState extends ConsumerState { details: [ { 'icon': EnquiryAssetIconPath.building, - 'text': 'Office : SDGs', - 'textAr': 'المقر الرئيسي : أهداف التنمية المستدامة' + 'text': 'Office: SDGs', + 'textAr': 'المقر الرئيسي: أهداف التنمية المستدامة' }, { 'icon': EnquiryAssetIconPath.phone, - 'text': 'Tel : 00971 46080000', - 'textAr': 'الهاتف : 0097146080000' + 'text': 'Tel: 00971 4608 0000', + 'textAr': 'الهاتف: 0097146080000' }, { 'icon': EnquiryAssetIconPath.fax, - 'text': 'Fax : 0097143273535', + 'text': 'Fax: 00971 4327 3535', 'textAr': 'فاكس : 0097143273535' }, { 'icon': EnquiryAssetIconPath.map, - 'text': 'P.O.Box : 127000 Dubai', - 'textAr': 'ص.ب: : 127000 دبي' + 'text': 'P.O.Box: 127000 Dubai', + 'textAr': 'ص.ب: 127000 دبي' }, { 'icon': EnquiryAssetIconPath.at, - 'text': 'Email Address : sdgs@fcsc.gov.ae', - 'textAr': 'البريد الإلكتروني : sdgs@fcsc.gov.ae' + 'text': 'Email Address: sdgs@fcsc.gov.ae', + 'textAr': 'البريد الإلكتروني: sdgs@fcsc.gov.ae' }, { 'icon': EnquiryAssetIconPath.map, - 'text': 'Latitude : 25.223926', - 'textAr': 'خط العرض : 25.223926' + 'text': 'Latitude: 25.223926', + 'textAr': 'خط العرض: 25.223926' }, { 'icon': EnquiryAssetIconPath.map, - 'text': 'Longitude : 55.350526', - 'textAr': 'خط الطول : 55.350526' + 'text': 'Longitude: 55.350526', + 'textAr': 'خط الطول: 55.350526' }, ], ), @@ -229,6 +230,34 @@ class _ContactState extends ConsumerState { } Widget buildTextRow(String iconName, String text) { + List values = List.filled(2, ''); + String cleanText = ''; + + if (text.toLowerCase().contains('tel:') || text.toLowerCase().contains('الهاتف:')) { + values = text.split(':'); + print ('List of values----- :$values'); + print ('value 1 ${values[0]}'); + cleanText=values[1].replaceAll(' ', ''); + } else if(text.toLowerCase().contains('email address:') || text.toLowerCase().contains('البريد الإلكتروني:')){ + values = text.split(':'); + cleanText = values[1].replaceAll(' ', ''); + } else{ + cleanText = text; + } + + Future sendEmail(String emailAddress) async { + print ('before email : $emailAddress'); + final uri = Uri( + scheme: 'mailto', + path: emailAddress, + ); + if (await canLaunchUrl(uri)) { + await launchUrl(uri); + } else { + debugPrint('Could not launch $uri'); + } + } + return Padding( padding: const EdgeInsets.symmetric(vertical: 5.0), child: Row( @@ -240,7 +269,54 @@ class _ContactState extends ConsumerState { height: 20, ), const SizedBox(width: 10), - Expanded( + iconName == EnquiryAssetIconPath.phone + ? InkWell( + onTap: () async{ + print('clean test : $cleanText'); + final uri = Uri(scheme: 'tel', path: cleanText); + if (await canLaunchUrl(uri)) { + await launchUrl(uri); + } else { + debugPrint('Could not launch $uri'); + } + }, + child: RichText( + text: TextSpan( + text: values[0], + style: const TextStyle(fontSize: 14, color: Color(0xFF5F5F5F)), + children: [ + TextSpan(text: ':',), + TextSpan(text: values[1], + style: TextStyle(fontSize: 14, color:Color(0xFF985400)) + ), + ], + ), + ), + // child: Text( + // text, + // style: const TextStyle( + // fontSize: 14, + // color: Color(0xFF5F5F5F), + // ), + // ), + ) + : iconName == EnquiryAssetIconPath.at + ? InkWell( + onTap: () => sendEmail(cleanText), + child: RichText( + text: TextSpan( + text: values[0], + style: const TextStyle(fontSize: 14, color: Color(0xFF5F5F5F)), + children: [ + TextSpan(text: ':',), + TextSpan(text: values[1], + style: TextStyle(fontSize: 14, color:Color(0xFF985400)) + ), + ], + ), + ), + ) + :Expanded( child: Text( text, style: const TextStyle( diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart index 6fb39abb..a96b179d 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart @@ -26,6 +26,7 @@ class _NotificationPageState extends ConsumerState { bool isLoading = true; List> notifications = []; List userReadedNotiOrNot = []; + String notificationCount=''; // Current selected tab index int selectedTabIndex = 0; @@ -48,7 +49,30 @@ class _NotificationPageState extends ConsumerState { super.initState(); locale = ref.read(localeProvider) ?? const Locale('en'); _userService = UserService(); - fetchNotifications(locale?.languageCode ?? 'en'); + _initializePage(); + } + + Future _initializePage() async { + _userService = UserService(); + await _fetchUserData();(); + await fetchNotifications(locale?.languageCode ?? 'en'); + _processNotifications(notifications , userReadedNotiOrNot); + } + + void _processNotifications( List> notification ,List push ){ + print ('inside last function ${notification.length}'); + print('inside last function ${push.length}'); + + int count = 0; + for (var product in notification) { + if (push.contains(product['id'])) { + count++; + } + } + print('count is $count'); + if(count>0){ + notificationCount='{$count}';} + else{notificationCount='';} } Future getUserId() async { @@ -188,8 +212,8 @@ class _NotificationPageState extends ConsumerState { child: BaseScaffold( title: Text( context.translate( - 'Notification', - 'إشعار', + 'Notification $notificationCount', + '$notificationCount إشعار ', ), ), body: isLoading