feat: Implement expandable tag sections with "Show More/Less" functionality on the agent home screen.

This commit is contained in:
pradeepkumar
2026-03-15 00:41:31 +05:30
parent 21f669fca5
commit b7f131c677
4 changed files with 59 additions and 19 deletions

View File

@@ -89,6 +89,7 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
bool _isTogglingAvailability = false;
bool _showEmail = false;
bool _showPhone = false;
final Set<String> _expandedTagSections = {};
File? _localAvatarFile;
Future<void> _pickAndUploadAvatar() async {
@@ -729,7 +730,7 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
color: AppColors.primaryDark)),
),
const SizedBox(height: 8),
_buildTagsWrap(state.licensingAreas),
_buildTagsWrap(state.licensingAreas, sectionKey: 'licensing'),
const SizedBox(height: 16),
],
if (state.expertiseYears.isNotEmpty) ...[
@@ -747,7 +748,7 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
.map((e) => e['years']!.isNotEmpty
? '${e['area']} ${e['years']}'
: e['area']!)
.toList()),
.toList(), sectionKey: 'expertise'),
],
if (state.certifications.isNotEmpty) ...[
const SizedBox(height: 16),
@@ -833,8 +834,9 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
);
}
Widget _buildTagsWrap(List<String> tags) {
final displayTags = tags.take(6).toList();
Widget _buildTagsWrap(List<String> tags, {required String sectionKey}) {
final isExpanded = _expandedTagSections.contains(sectionKey);
final displayTags = isExpanded ? tags : tags.take(6).toList();
final remaining = tags.length - 6;
return Wrap(
@@ -857,19 +859,32 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
color: AppColors.primaryDark)),
)),
if (remaining > 0)
Container(
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
border: Border.all(color: AppColors.primaryDark, width: 0.1),
GestureDetector(
onTap: () {
setState(() {
if (isExpanded) {
_expandedTagSections.remove(sectionKey);
} else {
_expandedTagSections.add(sectionKey);
}
});
},
behavior: HitTestBehavior.opaque,
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
border: Border.all(color: AppColors.primaryDark, width: 0.1),
),
child: Text(
isExpanded ? 'Show Less' : '+$remaining More',
style: const TextStyle(
fontFamily: 'SourceSerif4',
fontSize: 15,
fontWeight: FontWeight.w300,
color: AppColors.primaryDark)),
),
child: Text('+$remaining More',
style: const TextStyle(
fontFamily: 'SourceSerif4',
fontSize: 15,
fontWeight: FontWeight.w300,
color: AppColors.primaryDark)),
),
],
);