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)),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:real_estate_mobile/core/constants/app_colors.dart';
|
||||
import 'package:real_estate_mobile/core/network/api_exceptions.dart';
|
||||
import 'package:real_estate_mobile/core/utils/image_url_resolver.dart';
|
||||
import 'package:real_estate_mobile/core/widgets/s3_image.dart';
|
||||
import 'package:real_estate_mobile/features/profile/data/profile_repository.dart';
|
||||
@@ -500,7 +501,12 @@ class _ChangeEmailSheetState extends State<_ChangeEmailSheet> {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_submitting = false;
|
||||
_localError = e.toString().replaceFirst('Exception: ', '');
|
||||
// ApiException carries the backend's message verbatim
|
||||
// (e.g. "Incorrect password", "Email is already in use").
|
||||
// Fall back to a generic message for unexpected error types.
|
||||
_localError = e is ApiException
|
||||
? e.message
|
||||
: 'Something went wrong. Please try again.';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user