Browse Source

feat(chat): 更新聊天页面婚姻信息展示逻辑

- 根据性别代码动态显示男性或女性图标
- 优化图片画廊布局,固定显示4张图片
- 添加空图片占位符以保持布局一致性
- 在婚姻数据模型中新增性别代码字段
- 更新婚姻数据构造函数和JSON解析逻辑
- 从用户信息映射中添加性别代码转换
ios
Jolie 3 months ago
parent
commit
6c3bcc84b6
2 changed files with 23 additions and 7 deletions
  1. 4
      lib/model/home/marriage_data.dart
  2. 26
      lib/pages/message/chat_page.dart

4
lib/model/home/marriage_data.dart

@ -18,6 +18,7 @@ class MarriageData {
final String districtName;
final String describeInfo;
final String createTime;
final int genderCode;
final List<PhotoItem> photoList;
// UI展示
@ -45,6 +46,7 @@ class MarriageData {
required this.describeInfo,
required this.createTime,
required this.photoList,
required this.genderCode,
});
factory MarriageData.fromJson(Map<String, dynamic> json) {
@ -65,6 +67,7 @@ class MarriageData {
districtName: json['districtName'] ?? '',
describeInfo: json['describeInfo'] ?? '',
createTime: json['createTime'] ?? '',
genderCode: json['genderCode'] ?? 0,
photoList: (json['photoList'] as List<dynamic>?)?.map((e) => PhotoItem.fromJson(e as Map<String, dynamic>)).toList() ?? [],
);
}
@ -88,6 +91,7 @@ class MarriageData {
districtName: userInfo.districtName ?? '',
describeInfo: userInfo.describeInfo ?? '',
createTime: userInfo.createTime ?? '',
genderCode: userInfo.genderCode?.toInt() ?? 0,
photoList: (userInfo.photoList ?? []).map((photo) => PhotoItem(
photoUrl: photo.photoUrl ?? '',
auditStatus: photo.auditStatus,

26
lib/pages/message/chat_page.dart

@ -323,7 +323,6 @@ class _ChatPageState extends State<ChatPage> {
if (marriageData == null) {
return SizedBox.shrink();
}
return IntrinsicHeight(
child: GestureDetector(
onTap: () {
@ -452,7 +451,7 @@ class _ChatPageState extends State<ChatPage> {
children: [
//
Image.asset(
Assets.imagesFemale,
marriageData.genderCode == 0 ? Assets.imagesMale : Assets.imagesFemale,
width: 14.w,
height: 14.w,
),
@ -510,11 +509,24 @@ class _ChatPageState extends State<ChatPage> {
),
if (marriageData.photoList.isNotEmpty) ...[
SizedBox(height: 8.h), //
//
// - 4
Row(
children: marriageData.photoList.take(4).toList().asMap().entries.map((entry) {
final index = entry.key;
final photo = entry.value;
children: List.generate(4, (index) {
//
if (index >= marriageData.photoList.length) {
return Expanded(
child: AspectRatio(
aspectRatio: 1, //
child: Container(
margin: EdgeInsets.only(
right: index < 3 ? 8.w : 0,
),
),
),
);
}
final photo = marriageData.photoList[index];
final photoUrl = photo.photoUrl.trim().replaceAll('`', ''); // URL中的反引号
return Expanded(
child: AspectRatio(
@ -537,7 +549,7 @@ class _ChatPageState extends State<ChatPage> {
),
),
);
}).toList(),
}),
),
SizedBox(height: 4.h), //
],

Loading…
Cancel
Save