From 0f49b21f33ace3da447e513ed5c42ab7f3c93d61 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Fri, 24 Apr 2026 12:50:49 +0530 Subject: [PATCH] feat: add unlink confirmation dialog, enable agent navigation, update notification read status UI, and increment app version --- .../screens/agent_detail_screen.dart | 51 ++++++++++++++++++- .../widgets/features_section.dart | 18 ++++++- .../screens/notifications_screen.dart | 44 +++++++++------- pubspec.yaml | 2 +- 4 files changed, 93 insertions(+), 22 deletions(-) diff --git a/lib/features/agents/presentation/screens/agent_detail_screen.dart b/lib/features/agents/presentation/screens/agent_detail_screen.dart index 9820041..dc2444d 100644 --- a/lib/features/agents/presentation/screens/agent_detail_screen.dart +++ b/lib/features/agents/presentation/screens/agent_detail_screen.dart @@ -448,12 +448,61 @@ class _AgentDetailScreenState extends ConsumerState { return; } if (state.connectionState == 'accepted') { - ref.read(agentDetailProvider(widget.agentId).notifier).cancelConnection(); + _showUnlinkConfirmation(state); return; } _showConnectModal(state); } + void _showUnlinkConfirmation(AgentDetailState state) { + final agentName = state.agent?.fullName ?? 'this agent'; + showDialog( + context: context, + builder: (ctx) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + title: const Text( + 'Unlink Agent', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Color(0xFF00293d), + ), + ), + content: Text( + 'Are you sure you want to unlink $agentName? You will need to send a new connection request to reconnect.', + style: const TextStyle(fontSize: 14, color: Color(0xFF4B5563)), + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(ctx).pop(), + child: const Text( + 'Cancel', + style: TextStyle(color: Color(0xFF6B7280)), + ), + ), + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFFE58625), + foregroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + onPressed: () { + Navigator.of(ctx).pop(); + ref + .read(agentDetailProvider(widget.agentId).notifier) + .cancelConnection(); + }, + child: const Text('Unlink'), + ), + ], + ), + ); + } + void _showConnectModal(AgentDetailState state) { final controller = TextEditingController(); showModalBottomSheet( diff --git a/lib/features/home/presentation/widgets/features_section.dart b/lib/features/home/presentation/widgets/features_section.dart index ff7aa49..72489f2 100644 --- a/lib/features/home/presentation/widgets/features_section.dart +++ b/lib/features/home/presentation/widgets/features_section.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:go_router/go_router.dart'; import 'package:real_estate_mobile/core/constants/app_colors.dart'; import 'package:real_estate_mobile/core/network/api_client.dart'; import 'package:real_estate_mobile/core/utils/image_url_resolver.dart'; @@ -84,6 +85,7 @@ const _staticAgents = [ ]; class _StaticAgent { + final String id; final String name; final String role; final String rating; @@ -93,6 +95,7 @@ class _StaticAgent { final bool isVerified; const _StaticAgent({ + this.id = '', required this.name, required this.role, required this.rating, @@ -154,6 +157,7 @@ class _FeaturesSectionState extends ConsumerState { } fetched.add(_StaticAgent( + id: agent['id'] as String? ?? '', name: agent['name'] as String? ?? '', role: agent['role'] as String? ?? '', rating: agent['rating'] as String? ?? '', @@ -335,7 +339,7 @@ class _FeaturesSectionState extends ConsumerState { } Widget _buildStaticAgentCard(_StaticAgent agent) { - return Container( + final card = Container( width: 254, decoration: BoxDecoration( color: Colors.white, @@ -530,5 +534,17 @@ class _FeaturesSectionState extends ConsumerState { ], ), ); + + if (agent.id.isNotEmpty) { + return Material( + color: Colors.transparent, + child: InkWell( + borderRadius: BorderRadius.circular(15), + onTap: () => context.push('/agents/detail/${agent.id}'), + child: card, + ), + ); + } + return card; } } diff --git a/lib/features/notifications/presentation/screens/notifications_screen.dart b/lib/features/notifications/presentation/screens/notifications_screen.dart index 5bf342b..e76c70d 100644 --- a/lib/features/notifications/presentation/screens/notifications_screen.dart +++ b/lib/features/notifications/presentation/screens/notifications_screen.dart @@ -93,26 +93,32 @@ class _NotificationsScreenState extends ConsumerState { return _buildFilterChip(label, 'unread'); }), const Spacer(), - GestureDetector( - onTap: () async { - await ref - .read(notificationListProvider.notifier) - .markAllAsRead(); - // Reload current filter to reflect changes - ref - .read(notificationListProvider.notifier) - .loadNotifications(filter: _activeFilter); - }, - child: const Text( - 'Mark all as read', - style: TextStyle( - fontFamily: 'SourceSerif4', - fontSize: 13, - fontWeight: FontWeight.w400, - color: AppColors.accentOrange, + Builder(builder: (context) { + final hasUnread = ref.watch(unreadCountProvider) > 0; + return GestureDetector( + onTap: hasUnread + ? () async { + await ref + .read(notificationListProvider.notifier) + .markAllAsRead(); + ref + .read(notificationListProvider.notifier) + .loadNotifications(filter: _activeFilter); + } + : null, + child: Text( + 'Mark all as read', + style: TextStyle( + fontFamily: 'SourceSerif4', + fontSize: 13, + fontWeight: FontWeight.w400, + color: hasUnread + ? AppColors.accentOrange + : AppColors.accentOrange.withValues(alpha: 0.4), + ), ), - ), - ), + ); + }), ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index f4be125..0cb290c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: real_estate_mobile description: "RE-Quest Real Estate Mobile App" publish_to: 'none' -version: 1.0.0+2 +version: 1.0.0+3 environment: sdk: ^3.10.1