From 8ccf26d99b32347f76375e49204a769dd7810452 Mon Sep 17 00:00:00 2001 From: venbaittech Date: Thu, 20 Mar 2025 18:24:00 +0530 Subject: [PATCH] notification and chart bug fix --- android/app/build.gradle | 4 +-- lib/config/my_router.dart | 8 +++++ .../auth_verification/forgot_password.dart | 10 +++---- .../Screens/charts/widgets/chart_widget.dart | 19 +++++++----- .../notification/notification.dart | 30 ++++++++++++------- pubspec.yaml | 2 +- 6 files changed, 47 insertions(+), 26 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 73ce6d94..308dea91 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -20,12 +20,12 @@ if (project.hasProperty('google-services.json')) { def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = "40" + flutterVersionCode = "41" } def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = "1.0.39" + flutterVersionName = "1.0.40" } def keystorePropertiesFile = rootProject.file("key.properties") diff --git a/lib/config/my_router.dart b/lib/config/my_router.dart index 855366ba..23a8dff9 100644 --- a/lib/config/my_router.dart +++ b/lib/config/my_router.dart @@ -302,6 +302,7 @@ import 'package:uae_stat/domain/entities/session_entity.dart'; import 'package:uae_stat/infrastructure/data/p_auth_repo.dart'; import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/UAE_Numbers/Social/marriages.dart'; import 'package:uae_stat/presentation/Screens/app_tour/WelcomePage.dart'; +import 'package:uae_stat/presentation/Screens/auth_verification/forgot_password.dart'; import 'package:uae_stat/presentation/Screens/auth_verification/privacy_policy.dart'; import 'package:uae_stat/presentation/Screens/auth_verification/registration.dart'; import 'package:uae_stat/presentation/Screens/auth_verification/terms&conditions.dart'; @@ -478,6 +479,13 @@ final GoRouter router = GoRouter( return Changepassword(userId: userId); }, ), + GoRoute( + path: '/forgot-password/:email', + builder: (context, state) { + final email = state.pathParameters['email']!; + return ForgotPassword(email: email); + }, + ), GoRoute( path: '/createNewPw/:userId/:email', builder: (context, state) { diff --git a/lib/presentation/Screens/auth_verification/forgot_password.dart b/lib/presentation/Screens/auth_verification/forgot_password.dart index 42745bb5..82cc12bd 100644 --- a/lib/presentation/Screens/auth_verification/forgot_password.dart +++ b/lib/presentation/Screens/auth_verification/forgot_password.dart @@ -20,9 +20,9 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:uae_stat/config/my_theme.dart'; class ForgotPassword extends ConsumerStatefulWidget { - final String userId; + final String email; - const ForgotPassword({Key? key, required this.userId}); + const ForgotPassword({Key? key, required this.email}); @override ConsumerState createState() => _ForgotPasswordState(); @@ -108,7 +108,7 @@ class _ForgotPasswordState extends ConsumerState { } Future updatePassword( - String userId, String oldPassword, String newPassword) async { + String email, String oldPassword, String newPassword) async { try { setState(() { isLoading = true; @@ -124,7 +124,7 @@ class _ForgotPasswordState extends ConsumerState { // Update password await _pb.collection('users').update( - userId, + email, body: { 'password': newPassword, 'passwordConfirm': newPassword, @@ -482,7 +482,7 @@ class _ForgotPasswordState extends ConsumerState { }); if ((_formKey.currentState?.validate() ?? false)) { await updatePassword( - widget.userId, + widget.email, _oldPassword ?? '', _newPassword ?? '', ); diff --git a/lib/presentation/Screens/charts/widgets/chart_widget.dart b/lib/presentation/Screens/charts/widgets/chart_widget.dart index 5baa6805..bcf5bc46 100644 --- a/lib/presentation/Screens/charts/widgets/chart_widget.dart +++ b/lib/presentation/Screens/charts/widgets/chart_widget.dart @@ -319,8 +319,9 @@ class ChartWidget extends StatelessWidget { // color: Colors.primaries[index % Colors.primaries.length], // color: adjustColor(bodyColor, index), // Adjust alpha dynamically color: uniqueColors[index % uniqueColors.length], - title: '${percentage.toStringAsFixed(1)}%', - radius: isTouched ? 60 : 50, + // title: '${percentage.toStringAsFixed(1)}%', + title: percentage > 1 ? '${percentage.toStringAsFixed(1)}%' : '', + radius: isTouched ? 70 : 50, // Increase size when touched titleStyle: TextStyle( @@ -329,7 +330,7 @@ class ChartWidget extends StatelessWidget { color: Colors.black, // color: Colors.white, ), - titlePositionPercentageOffset: 1.3, + titlePositionPercentageOffset: 1.4, ); }).toList(); } @@ -1624,7 +1625,7 @@ class ChartWidget extends StatelessWidget { displayTitle, softWrap: true, textAlign: - TextAlign.end, + TextAlign.right, style: TextStyle( fontSize: 10, ), @@ -2045,7 +2046,7 @@ class ChartWidget extends StatelessWidget { title, softWrap: true, maxLines: 2, - textAlign: TextAlign.end, + textAlign: TextAlign.right, style: TextStyle(fontSize: 10), // overflow: TextOverflow.ellipsis, )), @@ -2334,8 +2335,8 @@ class ChartWidget extends StatelessWidget { // ); return BarTooltipItem( - '$formattedValue', // This is your main tooltip text - + ' $formattedValue', // This is your main tooltip text + // textAlign: TextAlign.center, const TextStyle( color: Colors.black, fontWeight: FontWeight.w400, @@ -2345,6 +2346,7 @@ class ChartWidget extends StatelessWidget { TextSpan( text: '', // Add extra information here // text: '\n$crop', // Add extra information here + style: TextStyle( color: Colors.grey[ 700], // Optional: Different color for extra text @@ -3014,7 +3016,7 @@ class ChartWidget extends StatelessWidget { // print("Bottomtiles"); // print(value); return Padding( - padding: const EdgeInsets.only(top: 10, left: 20.0), + padding: const EdgeInsets.only(top: 5, left: 20.0), child: SizedBox( width: 40, child: Transform.rotate( @@ -3022,6 +3024,7 @@ class ChartWidget extends StatelessWidget { angle: -1.5, // Slight rotation to improve readability child: Text( value.toInt().toString(), + textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontSize: 12), ), ), 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 99d280aa..6f5411d9 100644 --- a/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart +++ b/lib/presentation/routes/drawer_routes/Drawer Items/notification/notification.dart @@ -25,7 +25,7 @@ class _NotificationPageState extends ConsumerState { final _pb = PocketBase(apiUrl); bool isLoading = true; List> notifications = []; - List pushedNotification = []; + List userReadedNotiOrNot = []; // Current selected tab index int selectedTabIndex = 0; @@ -48,7 +48,6 @@ class _NotificationPageState extends ConsumerState { super.initState(); locale = ref.read(localeProvider) ?? const Locale('en'); _userService = UserService(); - _fetchUserData(); fetchNotifications(locale?.languageCode ?? 'en'); } @@ -75,15 +74,25 @@ class _NotificationPageState extends ConsumerState { setState(() { print('In'); // Extract pushed_notification from response - List notifications = + List userReadedNotification = userDetailsResponse.data['pushed_notification']; // Convert to List - pushedNotification = List.from(notifications); + userReadedNotiOrNot = List.from(userReadedNotification); - print('pushedNotification: $pushedNotification'); + print('userReadedNotiOrNot: $userReadedNotiOrNot'); + print('notifications: $notifications'); + // for (var notification in notifications) { + // notification["isReadedOrNot"] = + // userReadedNotiOrNot.contains(notification["id"]); + // } + // print('After Added: $notifications'); + isLoading = false; }); } catch (e) { + setState(() { + isLoading = false; + }); print('Error fetching user details: $e'); } } @@ -113,7 +122,8 @@ class _NotificationPageState extends ConsumerState { notifications = List>.from( jsonResponse['data']); // Assign decoded data print('notifications $notifications'); - isLoading = false; + _fetchUserData(); + // isLoading = false; }); } else { setState(() { @@ -250,7 +260,7 @@ class _NotificationPageState extends ConsumerState { notification['category'] ?? 'Unknown', message: notification['message'] ?? '', id: notification['id'], - pushedNotification: pushedNotification, + userReadedNotiOrNot: userReadedNotiOrNot, userID: userID, ), ); @@ -329,7 +339,7 @@ class NotificationTile extends StatelessWidget { final String category; final String id; final String userID; - final List pushedNotification; + final List userReadedNotiOrNot; const NotificationTile({ required this.title, @@ -338,12 +348,12 @@ class NotificationTile extends StatelessWidget { required this.category, required this.id, required this.userID, - required this.pushedNotification, + required this.userReadedNotiOrNot, }); @override Widget build(BuildContext context) { - bool isPushed = pushedNotification.contains(id); + bool isPushed = userReadedNotiOrNot.contains(id); print('isPushed $isPushed , $id'); return GestureDetector( diff --git a/pubspec.yaml b/pubspec.yaml index 1144a2f6..f8a4b1ba 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: uae_stat description: "View statistics about the UAE from the Federal Center for Statistics and Competitiveness." publish_to: "none" -version: 1.0.39+40 +version: 1.0.40+41 environment: sdk: ">=3.2.3 <4.0.0"