From 74d53dbed3e97c3f223327ce1ff229fdf54f483a Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Sat, 28 Mar 2026 20:08:28 +0530 Subject: [PATCH] feat: add matchPercentage field to AgentProfile and display match badge in agent search results --- .../agents/data/models/agent_profile.dart | 3 +++ .../screens/agent_search_screen.dart | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/features/agents/data/models/agent_profile.dart b/lib/features/agents/data/models/agent_profile.dart index eacc476..4a497f0 100644 --- a/lib/features/agents/data/models/agent_profile.dart +++ b/lib/features/agents/data/models/agent_profile.dart @@ -30,6 +30,7 @@ class AgentProfile { final List legacySpecializations; final List languages; final List serviceAreas; + final int? matchPercentage; const AgentProfile({ required this.id, @@ -61,6 +62,7 @@ class AgentProfile { this.legacySpecializations = const [], this.languages = const [], this.serviceAreas = const [], + this.matchPercentage, }); String get fullName => '$firstName $lastName'.trim(); @@ -279,6 +281,7 @@ class AgentProfile { ?.map((e) => e.toString()) .toList() ?? const [], + matchPercentage: json['matchPercentage'] as int?, ); } } diff --git a/lib/features/agents/presentation/screens/agent_search_screen.dart b/lib/features/agents/presentation/screens/agent_search_screen.dart index e5fbea8..ece52a0 100644 --- a/lib/features/agents/presentation/screens/agent_search_screen.dart +++ b/lib/features/agents/presentation/screens/agent_search_screen.dart @@ -528,6 +528,30 @@ class _AgentCardState extends State<_AgentCard> { ), ), ], + // Match badge + if (agent.matchPercentage != null) ...[ + const SizedBox(width: 8), + Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + decoration: BoxDecoration( + color: agent.matchPercentage! >= 80 + ? const Color(0xFF638559) + : agent.matchPercentage! >= 65 + ? const Color(0xFF7D917D) + : AppColors.primaryDark.withValues(alpha: 0.6), + borderRadius: BorderRadius.circular(20), + ), + child: Text( + '${agent.matchPercentage}% Match', + style: const TextStyle( + fontFamily: 'SourceSerif4', + fontSize: 12, + fontWeight: FontWeight.w500, + color: Colors.white, + ), + ), + ), + ], ], ), const SizedBox(height: 4),