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();
|
isExpanded ? tags : tags.take(initialCount).toList();
|
||||||
final remaining = tags.length - initialCount;
|
final remaining = tags.length - initialCount;
|
||||||
|
|
||||||
return Wrap(
|
// Cap each chip's width so long taglines wrap inside the chip instead
|
||||||
spacing: 8,
|
// of overflowing the Wrap's row and clipping behind ancestor bounds.
|
||||||
runSpacing: 8,
|
return LayoutBuilder(
|
||||||
children: [
|
builder: (ctx, constraints) {
|
||||||
...displayTags.map((tag) => Container(
|
final maxChipWidth = constraints.maxWidth.isFinite
|
||||||
padding:
|
? constraints.maxWidth
|
||||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
: MediaQuery.of(ctx).size.width - 32;
|
||||||
decoration: BoxDecoration(
|
return Wrap(
|
||||||
borderRadius: BorderRadius.circular(15),
|
spacing: 8,
|
||||||
border:
|
runSpacing: 8,
|
||||||
Border.all(color: AppColors.primaryDark, width: 0.7),
|
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:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:real_estate_mobile/core/constants/app_colors.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/utils/image_url_resolver.dart';
|
||||||
import 'package:real_estate_mobile/core/widgets/s3_image.dart';
|
import 'package:real_estate_mobile/core/widgets/s3_image.dart';
|
||||||
import 'package:real_estate_mobile/features/profile/data/profile_repository.dart';
|
import 'package:real_estate_mobile/features/profile/data/profile_repository.dart';
|
||||||
@@ -500,7 +501,12 @@ class _ChangeEmailSheetState extends State<_ChangeEmailSheet> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_submitting = false;
|
_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