refactor: improve error message handling in profile settings and add width constraints to agent tag chips
This commit is contained in:
@@ -1113,54 +1113,70 @@ class _AgentHomeContentState extends ConsumerState<_AgentHomeContent> {
|
||||
isExpanded ? tags : tags.take(initialCount).toList();
|
||||
final remaining = tags.length - initialCount;
|
||||
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
...displayTags.map((tag) => Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
border:
|
||||
Border.all(color: AppColors.primaryDark, width: 0.7),
|
||||
// Cap each chip's width so long taglines wrap inside the chip instead
|
||||
// of overflowing the Wrap's row and clipping behind ancestor bounds.
|
||||
return LayoutBuilder(
|
||||
builder: (ctx, constraints) {
|
||||
final maxChipWidth = constraints.maxWidth.isFinite
|
||||
? constraints.maxWidth
|
||||
: MediaQuery.of(ctx).size.width - 32;
|
||||
return Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
...displayTags.map((tag) => ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: maxChipWidth),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
border: Border.all(
|
||||
color: AppColors.primaryDark, width: 0.7),
|
||||
),
|
||||
child: Text(
|
||||
tag,
|
||||
softWrap: true,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'SourceSerif4',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.primaryDark),
|
||||
),
|
||||
),
|
||||
)),
|
||||
if (remaining > 0)
|
||||
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(tag,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'SourceSerif4',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.primaryDark)),
|
||||
)),
|
||||
if (remaining > 0)
|
||||
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)),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user