refactor: dynamicize agent profile section labels using provider-based slug mapping

This commit is contained in:
pradeepkumar
2026-04-15 16:50:35 +05:30
parent 4bab9c06a7
commit 39231d5ca4
3 changed files with 46 additions and 28 deletions

View File

@@ -312,6 +312,22 @@ class AgentDetailState {
String get bestExperienceLabel => String get bestExperienceLabel =>
_labelForSlug('best_experience', 'Best Experience'); _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 ── // ── Availability ──
String get availabilityType { String get availabilityType {

View File

@@ -831,25 +831,25 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
), ),
const SizedBox(height: 22), const SizedBox(height: 22),
// Years (always show, matching web) // Years (always show, matching web)
_buildExperienceItem('Years in Experience', [ _buildExperienceItem(state.yearsInExperienceLabel, [
state.yearsInExperience, state.yearsInExperience,
]), ]),
// Contracts (always show, matching web) // Contracts (always show, matching web)
_buildExperienceItem('Number of contracts closed', [ _buildExperienceItem(state.contractsClosedLabel, [
state.contractsClosed, state.contractsClosed,
]), ]),
// Licensing Areas (always show) // Licensing Areas (always show)
state.licensingAreas.isNotEmpty state.licensingAreas.isNotEmpty
? _buildLicensingAreas(state.licensingAreas) ? _buildLicensingAreas(state.licensingAreas, state.licensingAreasLabel)
: _buildEmptySection('Licensing & Areas', 'No licensed areas added'), : _buildEmptySection(state.licensingAreasLabel, 'No licensed areas added'),
// Expertise Years (always show) // Expertise Years (always show)
state.expertiseYears.isNotEmpty state.expertiseYears.isNotEmpty
? _buildExpertiseYears(state.expertiseYears) ? _buildExpertiseYears(state.expertiseYears, state.expertiseYearsLabel)
: _buildEmptySection('Areas in expertise & Years', 'No expertise areas added'), : _buildEmptySection(state.expertiseYearsLabel, 'No expertise areas added'),
// Certifications (always show) // Certifications (always show)
state.certifications.isNotEmpty state.certifications.isNotEmpty
? _buildCertifications(state.certifications) ? _buildCertifications(state.certifications, state.certificationsLabel)
: _buildEmptySection('Certifications', 'No certifications added'), : _buildEmptySection(state.certificationsLabel, 'No certifications added'),
], ],
), ),
); );
@@ -948,28 +948,28 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
); );
} }
Widget _buildLicensingAreas(List<String> areas) { Widget _buildLicensingAreas(List<String> areas, String label) {
return _ExpandableChipsSection( return _ExpandableChipsSection(
title: 'Licensing & Areas', title: label,
items: areas, items: areas,
initialCount: 6, initialCount: 6,
); );
} }
Widget _buildExpertiseYears(List<Map<String, String>> items) { Widget _buildExpertiseYears(List<Map<String, String>> items, String label) {
final chips = items.map((e) { final chips = items.map((e) {
final years = e['years'] ?? ''; final years = e['years'] ?? '';
return years.isNotEmpty ? '${e['area']} $years' : e['area'] ?? ''; return years.isNotEmpty ? '${e['area']} $years' : e['area'] ?? '';
}).toList(); }).toList();
return _ExpandableChipsSection( return _ExpandableChipsSection(
title: 'Areas in expertise & Years', title: label,
items: chips, items: chips,
initialCount: 4, initialCount: 4,
); );
} }
Widget _buildCertifications(List<Map<String, String>> certs) { Widget _buildCertifications(List<Map<String, String>> certs, String label) {
return _ExpandableCertificationsSection(certs: certs); return _ExpandableCertificationsSection(certs: certs, title: label);
} }
// ── Info Cards (Availability, Work Env, Best Experience) ── // ── Info Cards (Availability, Work Env, Best Experience) ──
@@ -1427,10 +1427,12 @@ class _ExpandableChipsSectionState extends State<_ExpandableChipsSection> {
class _ExpandableCertificationsSection extends StatefulWidget { class _ExpandableCertificationsSection extends StatefulWidget {
final List<Map<String, String>> certs; final List<Map<String, String>> certs;
final String title;
final int initialCount; final int initialCount;
const _ExpandableCertificationsSection({ const _ExpandableCertificationsSection({
required this.certs, required this.certs,
required this.title,
this.initialCount = 2, this.initialCount = 2,
}); });
@@ -1453,9 +1455,9 @@ class _ExpandableCertificationsSectionState
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Text( Text(
'Certifications', widget.title,
style: TextStyle( style: const TextStyle(
fontFamily: 'Fractul', fontFamily: 'Fractul',
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,

View File

@@ -834,16 +834,16 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
color: AppColors.primaryDark)), color: AppColors.primaryDark)),
const SizedBox(height: 16), const SizedBox(height: 16),
_buildExperienceRow( _buildExperienceRow(
'Years in Experience', state.yearsInExperience), state.yearsInExperienceLabel, state.yearsInExperience),
const Divider(height: 24, thickness: 0.2), const Divider(height: 24, thickness: 0.2),
_buildExperienceRow( _buildExperienceRow(
'Number of contract closed', state.contractsClosed), state.contractsClosedLabel, state.contractsClosed),
const Divider(height: 24, thickness: 0.2), const Divider(height: 24, thickness: 0.2),
if (state.licensingAreas.isNotEmpty) ...[ if (state.licensingAreas.isNotEmpty) ...[
const Align( Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text('Licensing & Areas', child: Text(state.licensingAreasLabel,
style: TextStyle( style: const TextStyle(
fontFamily: 'Fractul', fontFamily: 'Fractul',
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
@@ -854,10 +854,10 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
const SizedBox(height: 16), const SizedBox(height: 16),
], ],
if (state.expertiseYears.isNotEmpty) ...[ if (state.expertiseYears.isNotEmpty) ...[
const Align( Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text('Areas in expertise & Years', child: Text(state.expertiseYearsLabel,
style: TextStyle( style: const TextStyle(
fontFamily: 'Fractul', fontFamily: 'Fractul',
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
@@ -872,10 +872,10 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
], ],
if (state.certifications.isNotEmpty) ...[ if (state.certifications.isNotEmpty) ...[
const SizedBox(height: 16), const SizedBox(height: 16),
const Align( Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text('Certifications', child: Text(state.certificationsLabel,
style: TextStyle( style: const TextStyle(
fontFamily: 'Fractul', fontFamily: 'Fractul',
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,