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

@@ -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,

View File

@@ -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,