From 285dee15fc9770abeb31520850286d6fb5e48f45 Mon Sep 17 00:00:00 2001 From: Kalonkarthik Date: Thu, 20 Mar 2025 18:17:32 +0530 Subject: [PATCH] app tour alignment and message translation --- lib/l10n/intl_ar.arb | 3 +- lib/l10n/intl_en.arb | 4 +- .../auth_verification/create_new_pw.dart | 2 +- .../auth_verification/forgot_password.dart | 2 +- .../Screens/charts/screens/chart_screen.dart | 49 +++++++++++++++---- .../internet_check.dart | 25 +++++----- lib/presentation/Screens/profilepage.dart | 2 +- .../tab_routes/home_route.dart | 4 +- .../drawer_routes/Drawer Items/bookmark.dart | 5 +- .../Drawer Items/edit_profile.dart | 2 +- .../Drawer Items/manage_users.dart | 13 ++--- .../drawer_routes/custom_drawer_routes.dart | 4 +- 12 files changed, 76 insertions(+), 39 deletions(-) diff --git a/lib/l10n/intl_ar.arb b/lib/l10n/intl_ar.arb index b1abb55b..d613c33d 100644 --- a/lib/l10n/intl_ar.arb +++ b/lib/l10n/intl_ar.arb @@ -94,12 +94,13 @@ "status": "الحالة", "denied": "مرفوض", "pending": " قيد الانتظار", - "approve_msg": "هل أنت متأكد أنك ترغب في تغيير الحالة إلى \"{newStatus}\"؟", + "approve_msg": "هل أنت متأكد أنك ترغب في تغيير الحالة إلى", "yes": "نعم", "no": "لا", "no_result_found": "لم يتم العثور على نتائج", "search": "يبحث", "approved": "تمت الموافقة", + "status_success": "تم تحديث الحالة بنجاح", "profile_updated_successfully": "تم تحديث الملف الشخصي بنجاح", "create_new_password": "إنشاء كلمة مرور جديدة", diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 6bb6d3ee..f8c343a4 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -92,12 +92,12 @@ "denied": "Denied", "pending": "Pending", "approved": "Approved", - "approve_msg": "Are you sure you want to change the status to {newStatus}?", + "approve_msg": "Are you sure you want to change the status to ", "yes": "Yes", "no": "No", "no_result_found": "No results found", "search": "Search", - + "status_success": "Status updated successfully", "profile_updated_successfully": "Profile updated successfully", "create_new_password": "Create New Password", diff --git a/lib/presentation/Screens/auth_verification/create_new_pw.dart b/lib/presentation/Screens/auth_verification/create_new_pw.dart index 5e1b0d06..a973f8ed 100644 --- a/lib/presentation/Screens/auth_verification/create_new_pw.dart +++ b/lib/presentation/Screens/auth_verification/create_new_pw.dart @@ -210,7 +210,7 @@ class _CreateNewPwState extends ConsumerState { }); ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text('Failed to update password: $e'), + content: Text(context.translate('Failed to update password: $e','فشل في تحديث كلمة المرور')), backgroundColor: Colors.red, ), ); diff --git a/lib/presentation/Screens/auth_verification/forgot_password.dart b/lib/presentation/Screens/auth_verification/forgot_password.dart index 42745bb5..ea497ca3 100644 --- a/lib/presentation/Screens/auth_verification/forgot_password.dart +++ b/lib/presentation/Screens/auth_verification/forgot_password.dart @@ -158,7 +158,7 @@ class _ForgotPasswordState extends ConsumerState { }); ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text('Failed to update password: $e'), + content: Text(context.translate('Failed to update password: $e','فشل في تحديث كلمة المرور')), backgroundColor: Colors.red, ), ); diff --git a/lib/presentation/Screens/charts/screens/chart_screen.dart b/lib/presentation/Screens/charts/screens/chart_screen.dart index 243d9a1d..b9b70203 100644 --- a/lib/presentation/Screens/charts/screens/chart_screen.dart +++ b/lib/presentation/Screens/charts/screens/chart_screen.dart @@ -99,6 +99,7 @@ class _ChartScreen1State extends ConsumerState { late final Locale locale; late String mainTopic; late UserService _userService; + late double tourCard; @override void initState() { @@ -447,6 +448,29 @@ class _ChartScreen1State extends ConsumerState { // // ); // } + ///Calculate card Width + Future _getWidget() async { + await Future.delayed(Duration(milliseconds: 50)); // Ensures widget is built + final RenderBox? box = cardKey.currentContext?.findRenderObject() as RenderBox?; + + if (box != null) { + final Offset position = box.localToGlobal(Offset.zero); + final Size size = box.size; + + double bottomY = position.dy + size.height; // Y position + height + // final double screenWidth = MediaQuery.of(context).size.width; + // final double screenHeight = MediaQuery.of(context).size.height; + // print("screenWidth: ${screenWidth}"); + // print("screenHeight: ${screenHeight}"); + // print("Widget Position: ${position.dx}, ${position.dy}"); + // print("Widget Size: ${size.width} x ${size.height}"); + // print("Bottom Y Position: $bottomY"); + + return bottomY; + } + return null; + } + void handleSkip() { tutorialCoachMark.skip(); debugPrint('Skip clicked'); @@ -459,8 +483,9 @@ class _ChartScreen1State extends ConsumerState { context.go('/myhomepage'); } - void _kpiTutorialCoachMark() { + Future _kpiTutorialCoachMark() async { debugPrint('Not Initialized and Started'); + tourCard = (await _getWidget())!; // _calculateMarkPosition(); _initmarriageTargets(); debugPrint('Initialized and Started'); @@ -510,6 +535,9 @@ class _ChartScreen1State extends ConsumerState { void _initmarriageTargets() { final double screenWidth = MediaQuery.of(context).size.width; final double screenHeight = MediaQuery.of(context).size.height; + // print('remaintarget $remainHeight'); + // print ('at intint target : ${screenHeight-remainHeight}'); + final double arrowPosition= screenHeight-tourCard; marriageTargets = [ TargetFocus( enableTargetTab: false, @@ -529,11 +557,11 @@ class _ChartScreen1State extends ConsumerState { align: ContentAlign.bottom, child: SizedBox( width: double.infinity, - height: MediaQuery.of(context).size.height * 0.3, + height: arrowPosition, child: Stack( children: [ Positioned( - bottom: 55, + bottom: arrowPosition*0.41, left: 16, right: 16, child: Column( @@ -693,11 +721,11 @@ class _ChartScreen1State extends ConsumerState { align: ContentAlign.bottom, child: SizedBox( width: double.infinity, - height: MediaQuery.of(context).size.height * 0.60, + height: MediaQuery.of(context).size.height * 0.65, child: Stack( children: [ Positioned( - bottom: 55, + bottom: 25, left: 16, right: 16, child: Column( @@ -841,6 +869,9 @@ class _ChartScreen1State extends ConsumerState { void _initpreviousTargets() { final double screenWidth = MediaQuery.of(context).size.width; final double screenHeight = MediaQuery.of(context).size.height; + // print('remaintarget $remainHeight'); + // print ('at intint target : ${screenHeight-remainHeight}'); + final double arrowPosition= screenHeight-tourCard; previousMarriageTargets = [ TargetFocus( enableTargetTab: false, @@ -860,11 +891,11 @@ class _ChartScreen1State extends ConsumerState { align: ContentAlign.bottom, child: SizedBox( width: double.infinity, - height: MediaQuery.of(context).size.height * 0.60, + height: MediaQuery.of(context).size.height * 0.65, child: Stack( children: [ Positioned( - bottom: 35, + bottom: 25, left: 16, right: 16, child: Column( @@ -1020,11 +1051,11 @@ class _ChartScreen1State extends ConsumerState { align: ContentAlign.bottom, child: SizedBox( width: double.infinity, - height: MediaQuery.of(context).size.height * 0.30, + height: arrowPosition, child: Stack( children: [ Positioned( - bottom: 55, + bottom: arrowPosition*0.41, left: 16, right: 16, child: Column( diff --git a/lib/presentation/Screens/online_offline_verification/internet_check.dart b/lib/presentation/Screens/online_offline_verification/internet_check.dart index c13568c7..8b39d23f 100644 --- a/lib/presentation/Screens/online_offline_verification/internet_check.dart +++ b/lib/presentation/Screens/online_offline_verification/internet_check.dart @@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; +import 'package:uae_stat/domain/use_cases/language.dart'; class InternetCheckScreen extends ConsumerWidget { const InternetCheckScreen({super.key}); @@ -14,7 +15,7 @@ class InternetCheckScreen extends ConsumerWidget { // Show a SnackBar when internet is back ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text("Internet is back!"), + content: Text(context.translate('Internet is back!','عاد الاتصال بالإنترنت!')), backgroundColor: Colors.green, ), ); @@ -42,22 +43,22 @@ class InternetCheckScreen extends ConsumerWidget { children: [ Image.asset('assets/logos/no-internet.png', width: 150), SizedBox(height: myHeight / 40), - Text("No Internet Connection", - style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold)), - Text("Please check your Wi-Fi or Mobile Data", - style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500)), - Text("connection and try again", - style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500)), + Text(context.translate('No Internet Connection','لا يوجد اتصال بالإنترنت'), + style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),), + Text(context.translate('Please check your Wi-Fi or Mobile Data','يرجى التحقق من شبكة Wi-Fi أو بيانات الهاتف المحمول'), + style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500),), + Text(context.translate('connection and try again','واتصالك ثم حاول مرة أخرى'), + style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500),), SizedBox(height: myHeight / 40), ElevatedButton( onPressed: () async { bool hasInternet = - await InternetConnectionChecker.instance.hasConnection; + await InternetConnectionChecker.instance.hasConnection; if (hasInternet) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text("Internet is back!"), + content: Text(context.translate('Internet is back!','عاد الاتصال بالإنترنت!')), backgroundColor: Colors.green, ), ); @@ -73,7 +74,7 @@ class InternetCheckScreen extends ConsumerWidget { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: - Text("No internet connection. Please try again."), + Text(context.translate('No internet connection. Please try again.','لا يوجد اتصال بالإنترنت. يرجى المحاولة مرة أخرى.')), backgroundColor: Colors.red, ), ); @@ -88,8 +89,8 @@ class InternetCheckScreen extends ConsumerWidget { child: Row( mainAxisSize: MainAxisSize.min, children: [ - Text("Retry", - style: TextStyle(fontSize: 16, color: Colors.white)), + Text( context.translate('Retry','إعادة المحاولة'), + style: TextStyle(fontSize: 16, color: Colors.white),), SizedBox(width: 8), Icon(Icons.refresh, size: 16, color: Colors.white), ], diff --git a/lib/presentation/Screens/profilepage.dart b/lib/presentation/Screens/profilepage.dart index 43bfad42..4d6910dd 100644 --- a/lib/presentation/Screens/profilepage.dart +++ b/lib/presentation/Screens/profilepage.dart @@ -378,7 +378,7 @@ class _ProfileScreenState extends ConsumerState { context.go('/welcomePage'); } catch (error) { ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text("Failed to update profile: $error"))); + SnackBar(content: Text(context.translate("Failed to update profile: $error",'$error فشل في تحديث الملف الشخصي: '))),); } } } diff --git a/lib/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart b/lib/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart index 99367785..4863716d 100644 --- a/lib/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart +++ b/lib/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart @@ -466,7 +466,7 @@ class EconomyStatsState extends ConsumerState { child: Stack( children: [ Positioned( - bottom: 20, + bottom: 10, left: 16, right: 16, child: Column( @@ -943,7 +943,7 @@ class EconomyStatsState extends ConsumerState { child: Stack( children: [ Positioned( - bottom: 20, + bottom: 10, left: 16, right: 16, child: Column( diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart b/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart index 0081985b..34ab01c9 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/bookmark.dart @@ -217,7 +217,9 @@ class _BookMarkState extends ConsumerState { } catch (e) { SnackBar( content: Text( + context.translate( 'Unable to remove from bookmarks. Please try again', + 'تعذر الإزالة من الإشارات المرجعية. يرجى المحاولة مرة أخرى.',), style: TextStyle(color: Color(0xFFEB5F24), fontWeight: FontWeight.w600), ), @@ -495,7 +497,8 @@ class _BookMarkState extends ConsumerState { size: 100, color: Colors.grey[400]), SizedBox(height: 16), Text( - 'No Bookmark is added', + context.translate('No BookMark Added', + 'لم يتم إضافة أي علامة مرجعية'), style: TextStyle( fontSize: 16, color: Colors.grey), ), diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart b/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart index b694110f..a2cf4bf1 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/edit_profile.dart @@ -275,7 +275,7 @@ class _EditProfileState extends ConsumerState { }); } else { ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Please select a JPG, JPEG, or PNG file.')), + SnackBar(content: Text(context.translate('Please select a JPG, JPEG, or PNG file.','يرجى تحديد ملف بصيغة JPG أو JPEG أو PNG.'))), ); } } diff --git a/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart b/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart index 1be79d0e..7e33e008 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/manage_users.dart @@ -7,6 +7,7 @@ import 'package:pocketbase/pocketbase.dart'; import 'package:uae_stat/config/api_config.dart'; import 'package:uae_stat/config/connectivity_provider.dart'; import 'package:uae_stat/config/toggle_lang_service.dart'; +import 'package:uae_stat/domain/use_cases/language.dart'; import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart'; import 'package:uae_stat/presentation/components/indicators/locale_provider.dart'; @@ -151,7 +152,7 @@ class _ManageUserRouterState extends ConsumerState { isLoading = false; }); ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Status updated successfully!')), + SnackBar(content: Text(AppLocalizations.of(context)!.status_success),), ); } catch (e) { setState(() { @@ -159,7 +160,7 @@ class _ManageUserRouterState extends ConsumerState { }); Navigator.of(context).pop(); ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Error updating status: $e')), + SnackBar(content: Text(context.translate('Error updating status: $e','$e خطأ في تحديث الحالة: '))), ); } } @@ -191,7 +192,7 @@ class _ManageUserRouterState extends ConsumerState { ), Text.rich( TextSpan( - text: 'Are you sure you want to change the status to ', + text: AppLocalizations.of(context)!.approve_msg, style: TextStyle( fontSize: 18, color: Color(0xFF898C81), @@ -443,7 +444,7 @@ class _ManageUserRouterState extends ConsumerState { SizedBox(height: 15), // Space between icon and text Text( - "No results found", + AppLocalizations.of(context)!.no_result_found, style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, @@ -454,7 +455,7 @@ class _ManageUserRouterState extends ConsumerState { SizedBox(height: 12), // Space between texts FittedBox( child: Text( - "We couldn't find anything matching your search.", + context.translate("We couldn't find anything matching your search.",'لم نعثر على أي شيء يطابق بحثك.'), style: TextStyle( fontSize: 18, color: Color(0xFF898C81)), @@ -532,7 +533,7 @@ class _ManageUserRouterState extends ConsumerState { (index) => DataCell( index == 0 ? Text( - 'No results found', + AppLocalizations.of(context)!.no_result_found, style: TextStyle( fontStyle: FontStyle .italic), diff --git a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart index 83939921..4dcf04d8 100644 --- a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart +++ b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart @@ -309,7 +309,7 @@ class _BaseScaffoldState extends ConsumerState { child: Stack( children: [ Positioned( - bottom: 25, + bottom: 40, left: 16, right: 16, child: Column( @@ -473,7 +473,7 @@ class _BaseScaffoldState extends ConsumerState { child: Stack( children: [ Positioned( - bottom: 25, + bottom: 37, left: 16, right: 16, child: Column(