You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
6.9 KiB
187 lines
6.9 KiB
import 'package:dating_touchme_app/controller/discover/room_controller.dart';
|
|
import 'package:dating_touchme_app/extension/ex_widget.dart';
|
|
import 'package:easy_refresh/easy_refresh.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import 'audience_item.dart';
|
|
|
|
class KickList extends StatefulWidget {
|
|
const KickList({super.key});
|
|
|
|
@override
|
|
State<KickList> createState() => _KickListState();
|
|
}
|
|
|
|
class _KickListState extends State<KickList> {
|
|
|
|
final RoomController _roomController = Get.find<RoomController>();
|
|
|
|
|
|
|
|
List<Map<String, dynamic>> selectUserId = [];
|
|
|
|
selectChange(String userId, int uid){
|
|
final index = selectUserId.indexWhere((e) => e["userId"] == userId);
|
|
index == -1
|
|
? selectUserId.add({"userId": userId, "uid": uid})
|
|
: selectUserId.removeAt(index);
|
|
setState(() {
|
|
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Material(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(9.w)),
|
|
color: Colors.white,
|
|
child: Container(
|
|
width: 375.w,
|
|
height: 300.w,
|
|
padding: EdgeInsets.all(10.w),
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
"在线用户",
|
|
style: TextStyle(
|
|
fontSize: 16.w,
|
|
fontWeight: FontWeight.w700
|
|
),
|
|
),
|
|
Expanded(
|
|
child: EasyRefresh(
|
|
|
|
controller: _roomController.listRefreshController,
|
|
header: const ClassicHeader(
|
|
dragText: '下拉刷新',
|
|
armedText: '释放刷新',
|
|
readyText: '刷新中...',
|
|
processingText: '刷新中...',
|
|
processedText: '刷新完成',
|
|
failedText: '刷新失败',
|
|
noMoreText: '没有更多数据',
|
|
showMessage: false
|
|
),
|
|
footer: ClassicFooter(
|
|
dragText: '上拉加载',
|
|
armedText: '释放加载',
|
|
readyText: '加载中...',
|
|
processingText: '加载中...',
|
|
processedText: '加载完成',
|
|
failedText: '加载失败',
|
|
noMoreText: '没有更多数据',
|
|
showMessage: false
|
|
),
|
|
// 下拉刷新
|
|
onRefresh: () async {
|
|
print('推荐列表下拉刷新被触发');
|
|
_roomController.page.value = 1;
|
|
_roomController.audienceList.clear();
|
|
await _roomController.getAudienceList();
|
|
_roomController.listRefreshController.finishRefresh(IndicatorResult.success);
|
|
_roomController.listRefreshController.finishLoad(IndicatorResult.none);
|
|
},
|
|
// 上拉加载更多
|
|
onLoad: () async {
|
|
print('推荐列表上拉加载被触发, hasMore: ');
|
|
_roomController.page.value += 1;
|
|
await _roomController.getAudienceList();
|
|
},
|
|
child: ListView.separated(
|
|
// 关键:始终允许滚动,即使内容不足
|
|
// 移除顶部 padding,让刷新指示器可以正确显示在 AppBar 下方
|
|
padding: EdgeInsets.only(left: 12, right: 12),
|
|
itemBuilder: (context, index) {
|
|
// 空数据状态
|
|
if (_roomController.audienceList.isEmpty && index == 0) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text('暂无数据'),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
// 数据项
|
|
final item = _roomController.audienceList[index];
|
|
return AudienceItem(item: item, selectUserId: selectUserId, selectChange: selectChange,);
|
|
},
|
|
separatorBuilder: (context, index) {
|
|
// 空状态或加载状态时不显示分隔符
|
|
if (_roomController.audienceList.isEmpty) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
return const SizedBox(height: 12);
|
|
},
|
|
// 至少显示一个 item(用于显示加载或空状态)
|
|
itemCount: _roomController.audienceList.isEmpty ? 1 : _roomController.audienceList.length,
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Container(
|
|
width: 170.w,
|
|
height: 42.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(42.w)),
|
|
color: const Color.fromRGBO(237, 237, 237, 1)
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
"取消",
|
|
style: TextStyle(
|
|
fontSize: 14.w,
|
|
fontWeight: FontWeight.w500
|
|
),
|
|
),
|
|
),
|
|
).onTap((){
|
|
// 隐藏键盘
|
|
FocusScope.of(context).unfocus();
|
|
// 隐藏 overlay
|
|
SmartDialog.dismiss();
|
|
_roomController.setDialogDismiss(false);
|
|
}),
|
|
Container(
|
|
width: 170.w,
|
|
height: 42.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(42.w)),
|
|
color: const Color.fromRGBO(117, 98, 249, 1)
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
"确认",
|
|
style: TextStyle(
|
|
fontSize: 14.w,
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w500
|
|
),
|
|
),
|
|
),
|
|
).onTap(() async {
|
|
final List<String> dList =
|
|
selectUserId.map((item) => item["uid"].toString()).toList();
|
|
await _roomController.kickUser(dList);
|
|
|
|
// 隐藏键盘
|
|
FocusScope.of(context).unfocus();
|
|
// 隐藏 overlay
|
|
SmartDialog.dismiss();
|
|
_roomController.setDialogDismiss(false);
|
|
selectUserId.clear();
|
|
})
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|