feat: Always display agent experience, specialization, and info card sections on the agent detail screen, showing empty states when data is unavailable.

This commit is contained in:
pradeepkumar
2026-03-14 23:41:50 +05:30
parent 04a57dc137
commit 2198cae027

View File

@@ -111,21 +111,17 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
const SizedBox(height: 16),
_buildProfileInfo(agent, state),
// ── Experience Section ──
if (_hasExperience(state)) ...[
const SizedBox(height: 24),
_buildExperienceSection(state),
],
// ── Experience Section (always show, like web) ──
const SizedBox(height: 24),
_buildExperienceSection(state),
// ── Info Cards (Availability, Work Env, Best Experience) ──
const SizedBox(height: 24),
_buildInfoCards(state),
// ── Specialization Section ──
if (state.specializationCards.isNotEmpty) ...[
const SizedBox(height: 24),
_buildSpecializationSection(state),
],
// ── Specialization Section (always show, like web) ──
const SizedBox(height: 24),
_buildSpecializationSection(state),
// ── Testimonials Section ──
if (state.testimonials.isNotEmpty) ...[
@@ -707,13 +703,6 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
}
// ── Experience ──
bool _hasExperience(AgentDetailState s) =>
s.yearsInExperience != '-' ||
s.contractsClosed != '-' ||
s.licensingAreas.isNotEmpty ||
s.expertiseYears.isNotEmpty ||
s.certifications.isNotEmpty;
Widget _buildExperienceSection(AgentDetailState state) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 17),
@@ -740,15 +729,18 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
_buildExperienceItem('Number of contracts closed', [
state.contractsClosed,
]),
// Licensing Areas
if (state.licensingAreas.isNotEmpty)
_buildLicensingAreas(state.licensingAreas),
// Expertise Years
if (state.expertiseYears.isNotEmpty)
_buildExpertiseYears(state.expertiseYears),
// Certifications
if (state.certifications.isNotEmpty)
_buildCertifications(state.certifications),
// Licensing Areas (always show)
state.licensingAreas.isNotEmpty
? _buildLicensingAreas(state.licensingAreas)
: _buildEmptySection('Licensing & Areas', 'No licensed areas added'),
// Expertise Years (always show)
state.expertiseYears.isNotEmpty
? _buildExpertiseYears(state.expertiseYears)
: _buildEmptySection('Areas in expertise & Years', 'No expertise areas added'),
// Certifications (always show)
state.certifications.isNotEmpty
? _buildCertifications(state.certifications)
: _buildEmptySection('Certifications', 'No certifications added'),
],
),
);
@@ -811,6 +803,42 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
);
}
Widget _buildEmptySection(String title, String emptyText) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontFamily: 'Fractul',
fontSize: 14,
fontWeight: FontWeight.w700,
color: AppColors.primaryDark,
),
),
const SizedBox(height: 14),
Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
emptyText,
style: TextStyle(
fontFamily: 'SourceSerif4',
fontSize: 14,
fontWeight: FontWeight.w400,
color: AppColors.primaryDark.withValues(alpha: 0.4),
),
),
),
const SizedBox(height: 16),
Divider(
color: AppColors.primaryDark.withValues(alpha: 0.15),
height: 1,
),
const SizedBox(height: 10),
],
);
}
Widget _buildLicensingAreas(List<String> areas) {
return _ExpandableChipsSection(
title: 'Licensing & Areas',
@@ -859,32 +887,36 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
padding: const EdgeInsets.symmetric(horizontal: 36),
child: Column(
children: [
// Availability card
if (state.availabilityType.isNotEmpty)
_buildInfoCard(
icon: Icons.access_time_filled,
title: 'Availability',
subtitle: state.availabilityType,
items: state.availabilitySchedule,
),
if (workEnv.isNotEmpty) ...[
const SizedBox(height: 16),
_buildInfoCard(
icon: Icons.landscape_outlined,
title: '',
subtitle: '',
description: workEnv,
),
],
if (bestExp.isNotEmpty) ...[
const SizedBox(height: 16),
_buildInfoCard(
icon: Icons.star_rounded,
title: '',
subtitle: '',
description: bestExp,
),
],
// Availability card (always show)
_buildInfoCard(
icon: Icons.access_time_filled,
title: 'Availability',
subtitle: state.availabilityType.isNotEmpty
? state.availabilityType
: 'Not specified',
items: state.availabilitySchedule.isNotEmpty
? state.availabilitySchedule
: null,
isEmpty: state.availabilityType.isEmpty,
),
const SizedBox(height: 16),
// Work environment (always show)
_buildInfoCard(
icon: Icons.landscape_outlined,
title: 'Work Environment',
subtitle: '',
description: workEnv.isNotEmpty ? workEnv : 'Not specified',
isEmpty: workEnv.isEmpty,
),
const SizedBox(height: 16),
// Best experience (always show)
_buildInfoCard(
icon: Icons.star_rounded,
title: 'Best Experience',
subtitle: '',
description: bestExp.isNotEmpty ? bestExp : 'Not specified',
isEmpty: bestExp.isEmpty,
),
],
),
);
@@ -896,6 +928,7 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
required String subtitle,
List<String>? items,
String? description,
bool isEmpty = false,
}) {
return Container(
width: double.infinity,
@@ -932,11 +965,13 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
const SizedBox(height: 2),
Text(
subtitle,
style: const TextStyle(
style: TextStyle(
fontFamily: 'SourceSerif4',
fontSize: 14,
fontWeight: FontWeight.w600,
color: AppColors.primaryDark,
color: isEmpty
? AppColors.primaryDark.withValues(alpha: 0.4)
: AppColors.primaryDark,
),
),
],
@@ -960,11 +995,13 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
const SizedBox(height: 8),
Text(
description,
style: const TextStyle(
style: TextStyle(
fontFamily: 'SourceSerif4',
fontSize: 14,
fontWeight: FontWeight.w600,
color: AppColors.primaryDark,
color: isEmpty
? AppColors.primaryDark.withValues(alpha: 0.4)
: AppColors.primaryDark,
),
textAlign: TextAlign.center,
),
@@ -1002,12 +1039,23 @@ class _AgentDetailScreenState extends ConsumerState<AgentDetailScreen> {
),
),
const SizedBox(height: 16),
...state.specializationCards.map(
(card) => Padding(
padding: const EdgeInsets.only(bottom: 12),
child: _SpecializationCardWidget(card: card),
if (state.specializationCards.isNotEmpty)
...state.specializationCards.map(
(card) => Padding(
padding: const EdgeInsets.only(bottom: 12),
child: _SpecializationCardWidget(card: card),
),
)
else
Text(
'No specialization data added',
style: TextStyle(
fontFamily: 'SourceSerif4',
fontSize: 14,
fontWeight: FontWeight.w400,
color: AppColors.primaryDark.withValues(alpha: 0.4),
),
),
),
],
),
);