|
|
@ -7,7 +7,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
import 'package:get/get.dart'; |
|
|
import 'package:get/get.dart'; |
|
|
|
|
|
|
|
|
import '../../controller/discover/visitor_controller.dart'; |
|
|
import '../../controller/discover/visitor_controller.dart'; |
|
|
|
|
|
import '../../controller/global.dart'; |
|
|
|
|
|
import '../../generated/assets.dart'; |
|
|
import '../../model/home/marriage_data.dart'; |
|
|
import '../../model/home/marriage_data.dart'; |
|
|
|
|
|
import '../home/user_information_page.dart'; |
|
|
|
|
|
|
|
|
class VisitorListPage extends StatefulWidget { |
|
|
class VisitorListPage extends StatefulWidget { |
|
|
const VisitorListPage({super.key}); |
|
|
const VisitorListPage({super.key}); |
|
|
@ -26,7 +29,7 @@ class _VisitorListPagePageState extends State<VisitorListPage> { |
|
|
backgroundColor: Color(0xffF5F5F5), |
|
|
backgroundColor: Color(0xffF5F5F5), |
|
|
appBar: AppBar( |
|
|
appBar: AppBar( |
|
|
title: Obx(() => Text( |
|
|
title: Obx(() => Text( |
|
|
'最近访客 (${visitorController.todayVisitorsCount})', |
|
|
|
|
|
|
|
|
'最近访客 (${visitorController.total.value})', |
|
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), |
|
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), |
|
|
)), |
|
|
)), |
|
|
centerTitle: true, |
|
|
centerTitle: true, |
|
|
@ -90,19 +93,18 @@ class _VisitorListPagePageState extends State<VisitorListPage> { |
|
|
noMoreText: '没有更多数据', |
|
|
noMoreText: '没有更多数据', |
|
|
showMessage: false, |
|
|
showMessage: false, |
|
|
), |
|
|
), |
|
|
child: ListView.separated( |
|
|
|
|
|
padding: const EdgeInsets.only(top: 10, right: 10, left: 10), |
|
|
|
|
|
|
|
|
child: GridView.builder( |
|
|
|
|
|
padding: EdgeInsets.only(top: 8.w, left: 10.w, right: 8.w, bottom: 0.w), |
|
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
|
|
crossAxisCount: 2, // 每行2个 |
|
|
|
|
|
crossAxisSpacing: 4.w, // 左右间距 |
|
|
|
|
|
mainAxisSpacing: 4.w, // 上下间距 |
|
|
|
|
|
childAspectRatio: 1, // 宽高比 |
|
|
|
|
|
), |
|
|
itemCount: visitorController.visitors.length, |
|
|
itemCount: visitorController.visitors.length, |
|
|
itemBuilder: (context, index) { |
|
|
itemBuilder: (context, index) { |
|
|
final visitor = visitorController.visitors[index]; |
|
|
final visitor = visitorController.visitors[index]; |
|
|
return VisitorListItem(visitor: visitor); |
|
|
|
|
|
}, |
|
|
|
|
|
separatorBuilder: (context, index) { |
|
|
|
|
|
// 空状态或加载状态时不显示分隔符 |
|
|
|
|
|
if (visitorController.visitors.isEmpty) { |
|
|
|
|
|
return const SizedBox.shrink(); |
|
|
|
|
|
} |
|
|
|
|
|
return const SizedBox(height: 10); |
|
|
|
|
|
|
|
|
return VisitorItem(visitor: visitor); |
|
|
}, |
|
|
}, |
|
|
), |
|
|
), |
|
|
); |
|
|
); |
|
|
@ -112,96 +114,101 @@ class _VisitorListPagePageState extends State<VisitorListPage> { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class VisitorListItem extends StatelessWidget { |
|
|
|
|
|
|
|
|
class VisitorItem extends StatelessWidget { |
|
|
final MarriageData visitor; |
|
|
final MarriageData visitor; |
|
|
|
|
|
|
|
|
const VisitorListItem({Key? key, required this.visitor}) : super(key: key); |
|
|
|
|
|
|
|
|
const VisitorItem({Key? key, required this.visitor}) : super(key: key); |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
Widget build(BuildContext context) { |
|
|
Widget build(BuildContext context) { |
|
|
return Container( |
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
|
color: Colors.white, |
|
|
|
|
|
borderRadius: BorderRadius.circular(12), |
|
|
|
|
|
), |
|
|
|
|
|
padding: const EdgeInsets.all(12), |
|
|
|
|
|
child: Row( |
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
|
|
|
|
return Stack( |
|
|
children: [ |
|
|
children: [ |
|
|
// 左侧图片 |
|
|
|
|
|
Container( |
|
|
|
|
|
width: 50, |
|
|
|
|
|
height: 50, |
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
|
|
color: Colors.blue[100], |
|
|
|
|
|
image: DecorationImage( |
|
|
|
|
|
image: NetworkImage(visitor.profilePhoto), |
|
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
|
|
|
|
ClipRRect( |
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10.w)), |
|
|
|
|
|
child: CachedNetworkImage( |
|
|
|
|
|
imageUrl: "${visitor.profilePhoto}?x-oss-process=image/format,webp/resize,w_240", |
|
|
|
|
|
width: 173.w, |
|
|
|
|
|
height: 173.w, |
|
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
|
placeholder: (context, url) => Container( |
|
|
|
|
|
color: Colors.white38, |
|
|
|
|
|
child: Center( |
|
|
|
|
|
child: CircularProgressIndicator( |
|
|
|
|
|
strokeWidth: 1.w, |
|
|
|
|
|
color: Colors.grey, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
|
|
|
errorWidget: (context, url, error) => |
|
|
|
|
|
Image.asset( |
|
|
|
|
|
Assets.imagesUserAvatar, |
|
|
|
|
|
width: 173.w, |
|
|
|
|
|
height: 173.w, |
|
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
SizedBox(width: 12), |
|
|
|
|
|
Expanded( |
|
|
|
|
|
|
|
|
Positioned( |
|
|
|
|
|
left: 8.w, |
|
|
|
|
|
bottom: 12.w, |
|
|
child: Column( |
|
|
child: Column( |
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
children: [ |
|
|
children: [ |
|
|
Row( |
|
|
|
|
|
children: [ |
|
|
|
|
|
Text( |
|
|
|
|
|
visitor.nickName, |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
Spacer(), |
|
|
|
|
|
// Text( |
|
|
|
|
|
// _formatTime(visitor.visitTime!), |
|
|
|
|
|
// style: TextStyle( |
|
|
|
|
|
// color: Colors.grey[500], |
|
|
|
|
|
// fontSize: 13, |
|
|
|
|
|
// ), |
|
|
|
|
|
// ), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
SizedBox(height: 4), |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
// height: 20, // 固定高度20 |
|
|
|
|
|
child: Text( |
|
|
|
|
|
visitor.describeInfo, |
|
|
|
|
|
|
|
|
if(visitor.describeInfo.isNotEmpty)SizedBox( |
|
|
|
|
|
width: 156.w, |
|
|
|
|
|
child: Text(visitor.describeInfo, |
|
|
|
|
|
maxLines: 1, |
|
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
fontSize: 13, |
|
|
|
|
|
color: Color.fromRGBO(51, 51, 51, 0.6), |
|
|
|
|
|
|
|
|
fontSize: 12.w, |
|
|
|
|
|
color: Colors.white, |
|
|
|
|
|
fontWeight: FontWeight.w500, |
|
|
), |
|
|
), |
|
|
overflow: TextOverflow.ellipsis, // 文本超出显示... |
|
|
|
|
|
maxLines: 1, // 限制为单行 |
|
|
|
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
|
|
|
SizedBox(height: 2.w), |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
width: 156.w, |
|
|
|
|
|
child: Row( |
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
|
children: [ |
|
|
|
|
|
Text( |
|
|
|
|
|
"${visitor.cityName.isNotEmpty ? '${visitor.cityName} | ' : ''}${visitor.age}岁", |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 14.w, |
|
|
|
|
|
color: Colors.white, |
|
|
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
Text('访问1次', style: TextStyle(color: Color(0xffA799FF), fontSize: 12.w)) |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
) |
|
|
], |
|
|
], |
|
|
) |
|
|
|
|
|
|
|
|
), |
|
|
) |
|
|
) |
|
|
], |
|
|
], |
|
|
), |
|
|
|
|
|
).onTap((){ |
|
|
).onTap((){ |
|
|
// _showVisitorDetail(visitor); |
|
|
|
|
|
|
|
|
Get.to(() => UserInformationPage(miId: visitor.miId, userId: GlobalData().userId!)); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String _formatTime(String timestamp) { |
|
|
|
|
|
var time = DateTime.parse(timestamp); |
|
|
|
|
|
final now = DateTime.now(); |
|
|
|
|
|
final difference = now.difference(time); |
|
|
|
|
|
|
|
|
|
|
|
if (difference.inMinutes < 1) { |
|
|
|
|
|
return '刚刚'; |
|
|
|
|
|
} else if (difference.inHours < 1) { |
|
|
|
|
|
return '${difference.inMinutes}分钟前'; |
|
|
|
|
|
} else if (difference.inDays < 1) { |
|
|
|
|
|
return '${difference.inHours}小时前'; |
|
|
|
|
|
} else if (difference.inDays < 7) { |
|
|
|
|
|
return '${difference.inDays}天前'; |
|
|
|
|
|
} else { |
|
|
|
|
|
return '${time.month}/${time.day}'; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// String _formatTime(String timestamp) { |
|
|
|
|
|
// var time = DateTime.parse(timestamp); |
|
|
|
|
|
// final now = DateTime.now(); |
|
|
|
|
|
// final difference = now.difference(time); |
|
|
|
|
|
// |
|
|
|
|
|
// if (difference.inMinutes < 1) { |
|
|
|
|
|
// return '刚刚'; |
|
|
|
|
|
// } else if (difference.inHours < 1) { |
|
|
|
|
|
// return '${difference.inMinutes}分钟前'; |
|
|
|
|
|
// } else if (difference.inDays < 1) { |
|
|
|
|
|
// return '${difference.inHours}小时前'; |
|
|
|
|
|
// } else if (difference.inDays < 7) { |
|
|
|
|
|
// return '${difference.inDays}天前'; |
|
|
|
|
|
// } else { |
|
|
|
|
|
// return '${time.month}/${time.day}'; |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
} |
|
|
} |