174 lines
5.3 KiB
Dart
174 lines
5.3 KiB
Dart
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:get/get.dart';
|
||
|
||
import '../../../../../app_settings/app_colors.dart';
|
||
import '../massSendLockGroupList/lockUserList/lockUserList_entity.dart';
|
||
|
||
typedef BlockCallback = void Function(List receiverList);
|
||
|
||
class MassSendElectronicKeyProgressPage extends StatefulWidget {
|
||
MassSendElectronicKeyProgressPage({required this.receiverList, required this.callback, Key? key}) : super(key: key);
|
||
List receiverList;
|
||
BlockCallback callback;
|
||
|
||
@override
|
||
State<MassSendElectronicKeyProgressPage> createState() => _MassSendElectronicKeyProgressPageState();
|
||
}
|
||
|
||
class _MassSendElectronicKeyProgressPageState extends State<MassSendElectronicKeyProgressPage> {
|
||
int failCount = 0;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
// 遍历receiverList,统计失败的数量
|
||
widget.receiverList.forEach((element) {
|
||
if (element is LockUserItemData) {
|
||
if (element.isSendSuccess == false || element.isSendSuccess == null) {
|
||
failCount++;
|
||
}
|
||
}
|
||
});
|
||
|
||
return Container(
|
||
width: 1.sw - 20*2,
|
||
height: 500.h,
|
||
decoration: BoxDecoration(
|
||
color: Colors.white,
|
||
borderRadius: BorderRadius.circular(10),
|
||
),
|
||
child: Column(
|
||
children: <Widget>[
|
||
topTitle(),
|
||
Divider(height: 1.h, color: AppColors.greyLineColor),
|
||
progressTitle(),
|
||
Expanded(child: progressList()),
|
||
Divider(height: 1.h, color: AppColors.greyLineColor),
|
||
bottomBtn(),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget topTitle(){
|
||
return SizedBox(
|
||
height: 70.h,
|
||
child: Stack(
|
||
children: [
|
||
Center(
|
||
child: Text(
|
||
'发送钥匙'.tr,
|
||
style: TextStyle(fontSize: 24.sp),
|
||
),
|
||
),
|
||
Positioned(
|
||
right: 0,
|
||
child: GestureDetector(
|
||
onTap: Get.back,
|
||
child: Container(
|
||
padding: EdgeInsets.all(15.w),
|
||
child: Image.asset(
|
||
'images/icon_close_black.png',
|
||
width: 35.w,
|
||
height: 35.w,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget progressTitle(){
|
||
return Container(
|
||
padding: EdgeInsets.only(left: 15.w, top: 10.h, bottom: 10.h),
|
||
child: Row(
|
||
children: <Widget>[
|
||
Text('进度'.tr + ':' + '$failCount/${widget.receiverList.length}', style: TextStyle(fontSize: 24.sp)),
|
||
SizedBox(width: 20.w),
|
||
Text('失败'.tr + ':' + '$failCount', style: TextStyle(fontSize: 24.sp, color: Colors.red))
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget progressList(){
|
||
return ListView.builder(
|
||
itemCount: widget.receiverList.length,
|
||
itemBuilder: (BuildContext c, int index) {
|
||
LockUserItemData data = widget.receiverList[index];
|
||
return Container(
|
||
margin: EdgeInsets.only(left: 15.w, top: 5.h, bottom: 5.h, right: 15.w),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Row(
|
||
children: <Widget>[
|
||
Text(data.userid??'', style: TextStyle(fontSize: 24.sp)),
|
||
SizedBox(width: 10.w),
|
||
if (data.isSendSuccess ?? false) const Icon(Icons.check, color: Colors.green) else const Icon(Icons.close, color: Colors.red),
|
||
],
|
||
),
|
||
if (!(data.isSendSuccess ?? false)) Text(data.sendFailReason??'', style: TextStyle(fontSize: 20.sp, color: Colors.red))
|
||
],
|
||
),
|
||
);
|
||
},
|
||
);
|
||
}
|
||
|
||
Widget bottomBtn(){
|
||
return Container(
|
||
height: 80.h,
|
||
child: Row(
|
||
children: <Widget>[
|
||
Expanded(
|
||
child: GestureDetector(
|
||
onTap: Get.back,
|
||
child: Container(
|
||
alignment: Alignment.center,
|
||
decoration: const BoxDecoration(
|
||
color: Colors.white,
|
||
borderRadius: BorderRadius.only(
|
||
bottomLeft: Radius.circular(10)),
|
||
),
|
||
child: Text(
|
||
'完成'.tr,
|
||
style: TextStyle(
|
||
fontSize: 24.sp, color: AppColors.mainColor),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
Container(width: 1.h, color: AppColors.greyLineColor),
|
||
Expanded(
|
||
child: GestureDetector(
|
||
onTap: (){
|
||
Get.back();
|
||
// 剔除发送失败的数据,重新发送
|
||
widget.receiverList.removeWhere((element) => (element as LockUserItemData).isSendSuccess == true);
|
||
widget.callback(widget.receiverList);
|
||
},
|
||
child: Container(
|
||
alignment: Alignment.center,
|
||
decoration: const BoxDecoration(
|
||
color: Colors.white,
|
||
borderRadius: BorderRadius.only(
|
||
bottomRight: Radius.circular(10)),
|
||
),
|
||
child: Text(
|
||
'重试'.tr,
|
||
style: TextStyle(
|
||
fontSize: 24.sp, color: AppColors.mainColor),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
}
|