From 39231d5ca4d0b2baa7b2b7e7e22ec3d9aed18d64 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Wed, 15 Apr 2026 16:50:35 +0530 Subject: [PATCH] refactor: dynamicize agent profile section labels using provider-based slug mapping --- .../providers/agent_detail_provider.dart | 16 +++++++++ .../screens/agent_detail_screen.dart | 36 ++++++++++--------- .../screens/agent_home_screen.dart | 22 ++++++------ 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/lib/features/agents/presentation/providers/agent_detail_provider.dart b/lib/features/agents/presentation/providers/agent_detail_provider.dart index d829753..4b1be7d 100644 --- a/lib/features/agents/presentation/providers/agent_detail_provider.dart +++ b/lib/features/agents/presentation/providers/agent_detail_provider.dart @@ -312,6 +312,22 @@ class AgentDetailState { String get bestExperienceLabel => _labelForSlug('best_experience', 'Best Experience'); + // Experience section labels (matches web mapFieldValuesToExperience) + String get yearsInExperienceLabel => + _labelForSlug('years_in_business', 'Years in Experience'); + + String get contractsClosedLabel => + _labelForSlug('contracts_completed', 'Number of contracts closed'); + + String get licensingAreasLabel => + _labelForSlug('licensed_areas', 'Licensing & Areas'); + + String get expertiseYearsLabel => + _labelForSlug('expertise_areas', 'Areas in expertise & Years'); + + String get certificationsLabel => + _labelForSlug('certification_entries', 'Certifications'); + // ── Availability ── String get availabilityType { diff --git a/lib/features/agents/presentation/screens/agent_detail_screen.dart b/lib/features/agents/presentation/screens/agent_detail_screen.dart index 516b65f..78b87ca 100644 --- a/lib/features/agents/presentation/screens/agent_detail_screen.dart +++ b/lib/features/agents/presentation/screens/agent_detail_screen.dart @@ -831,25 +831,25 @@ class _AgentDetailScreenState extends ConsumerState { ), const SizedBox(height: 22), // Years (always show, matching web) - _buildExperienceItem('Years in Experience', [ + _buildExperienceItem(state.yearsInExperienceLabel, [ state.yearsInExperience, ]), // Contracts (always show, matching web) - _buildExperienceItem('Number of contracts closed', [ + _buildExperienceItem(state.contractsClosedLabel, [ state.contractsClosed, ]), // Licensing Areas (always show) state.licensingAreas.isNotEmpty - ? _buildLicensingAreas(state.licensingAreas) - : _buildEmptySection('Licensing & Areas', 'No licensed areas added'), + ? _buildLicensingAreas(state.licensingAreas, state.licensingAreasLabel) + : _buildEmptySection(state.licensingAreasLabel, 'No licensed areas added'), // Expertise Years (always show) state.expertiseYears.isNotEmpty - ? _buildExpertiseYears(state.expertiseYears) - : _buildEmptySection('Areas in expertise & Years', 'No expertise areas added'), + ? _buildExpertiseYears(state.expertiseYears, state.expertiseYearsLabel) + : _buildEmptySection(state.expertiseYearsLabel, 'No expertise areas added'), // Certifications (always show) state.certifications.isNotEmpty - ? _buildCertifications(state.certifications) - : _buildEmptySection('Certifications', 'No certifications added'), + ? _buildCertifications(state.certifications, state.certificationsLabel) + : _buildEmptySection(state.certificationsLabel, 'No certifications added'), ], ), ); @@ -948,28 +948,28 @@ class _AgentDetailScreenState extends ConsumerState { ); } - Widget _buildLicensingAreas(List areas) { + Widget _buildLicensingAreas(List areas, String label) { return _ExpandableChipsSection( - title: 'Licensing & Areas', + title: label, items: areas, initialCount: 6, ); } - Widget _buildExpertiseYears(List> items) { + Widget _buildExpertiseYears(List> items, String label) { final chips = items.map((e) { final years = e['years'] ?? ''; return years.isNotEmpty ? '${e['area']} – $years' : e['area'] ?? ''; }).toList(); return _ExpandableChipsSection( - title: 'Areas in expertise & Years', + title: label, items: chips, initialCount: 4, ); } - Widget _buildCertifications(List> certs) { - return _ExpandableCertificationsSection(certs: certs); + Widget _buildCertifications(List> certs, String label) { + return _ExpandableCertificationsSection(certs: certs, title: label); } // ── Info Cards (Availability, Work Env, Best Experience) ── @@ -1427,10 +1427,12 @@ class _ExpandableChipsSectionState extends State<_ExpandableChipsSection> { class _ExpandableCertificationsSection extends StatefulWidget { final List> certs; + final String title; final int initialCount; const _ExpandableCertificationsSection({ required this.certs, + required this.title, this.initialCount = 2, }); @@ -1453,9 +1455,9 @@ class _ExpandableCertificationsSectionState return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( - 'Certifications', - style: TextStyle( + Text( + widget.title, + style: const TextStyle( fontFamily: 'Fractul', fontSize: 14, fontWeight: FontWeight.w700, diff --git a/lib/features/agents/presentation/screens/agent_home_screen.dart b/lib/features/agents/presentation/screens/agent_home_screen.dart index de3f3ed..872bcda 100644 --- a/lib/features/agents/presentation/screens/agent_home_screen.dart +++ b/lib/features/agents/presentation/screens/agent_home_screen.dart @@ -834,16 +834,16 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> { color: AppColors.primaryDark)), const SizedBox(height: 16), _buildExperienceRow( - 'Years in Experience', state.yearsInExperience), + state.yearsInExperienceLabel, state.yearsInExperience), const Divider(height: 24, thickness: 0.2), _buildExperienceRow( - 'Number of contract closed', state.contractsClosed), + state.contractsClosedLabel, state.contractsClosed), const Divider(height: 24, thickness: 0.2), if (state.licensingAreas.isNotEmpty) ...[ - const Align( + Align( alignment: Alignment.centerLeft, - child: Text('Licensing & Areas', - style: TextStyle( + child: Text(state.licensingAreasLabel, + style: const TextStyle( fontFamily: 'Fractul', fontSize: 14, fontWeight: FontWeight.w700, @@ -854,10 +854,10 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> { const SizedBox(height: 16), ], if (state.expertiseYears.isNotEmpty) ...[ - const Align( + Align( alignment: Alignment.centerLeft, - child: Text('Areas in expertise & Years', - style: TextStyle( + child: Text(state.expertiseYearsLabel, + style: const TextStyle( fontFamily: 'Fractul', fontSize: 14, fontWeight: FontWeight.w700, @@ -872,10 +872,10 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> { ], if (state.certifications.isNotEmpty) ...[ const SizedBox(height: 16), - const Align( + Align( alignment: Alignment.centerLeft, - child: Text('Certifications', - style: TextStyle( + child: Text(state.certificationsLabel, + style: const TextStyle( fontFamily: 'Fractul', fontSize: 14, fontWeight: FontWeight.w700,