refactor: dynamicize agent profile section labels using provider-based slug mapping
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -831,25 +831,25 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
|
||||
),
|
||||
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<AgentDetailScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLicensingAreas(List<String> areas) {
|
||||
Widget _buildLicensingAreas(List<String> areas, String label) {
|
||||
return _ExpandableChipsSection(
|
||||
title: 'Licensing & Areas',
|
||||
title: label,
|
||||
items: areas,
|
||||
initialCount: 6,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildExpertiseYears(List<Map<String, String>> items) {
|
||||
Widget _buildExpertiseYears(List<Map<String, String>> 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<Map<String, String>> certs) {
|
||||
return _ExpandableCertificationsSection(certs: certs);
|
||||
Widget _buildCertifications(List<Map<String, String>> 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<Map<String, String>> 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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user