|
|
|
@ -7,7 +7,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
|
|
|
|
import '../../controller/discover/visitor_controller.dart'; |
|
|
|
import '../../model/discover/visitor_model.dart'; |
|
|
|
import '../../model/home/marriage_data.dart'; |
|
|
|
|
|
|
|
class VisitorListPage extends StatefulWidget { |
|
|
|
const VisitorListPage({super.key}); |
|
|
|
@ -31,28 +31,6 @@ class _VisitorListPagePageState extends State<VisitorListPage> { |
|
|
|
)), |
|
|
|
centerTitle: true, |
|
|
|
backgroundColor: Colors.white, |
|
|
|
actions: [ |
|
|
|
// 更多操作 |
|
|
|
PopupMenuButton<String>( |
|
|
|
onSelected: (value) { |
|
|
|
if (value == 'clear') { |
|
|
|
_showClearDialog(); |
|
|
|
} else if (value == 'sort') { |
|
|
|
_showSortDialog(); |
|
|
|
} |
|
|
|
}, |
|
|
|
tooltip: "", |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), |
|
|
|
color: Colors.white, |
|
|
|
elevation: 8, |
|
|
|
offset: Offset(32.w, 36.h), // 相对按钮下移一点 |
|
|
|
itemBuilder: (BuildContext context) => [ |
|
|
|
PopupMenuItem(value: 'sort', child: Text('排序方式')), |
|
|
|
PopupMenuItem(value: 'clear', child: Text('清空记录')), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
body: Obx(() { |
|
|
|
if (visitorController.isLoading.value && visitorController.visitors.isEmpty) { |
|
|
|
@ -76,17 +54,15 @@ class _VisitorListPagePageState extends State<VisitorListPage> { |
|
|
|
Icon(Icons.people_outline, size: 80, color: Colors.grey[300]), |
|
|
|
SizedBox(height: 16), |
|
|
|
Text( |
|
|
|
'暂无访客记录', |
|
|
|
style: TextStyle(fontSize: 18, color: Colors.grey), |
|
|
|
'暂无访客记录,点击刷新', |
|
|
|
style: TextStyle(fontSize: 14, color: Colors.grey), |
|
|
|
), |
|
|
|
SizedBox(height: 8), |
|
|
|
Text( |
|
|
|
'下拉刷新获取数据', |
|
|
|
style: TextStyle(color: Colors.grey), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
).onTap((){ |
|
|
|
visitorController.loadInitialData(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return EasyRefresh( |
|
|
|
@ -134,65 +110,10 @@ class _VisitorListPagePageState extends State<VisitorListPage> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
void _showClearDialog() { |
|
|
|
Get.dialog( |
|
|
|
AlertDialog( |
|
|
|
title: Text('确认清空'), |
|
|
|
content: Text('确定要清空所有访客记录吗?此操作不可恢复。'), |
|
|
|
actions: [ |
|
|
|
TextButton( |
|
|
|
onPressed: () => Get.back(), |
|
|
|
child: Text('取消'), |
|
|
|
), |
|
|
|
TextButton( |
|
|
|
onPressed: () { |
|
|
|
visitorController.clearAllVisitors(); |
|
|
|
Get.back(); |
|
|
|
}, |
|
|
|
child: Text('确定', style: TextStyle(color: Colors.red)), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
void _showSortDialog() { |
|
|
|
Get.dialog( |
|
|
|
AlertDialog( |
|
|
|
title: Text('排序方式'), |
|
|
|
content: Column( |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
children: [ |
|
|
|
ListTile( |
|
|
|
title: Text('按访问时间'), |
|
|
|
onTap: () { |
|
|
|
// 实现排序逻辑 |
|
|
|
Get.back(); |
|
|
|
}, |
|
|
|
), |
|
|
|
ListTile( |
|
|
|
title: Text('按访问时长'), |
|
|
|
onTap: () { |
|
|
|
// 实现排序逻辑 |
|
|
|
Get.back(); |
|
|
|
}, |
|
|
|
), |
|
|
|
ListTile( |
|
|
|
title: Text('按访问次数'), |
|
|
|
onTap: () { |
|
|
|
// 实现排序逻辑 |
|
|
|
Get.back(); |
|
|
|
}, |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class VisitorListItem extends StatelessWidget { |
|
|
|
final VisitorModel visitor; |
|
|
|
final MarriageData visitor; |
|
|
|
|
|
|
|
const VisitorListItem({Key? key, required this.visitor}) : super(key: key); |
|
|
|
|
|
|
|
@ -215,7 +136,7 @@ class VisitorListItem extends StatelessWidget { |
|
|
|
borderRadius: BorderRadius.circular(8), |
|
|
|
color: Colors.blue[100], |
|
|
|
image: DecorationImage( |
|
|
|
image: NetworkImage(visitor.profilePhoto!), |
|
|
|
image: NetworkImage(visitor.profilePhoto), |
|
|
|
fit: BoxFit.cover, |
|
|
|
), |
|
|
|
), |
|
|
|
@ -227,26 +148,26 @@ class VisitorListItem extends StatelessWidget { |
|
|
|
Row( |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
visitor.nickName!, |
|
|
|
visitor.nickName, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14, |
|
|
|
), |
|
|
|
), |
|
|
|
Spacer(), |
|
|
|
Text( |
|
|
|
_formatTime(visitor.visitTime!), |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.grey[500], |
|
|
|
fontSize: 13, |
|
|
|
), |
|
|
|
), |
|
|
|
// Text( |
|
|
|
// _formatTime(visitor.visitTime!), |
|
|
|
// style: TextStyle( |
|
|
|
// color: Colors.grey[500], |
|
|
|
// fontSize: 13, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
], |
|
|
|
), |
|
|
|
SizedBox(height: 4), |
|
|
|
SizedBox( |
|
|
|
// height: 20, // 固定高度20 |
|
|
|
child: Text( |
|
|
|
visitor.describeInfo!, |
|
|
|
visitor.describeInfo, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 13, |
|
|
|
color: Color.fromRGBO(51, 51, 51, 0.6), |
|
|
|
|