refactor: convert horizontal wrap chips to full-width vertical stack list in agent screens

This commit is contained in:
pradeepkumar
2026-05-07 11:59:21 +05:30
parent 91f8a1f1a0
commit 2760c14954
3 changed files with 256 additions and 220 deletions

View File

@@ -1297,16 +1297,14 @@ class _ExpandableTagsWrapState extends State<_ExpandableTagsWrap> {
_expanded ? widget.tags : widget.tags.take(widget.initialCount).toList(); _expanded ? widget.tags : widget.tags.take(widget.initialCount).toList();
final hasMore = widget.tags.length > widget.initialCount; final hasMore = widget.tags.length > widget.initialCount;
// Each chip fills the row width so all chips share the same left edge.
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Wrap( for (int i = 0; i < displayTags.length; i++) ...[
alignment: WrapAlignment.center, if (i > 0) const SizedBox(height: 8),
spacing: 8, Container(
runSpacing: 8, padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
children: displayTags
.map((tag) => Container(
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
border: Border.all( border: Border.all(
@@ -1315,7 +1313,8 @@ class _ExpandableTagsWrapState extends State<_ExpandableTagsWrap> {
), ),
), ),
child: Text( child: Text(
tag, displayTags[i],
softWrap: true,
style: const TextStyle( style: const TextStyle(
fontFamily: 'SourceSerif4', fontFamily: 'SourceSerif4',
fontSize: 14, fontSize: 14,
@@ -1323,28 +1322,45 @@ class _ExpandableTagsWrapState extends State<_ExpandableTagsWrap> {
color: AppColors.primaryDark, color: AppColors.primaryDark,
), ),
), ),
))
.toList(),
), ),
],
if (hasMore) ...[ if (hasMore) ...[
const SizedBox(height: 10), const SizedBox(height: 10),
GestureDetector( Align(
alignment: Alignment.center,
child: GestureDetector(
onTap: () => setState(() => _expanded = !_expanded), onTap: () => setState(() => _expanded = !_expanded),
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
border: Border.all(color: AppColors.accentOrange, width: 0.7), border:
Border.all(color: AppColors.accentOrange, width: 1),
), ),
child: Text( child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
_expanded ? 'Show Less' : 'Show More', _expanded ? 'Show Less' : 'Show More',
style: const TextStyle( style: const TextStyle(
fontFamily: 'SourceSerif4', fontFamily: 'SourceSerif4',
fontSize: 10, fontSize: 12,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
color: AppColors.accentOrange, color: AppColors.accentOrange,
), ),
), ),
const SizedBox(width: 4),
Icon(
_expanded
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
size: 14,
color: AppColors.accentOrange,
),
],
),
),
), ),
), ),
], ],
@@ -1380,7 +1396,7 @@ class _ExpandableChipsSectionState extends State<_ExpandableChipsSection> {
final hasMore = widget.items.length > widget.initialCount; final hasMore = widget.items.length > widget.initialCount;
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Text( Text(
widget.title, widget.title,
@@ -1392,16 +1408,11 @@ class _ExpandableChipsSectionState extends State<_ExpandableChipsSection> {
), ),
), ),
const SizedBox(height: 14), const SizedBox(height: 14),
Wrap( // Each chip fills the row so all start at the same left edge.
spacing: 10, for (int i = 0; i < showItems.length; i++) ...[
runSpacing: 10, if (i > 0) const SizedBox(height: 10),
children: [ Container(
...showItems.map( padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
(item) => IntrinsicWidth(
child: Container(
height: 28,
padding: const EdgeInsets.symmetric(horizontal: 10),
alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
border: Border.all( border: Border.all(
@@ -1410,7 +1421,8 @@ class _ExpandableChipsSectionState extends State<_ExpandableChipsSection> {
), ),
), ),
child: Text( child: Text(
item, showItems[i],
softWrap: true,
style: const TextStyle( style: const TextStyle(
fontFamily: 'SourceSerif4', fontFamily: 'SourceSerif4',
fontSize: 14, fontSize: 14,
@@ -1419,16 +1431,16 @@ class _ExpandableChipsSectionState extends State<_ExpandableChipsSection> {
), ),
), ),
), ),
), ],
), if (hasMore || _expanded) ...[
if (hasMore || _expanded) const SizedBox(height: 10),
GestureDetector( Align(
onTap: () => setState(() => _expanded = !_expanded),
child: IntrinsicWidth(
child: Container(
height: 28,
padding: const EdgeInsets.symmetric(horizontal: 10),
alignment: Alignment.center, alignment: Alignment.center,
child: GestureDetector(
onTap: () => setState(() => _expanded = !_expanded),
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
border: Border.all( border: Border.all(
@@ -1447,30 +1459,29 @@ class _ExpandableChipsSectionState extends State<_ExpandableChipsSection> {
: '+${widget.items.length - widget.initialCount} More', : '+${widget.items.length - widget.initialCount} More',
style: TextStyle( style: TextStyle(
fontFamily: 'SourceSerif4', fontFamily: 'SourceSerif4',
fontSize: _expanded ? 13 : 15, fontSize: _expanded ? 13 : 13,
fontWeight: _expanded fontWeight: FontWeight.w700,
? FontWeight.w700
: FontWeight.w300,
color: _expanded color: _expanded
? AppColors.accentOrange ? AppColors.accentOrange
: AppColors.primaryDark, : AppColors.primaryDark,
), ),
), ),
if (_expanded) ...[ const SizedBox(width: 4),
const SizedBox(width: 2), Icon(
const Icon( _expanded
Icons.keyboard_arrow_up, ? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
size: 14, size: 14,
color: AppColors.accentOrange, color: _expanded
? AppColors.accentOrange
: AppColors.primaryDark,
), ),
], ],
],
), ),
), ),
), ),
), ),
], ],
),
const SizedBox(height: 14), const SizedBox(height: 14),
Divider( Divider(
color: AppColors.primaryDark.withValues(alpha: 0.15), color: AppColors.primaryDark.withValues(alpha: 0.15),

View File

@@ -969,7 +969,11 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
color: AppColors.primaryDark)), color: AppColors.primaryDark)),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
_buildTagsWrap( // Force chips to fill the row so every chip starts at the same
// left edge — prevents short chips from appearing centered.
SizedBox(
width: double.infinity,
child: _buildTagsWrap(
state.expertiseYears state.expertiseYears
.map((e) => e['years']!.isNotEmpty .map((e) => e['years']!.isNotEmpty
? '${e['area']} ${e['years']}' ? '${e['area']} ${e['years']}'
@@ -978,6 +982,7 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
sectionKey: 'expertise', sectionKey: 'expertise',
initialCount: 4, initialCount: 4,
), ),
),
], ],
if (state.certifications.isNotEmpty) ...[ if (state.certifications.isNotEmpty) ...[
const SizedBox(height: 16), const SizedBox(height: 16),
@@ -1113,29 +1118,23 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
isExpanded ? tags : tags.take(initialCount).toList(); isExpanded ? tags : tags.take(initialCount).toList();
final remaining = tags.length - initialCount; final remaining = tags.length - initialCount;
// Cap each chip's width so long taglines wrap inside the chip instead // Each chip fills the full row width so all chips start at the same
// of overflowing the Wrap's row and clipping behind ancestor bounds. // left edge regardless of text length. Long text wraps inside the chip.
return LayoutBuilder( return Column(
builder: (ctx, constraints) { crossAxisAlignment: CrossAxisAlignment.stretch,
final maxChipWidth = constraints.maxWidth.isFinite
? constraints.maxWidth
: MediaQuery.of(ctx).size.width - 32;
return Wrap(
spacing: 8,
runSpacing: 8,
children: [ children: [
...displayTags.map((tag) => ConstrainedBox( for (int i = 0; i < displayTags.length; i++) ...[
constraints: BoxConstraints(maxWidth: maxChipWidth), if (i > 0) const SizedBox(height: 8),
child: Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 6), horizontal: 14, vertical: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
border: Border.all( border:
color: AppColors.primaryDark, width: 0.7), Border.all(color: AppColors.primaryDark, width: 0.7),
), ),
child: Text( child: Text(
tag, displayTags[i],
softWrap: true, softWrap: true,
style: const TextStyle( style: const TextStyle(
fontFamily: 'SourceSerif4', fontFamily: 'SourceSerif4',
@@ -1144,9 +1143,12 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
color: AppColors.primaryDark), color: AppColors.primaryDark),
), ),
), ),
)), ],
if (remaining > 0) if (remaining > 0) ...[
GestureDetector( const SizedBox(height: 8),
Align(
alignment: Alignment.center,
child: GestureDetector(
onTap: () { onTap: () {
setState(() { setState(() {
if (isExpanded) { if (isExpanded) {
@@ -1159,24 +1161,38 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Container( child: Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 6), horizontal: 16, vertical: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
border: Border.all( border: Border.all(
color: AppColors.primaryDark, width: 0.1), color: AppColors.accentOrange, width: 1),
), ),
child: Text( child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
isExpanded ? 'Show Less' : '+$remaining More', isExpanded ? 'Show Less' : '+$remaining More',
style: const TextStyle( style: const TextStyle(
fontFamily: 'SourceSerif4', fontFamily: 'SourceSerif4',
fontSize: 15, fontSize: 12,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w600,
color: AppColors.primaryDark)), color: AppColors.accentOrange),
),
const SizedBox(width: 4),
Icon(
isExpanded
? Icons.keyboard_arrow_up
: Icons.keyboard_arrow_down,
size: 14,
color: AppColors.accentOrange,
),
],
),
),
), ),
), ),
], ],
); ],
},
); );
} }

View File

@@ -753,30 +753,36 @@ class _AgentCardState extends State<_AgentCard> {
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
// Expertise tags // Expertise tags — full-width pills, all start at same left edge
if (specializations.isNotEmpty) ...[ if (specializations.isNotEmpty) ...[
Wrap( Builder(builder: (_) {
alignment: WrapAlignment.start, final visible = _tagsExpanded
spacing: 6,
runSpacing: 6,
children: [
...(_tagsExpanded
? specializations ? specializations
: specializations.take(6)) : specializations.take(6).toList();
.map((tag) => _buildTag(tag)), return Column(
if (specializations.length > 6) crossAxisAlignment: CrossAxisAlignment.stretch,
GestureDetector( children: [
onTap: () => for (int i = 0; i < visible.length; i++) ...[
setState(() => _tagsExpanded = !_tagsExpanded), if (i > 0) const SizedBox(height: 6),
_buildTag(visible[i]),
],
if (specializations.length > 6) ...[
const SizedBox(height: 8),
Align(
alignment: Alignment.center,
child: GestureDetector(
onTap: () => setState(
() => _tagsExpanded = !_tagsExpanded),
child: Container( child: Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 5), horizontal: 12, vertical: 5),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
color: AppColors.accentOrange color: AppColors.accentOrange
.withValues(alpha: 0.1), .withValues(alpha: 0.1),
border: Border.all( border: Border.all(
color: AppColors.accentOrange, width: 0.7), color: AppColors.accentOrange,
width: 0.7),
), ),
child: Text( child: Text(
_tagsExpanded _tagsExpanded
@@ -791,8 +797,11 @@ class _AgentCardState extends State<_AgentCard> {
), ),
), ),
), ),
],
), ),
],
],
);
}),
const SizedBox(height: 14), const SizedBox(height: 14),
], ],