2024-06-18 10:36:41 +08:00
|
|
|
|
2023-11-03 13:58:41 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
2024-03-29 18:32:33 +08:00
|
|
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
2024-03-28 13:46:35 +08:00
|
|
|
import 'package:get/get.dart';
|
2023-11-03 13:58:41 +08:00
|
|
|
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
|
|
|
|
import 'package:star_lock/mine/mineSet/lockUserManage/lockUserManageList/keyListByUserEntity.dart';
|
2024-06-18 10:36:41 +08:00
|
|
|
import 'package:star_lock/mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_state.dart';
|
2024-03-29 18:32:33 +08:00
|
|
|
import 'package:star_lock/tools/noData.dart';
|
|
|
|
|
import 'package:star_lock/tools/showIosTipView.dart';
|
2023-11-03 13:58:41 +08:00
|
|
|
|
|
|
|
|
import '../../../../../app_settings/app_colors.dart';
|
|
|
|
|
import '../../../../../tools/titleAppBar.dart';
|
2024-03-29 18:32:33 +08:00
|
|
|
import '../../../../tools/EasyRefreshTool.dart';
|
2024-03-28 13:46:35 +08:00
|
|
|
import 'ownedKeyList_logic.dart';
|
2023-11-03 13:58:41 +08:00
|
|
|
|
|
|
|
|
class OwnedKeyListPage extends StatefulWidget {
|
|
|
|
|
const OwnedKeyListPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<OwnedKeyListPage> createState() => _OwnedKeyListPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _OwnedKeyListPageState extends State<OwnedKeyListPage> {
|
2024-06-18 10:36:41 +08:00
|
|
|
final OwnedKeyListLogic logic = Get.put(OwnedKeyListLogic());
|
|
|
|
|
final OwnedKeyListState state = Get.find<OwnedKeyListLogic>().state;
|
2023-11-03 13:58:41 +08:00
|
|
|
|
2024-03-29 18:32:33 +08:00
|
|
|
|
|
|
|
|
Future<void> getHttpData() async {
|
|
|
|
|
logic.mockNetworkDataRequest().then((KeyListByUserEntity value){
|
2024-06-18 10:36:41 +08:00
|
|
|
if(mounted) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
2024-03-29 18:32:33 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-03 13:58:41 +08:00
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2024-03-29 18:32:33 +08:00
|
|
|
|
|
|
|
|
getHttpData();
|
2023-11-03 13:58:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
|
|
|
appBar: TitleAppBar(
|
2024-08-01 18:54:32 +08:00
|
|
|
barTitle: '拥有的钥匙'.tr,
|
2023-11-03 13:58:41 +08:00
|
|
|
haveBack: true,
|
|
|
|
|
backgroundColor: AppColors.mainColor,
|
|
|
|
|
),
|
2024-03-29 18:32:33 +08:00
|
|
|
body: EasyRefreshTool(
|
|
|
|
|
onRefresh: () {
|
|
|
|
|
logic.pageNo = 1;
|
|
|
|
|
getHttpData();
|
|
|
|
|
},
|
|
|
|
|
onLoad: () {
|
|
|
|
|
getHttpData();
|
|
|
|
|
},
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
_topOwnedKeyText(),
|
|
|
|
|
Obx(() => Expanded(child: _buildMainUI())),
|
|
|
|
|
],
|
|
|
|
|
)));
|
2023-11-03 13:58:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _topOwnedKeyText() {
|
|
|
|
|
return Container(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
width: ScreenUtil().screenWidth,
|
|
|
|
|
// margin: EdgeInsets.only(left: 30.w, top: 30.w, right: 30.w, bottom: 30.w),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.only(left: 30.w, top: 20.w, right: 20.w, bottom: 10.w),
|
|
|
|
|
child: Text(
|
2024-08-01 18:54:32 +08:00
|
|
|
'拥有的钥匙'.tr,
|
2023-11-03 13:58:41 +08:00
|
|
|
style: TextStyle(fontSize: 24.sp),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-29 18:32:33 +08:00
|
|
|
Widget _buildMainUI() {
|
|
|
|
|
return state.dataList.isEmpty
|
|
|
|
|
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)
|
|
|
|
|
: SlidableAutoCloseBehavior(
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
itemCount: state.dataList.length,
|
2024-06-18 10:36:41 +08:00
|
|
|
itemBuilder: (BuildContext c, int index) {
|
|
|
|
|
final KeyListItem itemData = state.dataList[index];
|
2024-03-29 18:32:33 +08:00
|
|
|
return Slidable(
|
|
|
|
|
key:ValueKey(itemData.keyId),
|
|
|
|
|
endActionPane: ActionPane(
|
|
|
|
|
extentRatio: 0.2,
|
|
|
|
|
motion: const ScrollMotion(),
|
|
|
|
|
children: [
|
|
|
|
|
SlidableAction(
|
|
|
|
|
onPressed: (BuildContext context){
|
|
|
|
|
showIosTipViewDialog(itemData);
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: Colors.red,
|
|
|
|
|
foregroundColor: Colors.white,
|
2024-06-18 10:36:41 +08:00
|
|
|
label: '删除'.tr,
|
2024-03-29 18:32:33 +08:00
|
|
|
padding: EdgeInsets.only(left: 5.w, right: 5.w),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: _electronicKeyItem(itemData),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
);
|
2023-11-03 13:58:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _electronicKeyItem(KeyListItem itemData) {
|
2024-03-29 18:32:33 +08:00
|
|
|
var isHaveExpired = false;
|
|
|
|
|
if(itemData.keyStatus == XSConstantMacro.keyStatusExpired){
|
|
|
|
|
isHaveExpired = true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-03 13:58:41 +08:00
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () {},
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 90.h,
|
|
|
|
|
margin: const EdgeInsets.only(top: 1),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(10.w),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
2024-03-28 13:46:35 +08:00
|
|
|
SizedBox(width: 30.w,),
|
|
|
|
|
Image.asset('images/icon_lockGroup_item.png', width: 60.w, height: 60.w),
|
|
|
|
|
SizedBox(width: 20.w),
|
2023-11-03 13:58:41 +08:00
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
2024-03-29 18:32:33 +08:00
|
|
|
// Text(itemData.lockAlias ?? '', style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor)),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 1.sw - 110.w - 100.w,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Flexible(
|
|
|
|
|
child: Text(
|
|
|
|
|
itemData.lockAlias ?? '',
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: TextStyle(fontSize: 24.sp, color: isHaveExpired ? Colors.grey:AppColors.blackColor)
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Visibility(
|
|
|
|
|
visible: isHaveExpired,
|
2024-06-18 10:36:41 +08:00
|
|
|
child: Text('已过期'.tr,
|
2024-03-29 18:32:33 +08:00
|
|
|
style: TextStyle(fontSize: 22.sp, color: Colors.grey)),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 10.w),
|
2023-11-03 13:58:41 +08:00
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 5.h),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
2024-03-28 13:46:35 +08:00
|
|
|
logic.getUseDateStr(itemData),
|
2024-03-29 18:32:33 +08:00
|
|
|
style: TextStyle(fontSize: 18.sp, color: isHaveExpired ? Colors.grey:AppColors.placeholderTextColor),
|
2023-11-03 13:58:41 +08:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 20.h),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 20.h),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-03-29 18:32:33 +08:00
|
|
|
|
|
|
|
|
void showIosTipViewDialog(KeyListItem lockUserData) {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: Get.context!,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return ShowIosTipView(
|
2024-06-18 10:36:41 +08:00
|
|
|
title: '提示'.tr,
|
|
|
|
|
tipTitle: '删除钥匙会在用户APP连网后生效'.tr,
|
2024-03-29 18:32:33 +08:00
|
|
|
sureClick: () {
|
|
|
|
|
Get.back();
|
|
|
|
|
logic.deleteKeyRequest(lockUserData.keyId!);
|
|
|
|
|
},
|
|
|
|
|
cancelClick: () {
|
|
|
|
|
Get.back();
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-03 13:58:41 +08:00
|
|
|
}
|