247 lines
7.2 KiB
Dart
Executable File
247 lines
7.2 KiB
Dart
Executable File
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart';
|
|
|
|
import '../../../../appRouters.dart';
|
|
import '../../../../app_settings/app_colors.dart';
|
|
import '../../../../tools/commonDataManage.dart';
|
|
import '../../../../tools/keySearchWidget.dart';
|
|
import '../../../../tools/noData.dart';
|
|
import '../../../../tools/showIosTipView.dart';
|
|
import '../../../../tools/storage.dart';
|
|
import '../../../../tools/submitBtn.dart';
|
|
import '../../../../tools/titleAppBar.dart';
|
|
import '../../../../translations/trans_lib.dart';
|
|
import 'remoteControlList_logic.dart';
|
|
|
|
class RemoteControlListPage extends StatefulWidget {
|
|
const RemoteControlListPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<RemoteControlListPage> createState() => _RemoteControlListPageState();
|
|
}
|
|
|
|
class _RemoteControlListPageState extends State<RemoteControlListPage> {
|
|
final logic = Get.put(RemoteControlListLogic());
|
|
final state = Get.find<RemoteControlListLogic>().state;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.mainBackgroundColor,
|
|
appBar: TitleAppBar(
|
|
barTitle: TranslationLoader.lanKeys!.remoteControl!.tr,
|
|
haveBack: true,
|
|
backgroundColor: AppColors.mainColor,
|
|
actionsList: [
|
|
TextButton(
|
|
child: Text(
|
|
TranslationLoader.lanKeys!.reset!.tr,
|
|
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
|
),
|
|
onPressed: () async {
|
|
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
|
if (isDemoMode == false) {
|
|
final bool isNetWork =
|
|
LockMainLogic.to()?.judgeTheNetwork() ?? false;
|
|
if (!isNetWork) {
|
|
return;
|
|
}
|
|
showDeletAlertDialog(context);
|
|
} else {
|
|
// Get.toNamed(Routers.selectLockTypePage);
|
|
logic.showToast("演示模式");
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
body: Column(
|
|
children: [
|
|
KeySearchWidget(
|
|
editingController: state.searchController,
|
|
onSubmittedAction: () {
|
|
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
Expanded(child: _buildMainUI()),
|
|
AddBottomWhiteBtn(
|
|
btnName:
|
|
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.remoteControl!.tr}',
|
|
onClick: () async {
|
|
var data =
|
|
await Get.toNamed(Routers.addRemoteControlPage, arguments: {
|
|
"lockId": CommonDataManage().currentLockSetInfoData.lockId,
|
|
"fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
|
});
|
|
if (data != null) {
|
|
// 遥控添加
|
|
|
|
}
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 64.h,
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// String getAppBarTitle(int type) {
|
|
// String title = "";
|
|
// switch (type) {
|
|
// case 0:
|
|
// title = TranslationLoader.lanKeys!.card!.tr;
|
|
// break;
|
|
// case 1:
|
|
// title = TranslationLoader.lanKeys!.fingerprint!.tr;
|
|
// break;
|
|
// case 2:
|
|
// title = TranslationLoader.lanKeys!.remoteControl!.tr;
|
|
// break;
|
|
// case 3:
|
|
// title = TranslationLoader.lanKeys!.face!.tr;
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
// return title;
|
|
// }
|
|
|
|
Widget _buildMainUI() {
|
|
String typeImgName = 'images/icon_card.png';
|
|
|
|
return NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h);
|
|
}
|
|
|
|
Widget _buildDeleteBtn(String idStr) {
|
|
return GestureDetector(
|
|
onTap: () {
|
|
// 省略: 弹出是否删除的确认对话框。
|
|
showIosTipViewDialog(context, idStr);
|
|
},
|
|
child: Container(
|
|
width: 60,
|
|
color: const Color(0xFFF20101),
|
|
alignment: Alignment.center,
|
|
child: const Text(
|
|
'删除',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.white,
|
|
height: 1,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void showIosTipViewDialog(BuildContext context, String keyId) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return ShowIosTipView(
|
|
title: "提示",
|
|
tipTitle: "确定要删除吗?",
|
|
sureClick: () async {
|
|
// 遥控删除
|
|
|
|
},
|
|
cancelClick: () {
|
|
Get.back();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _keyItem(String lockTypeIcon, String lockTypeTitle, String showTime,
|
|
Function() action) {
|
|
return GestureDetector(
|
|
onTap: action,
|
|
child: Container(
|
|
height: 90.h,
|
|
// margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
|
color: Colors.white,
|
|
// decoration: BoxDecoration(
|
|
// color: Colors.white,
|
|
// // borderRadius: BorderRadius.circular(10.w),
|
|
// ),
|
|
child: Row(
|
|
children: [
|
|
SizedBox(width: 30.w),
|
|
Image.asset(lockTypeIcon, width: 60.w, height: 60.w),
|
|
SizedBox(width: 20.w),
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(lockTypeTitle,
|
|
style: TextStyle(
|
|
fontSize: 24.sp, color: AppColors.blackColor)),
|
|
],
|
|
),
|
|
SizedBox(height: 5.h),
|
|
Container(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(showTime,
|
|
style: TextStyle(
|
|
fontSize: 18.sp,
|
|
color: AppColors.placeholderTextColor)),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(width: 20.h),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(width: 20.h),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void showDeletAlertDialog(
|
|
BuildContext context,
|
|
) {
|
|
showCupertinoDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return CupertinoAlertDialog(
|
|
title: const Text("提示"),
|
|
content: const Text('重置后遥控信息都会清除哦,确认要重置吗?'),
|
|
actions: [
|
|
CupertinoDialogAction(
|
|
child: Text(TranslationLoader.lanKeys!.cancel!.tr),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
CupertinoDialogAction(
|
|
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
|
onPressed: () {
|
|
// 遥控重置
|
|
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|