From 2198cae0273ed1f19e34f28bb27a6bf2c59616d1 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Sat, 14 Mar 2026 23:41:50 +0530 Subject: [PATCH] feat: Always display agent experience, specialization, and info card sections on the agent detail screen, showing empty states when data is unavailable. --- .../screens/agent_detail_screen.dart | 170 +++++++++++------- 1 file changed, 109 insertions(+), 61 deletions(-) diff --git a/lib/features/agents/presentation/screens/agent_detail_screen.dart b/lib/features/agents/presentation/screens/agent_detail_screen.dart index 1aadb11..87f9fc4 100644 --- a/lib/features/agents/presentation/screens/agent_detail_screen.dart +++ b/lib/features/agents/presentation/screens/agent_detail_screen.dart @@ -111,21 +111,17 @@ class _AgentDetailScreenState extends ConsumerState { 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 { } // ── 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 { _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 { ); } + 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 areas) { return _ExpandableChipsSection( title: 'Licensing & Areas', @@ -859,32 +887,36 @@ class _AgentDetailScreenState extends ConsumerState { 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 { required String subtitle, List? items, String? description, + bool isEmpty = false, }) { return Container( width: double.infinity, @@ -932,11 +965,13 @@ class _AgentDetailScreenState extends ConsumerState { 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 { 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 { ), ), 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), + ), ), - ), ], ), );