1、修复添加指纹、人脸、遥控轻微左右滑动添加卡类型不同问题。2、添加星锁状态、添加用户协议根据是否是添加用户前流程

This commit is contained in:
魏少阳 2024-04-25 11:56:13 +08:00
parent 39455bf6e9
commit b5f9f91ec5
14 changed files with 477 additions and 211 deletions

View File

@ -76,7 +76,7 @@ import 'main/lockDetail/checkingIn/checkingInStaff/checkingInStaffDetail/checkin
import 'main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyPeriodValidity/electronicKeyPeriodValidity_page.dart';
import 'main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicManageKey/massSendElectronicKeyManage_page.dart';
import 'main/lockDetail/face/addFace/addFace_page.dart';
import 'main/lockDetail/face/addFaceType/addFaceTypeManage/addFaceTypeManage_page.dart';
import 'main/lockDetail/face/addFaceType/addFaceType_page.dart';
import 'main/lockDetail/face/faceList/faceList_page.dart';
import 'main/lockDetail/fingerprint/addFingerprint/addFingerprint_page.dart';
import 'main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart';
@ -117,7 +117,7 @@ import 'main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart';
import 'main/lockDetail/monitoring/monitoringRealTimeScreen/monitoringRealTimeScreen_page.dart';
import 'main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart';
import 'main/lockDetail/realTimePicture/realTimePicture_page.dart';
import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControlManage/addRemoteControlManage_page.dart';
import 'main/lockDetail/remoteControl/addRemoteControl/addRemoteControl_page.dart';
import 'main/lockDetail/remoteControl/remoteControlList/remoteControlList_page.dart';
import 'main/lockDetail/videoLog/editVideoLog/editVideoLog_page.dart';
import 'main/lockDetail/videoLog/videoLog/videoLog_page.dart';
@ -412,8 +412,7 @@ abstract class Routers {
static const videoLogDownLoadPage = '/VideoLogDownLoadPage'; //
static const remoteControlListPage = '/RemoteControlListPage'; //
static const addRemoteControlManagePage =
'/AddRemoteControlManagePage'; //
static const addRemoteControlPage = '/AddRemoteControlPage'; //
static const cardListPage = '/CardListPage'; //
// static const addCardTypeManagePage = '/AddCardTypeManagePage'; //
@ -423,7 +422,7 @@ abstract class Routers {
static const addFingerprintTypePage = '/AddFingerprintTypePage'; //
static const fingerprintDetailPage = '/FingerprintDetailPage'; //
static const faceListPage = '/FaceListPage'; //
static const addFaceTypeManagePage = '/AddFaceTypeManagePage'; //
static const addFaceTypePage = '/AddFaceTypePage'; //
static const faceDetailPage = '/faceDetailPage'; //
static const irisListPage = '/IrisListPage'; //
@ -1006,8 +1005,8 @@ abstract class AppRouters {
name: Routers.remoteControlListPage,
page: () => const RemoteControlListPage()),
GetPage(
name: Routers.addRemoteControlManagePage,
page: () => const AddRemoteControlManagePage()),
name: Routers.addRemoteControlPage,
page: () => const AddRemoteControlPage()),
GetPage(name: Routers.cardListPage, page: () => const CardListPage()),
// GetPage(
// name: Routers.addCardTypeManagePage,
@ -1027,8 +1026,8 @@ abstract class AppRouters {
page: () => const FingerprintDetailPage()),
GetPage(name: Routers.faceListPage, page: () => const FaceListPage()),
GetPage(
name: Routers.addFaceTypeManagePage,
page: () => const AddFaceTypeManagePage()),
name: Routers.addFaceTypePage,
page: () => const AddFaceTypePage()),
GetPage(
name: Routers.passwordKeyDetailChangeDatePage,
page: () => const PasswordKeyDetailChangeDatePage()),

View File

@ -86,6 +86,7 @@ class IoSenderManage {
List<int>? publicKey,
List<int>? privateKey,
List<int>? token,
bool? isBeforeAddUser,
CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData(
command: AddUserCommand(
@ -103,7 +104,7 @@ class IoSenderManage {
publicKey: publicKey,
privateKey: privateKey,
token: token),
isBeforeAddUser: true,
isBeforeAddUser: isBeforeAddUser!,
callBack: callBack);
}
@ -214,6 +215,7 @@ class IoSenderManage {
{String? lockID,
String? userID,
List<int>? privateKey,
bool? isBeforeAddUser,
CommandSendCallBack? callBack}) {
CommandSenderManager().managerSendData(
command: GetStarLockStatuInfoCommand(
@ -221,6 +223,7 @@ class IoSenderManage {
userID: userID,
privateKey: privateKey,
),
isBeforeAddUser: isBeforeAddUser!,
callBack: callBack);
}

View File

@ -180,7 +180,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
}
break;
case 5:
Get.toNamed(Routers.addFaceTypeManagePage, arguments: {
Get.toNamed(Routers.addFaceTypePage, arguments: {
"lockId": state.getKeyInfosData.value.lockId,
"fromType": 2, // 1 2
"fromTypeTwoStaffName": state.staffNameController.text

View File

@ -16,16 +16,17 @@ class AddFaceTypeLogic extends BaseGetXController {
var startTime = "";
var endTime = "";
if (state.selectType.value == "0") {
print("永久卡永久卡永久卡");
faceType = 1;
startDate = "0";
endDate = "0";
startTime = "0";
endTime = "0";
} else if (state.selectType.value == "1") {
print("限时卡限时卡限时卡");
faceType = 2;
startDate =
DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
startDate = DateTool().dateToTimestamp(state.timeLimitBeginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.timeLimitEndTime.value, 1).toString();
startTime = "0";
endTime = "0";
@ -48,16 +49,18 @@ class AddFaceTypeLogic extends BaseGetXController {
return;
}
} else if (state.selectType.value == "2") {
if (state.beginTime.value.isEmpty) {
print("循环卡循环卡循环卡");
if (state.cycleBeginTime.value.isEmpty) {
showToast("请选择有效期".tr);
return;
}
startDate = DateTool().dateToTimestamp(state.beginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.endTime.value, 1).toString();
startDate = DateTool().dateToTimestamp(state.cycleBeginTime.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.cycleEndTime.value, 1).toString();
startTime = DateTool().dateToTimestamp(state.effectiveDateTime.value, 0).toString();
endTime = DateTool().dateToTimestamp(state.failureDateTime.value, 0).toString();
faceType = 4;
}
//
Get.toNamed(Routers.addFacePage, arguments: {
"lockId": state.lockId.value,

View File

@ -9,106 +9,111 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/CustomUnderlineTabIndicator.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/storage.dart';
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
import '../../../../translations/trans_lib.dart';
import 'addFaceType_logic.dart';
class AddFaceTypePage extends StatefulWidget {
final String selectType; //
final int lockId;
final int fromType; // // 1 2
final String fromTypeTwoStaffName; //
const AddFaceTypePage(
{Key? key,
required this.selectType,
required this.lockId,
required this.fromType,
required this.fromTypeTwoStaffName})
: super(key: key);
const AddFaceTypePage({Key? key}) : super(key: key);
@override
State<AddFaceTypePage> createState() => _AddFaceTypePageState();
}
class _AddFaceTypePageState extends State<AddFaceTypePage> {
class _AddFaceTypePageState extends State<AddFaceTypePage> with SingleTickerProviderStateMixin {
final logic = Get.put(AddFaceTypeLogic());
final state = Get.find<AddFaceTypeLogic>().state;
@override
Widget build(BuildContext context) {
state.selectType.value = widget.selectType;
state.lockId.value = widget.lockId;
if (widget.fromTypeTwoStaffName.isNotEmpty) {
state.nameController.text = widget.fromTypeTwoStaffName;
}
state.fromType.value = widget.fromType;
return indexChangeWidget();
}
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (state.selectType.value == "1") {
state.beginTime.value = DateTool().dateToYMDHNString(
DateTime.now().millisecondsSinceEpoch.toString()); //
state.endTime.value = DateTool().dateToYMDHNString(
DateTime.now().millisecondsSinceEpoch.toString()); //
} else {
state.beginTime.value = ""; //
state.endTime.value = ""; //
state.tabController = TabController(
vsync: this,
length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length,
initialIndex: 0);
state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) {
state.selectType.value = state.tabController.index.toString();
});
if (state.tabController.animation!.value == state.tabController.index) {
FocusScope.of(context).requestFocus(FocusNode());
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle:
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.face!.tr}",
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
children: [
_tabBar(),
_pageWidget(),
],
),
);
}
Widget indexChangeWidget() {
switch (int.parse(widget.selectType)) {
switch (int.parse(state.selectType.value)) {
case 0:
{
//
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyBottomWidget()
],
return SingleChildScrollView(
child: Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyBottomWidget()
],
),
);
}
case 1:
{
//
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyTimeLimitWidget(),
keyBottomWidget()
],
return SingleChildScrollView(
child: Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyTimeLimitWidget(),
keyBottomWidget()
],
),
);
}
case 2:
{
//
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyCyclicDate(),
SizedBox(height: 10.h),
keyBottomWidget()
],
return SingleChildScrollView(
child: Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyCyclicDate(),
SizedBox(height: 10.h),
keyBottomWidget()
],
),
);
}
default:
@ -138,24 +143,24 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.beginTime.value,
rightTitle: state.timeLimitBeginTime.value,
isHaveLine: true,
isHaveDirection: true,
action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
});
state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.endTime.value,
rightTitle: state.timeLimitEndTime.value,
isHaveDirection: true,
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
});
state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Container(height: 10.h),
],
@ -168,47 +173,44 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle: "${state.beginTime.value}\n${state.endTime.value}",
rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}",
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
Get.log(
'得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
}
})),
Obx(() => Visibility(
visible: state.weekdaysList.isNotEmpty ? true : false,
child: CommonItem(
leftTitel: "有效日",
leftTitel: "有效日".tr,
rightTitle: state.weekdaysList.value.join(",").toString(),
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
}
@ -217,25 +219,22 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem(
leftTitel: "有效时间".tr,
rightTitle:
"${state.effectiveDateTime.value}-${state.failureDateTime.value}",
rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}",
isHaveDirection: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
Get.back(result: result);
}
}))),
],
@ -338,4 +337,69 @@ class _AddFaceTypePageState extends State<AddFaceTypePage> {
},
);
}
final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"),
];
final List<ItemView> _fromCheckInTypeItemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
];
TabBar _tabBar() {
return TabBar(
controller: state.tabController,
onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode());
},
tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.map((ItemView item) => _tab(item)).toList(),
isScrollable: true,
indicatorColor: Colors.red,
unselectedLabelColor: Colors.black,
unselectedLabelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
),
automaticIndicatorColorAdjustment: true,
labelColor: AppColors.mainColor,
labelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
fontWeight: FontWeight.w600),
indicator: CustomUnderlineTabIndicator(
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
strokeCap: StrokeCap.round,
width: 30.w),
);
}
Tab _tab(ItemView item) {
return Tab(
child: SizedBox(
width: 1.sw / 5,
child: Text(item.title, textAlign: TextAlign.center)));
}
Widget _pageWidget() {
return Expanded(
child: TabBarView(
controller: state.tabController,
children:
state.fromType.value == 1
? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList()
: _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(),
),
);
}
}
class ItemView {
const ItemView({required this.title, required this.selectType});
final String title;
final String selectType;
}

View File

@ -1,30 +1,33 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../../tools/dateTool.dart';
class AddFaceTypeState {
final lockId = 0.obs;
final selectType = "0".obs; // 0 1 2
final fromType = 1.obs; // // 1 2
var fromTypeTwoStaffName = "".obs; //
final isStressFingerprint = false.obs;
final isAdministrator = false.obs; //
var beginTime = "".obs; //
var endTime = "".obs; //
var effectiveDateTime = "".obs; //
var failureDateTime = "".obs; //
var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var cycleBeginTime = "".obs;//
var cycleEndTime = "".obs;//
var effectiveDateTime = "".obs;//
var failureDateTime = "".obs;//
var weekdaysList = [].obs;
var fromTypeTwoStaffName = "".obs; //
final TextEditingController nameController = TextEditingController();
late TabController tabController;
AddFaceTypeState() {
// Map map = Get.arguments;
// lockId.value = map["lockId"];
// fromType.value = map["fromType"];
// if(fromType.value == 2){
// fromTypeTwoStaffName = map["fromTypeTwoStaffName"]; //
// // nameController.text = fromTypeTwoStaffName.value;
// }
// print("lockId:${lockId.value} fromType:${fromType.value}");
Map map = Get.arguments;
lockId.value = map["lockId"];
fromType.value = map["fromType"];
// 1 2
if(fromType.value == 2){
fromTypeTwoStaffName.value = map["fromTypeTwoStaffName"]; //
}
}
}

View File

@ -79,7 +79,7 @@ class _FaceListPageState extends State<FaceListPage> {
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}',
onClick: () async {
var data =
await Get.toNamed(Routers.addFaceTypeManagePage, arguments: {
await Get.toNamed(Routers.addFaceTypePage, arguments: {
"lockId": state.lockId.value,
"fromType": 1 // 1 2
});

View File

@ -72,44 +72,50 @@ class _AddFingerprintTypePageState extends State<AddFingerprintTypePage> with Si
{
//
// return sendElectronicKeySucceed();
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyBottomWidget()
],
return SingleChildScrollView(
child: Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyBottomWidget()
],
),
);
}
case 1:
{
//
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyTimeLimitWidget(),
SizedBox(height: 10.h),
keyBottomWidget()
],
return SingleChildScrollView(
child: Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyTimeLimitWidget(),
SizedBox(height: 10.h),
keyBottomWidget()
],
),
);
}
case 2:
{
//
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyCyclicDate(),
SizedBox(height: 10.h),
keyBottomWidget()
],
return SingleChildScrollView(
child: Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyCyclicDate(),
SizedBox(height: 10.h),
keyBottomWidget()
],
),
);
}
default:

View File

@ -74,10 +74,10 @@ class LockEscalationLogic extends BaseGetXController {
if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var signKey = await Storage.getStringList(saveBlueSignKey);
List<int> signKeyDataList = changeStringListToIntList(signKey!);
String lockID = CommonDataManage.shareManager()
?.currentLockSetInfoData
String lockID = CommonDataManage.shareManager()?.currentLockSetInfoData
.lockId
?.toString() ??
'';

View File

@ -8,34 +8,67 @@ import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/CustomUnderlineTabIndicator.dart';
import '../../../../tools/commonItem.dart';
import '../../../../tools/dateTool.dart';
import '../../../../tools/storage.dart';
import '../../../../tools/submitBtn.dart';
import '../../../../tools/titleAppBar.dart';
import '../../../../translations/trans_lib.dart';
import 'addRemoteControl_logic.dart';
class AddRemoteControlPage extends StatefulWidget {
final String selectType;
const AddRemoteControlPage({Key? key, required this.selectType})
const AddRemoteControlPage({Key? key})
: super(key: key);
@override
State<AddRemoteControlPage> createState() => _AddRemoteControlPageState();
}
class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
class _AddRemoteControlPageState extends State<AddRemoteControlPage> with SingleTickerProviderStateMixin {
final logic = Get.put(AddRemoteControlLoigc());
final state = Get.find<AddRemoteControlLoigc>().state;
@override
void initState() {
// TODO: implement initState
super.initState();
state.tabController = TabController(
vsync: this,
length: state.fromType.value == 1 ? _itemTabs.length : _fromCheckInTypeItemTabs.length,
initialIndex: 0);
state.tabController.addListener(() {
WidgetsBinding.instance.addPostFrameCallback((_) {
state.selectType.value = state.tabController.index.toString();
});
if (state.tabController.animation!.value == state.tabController.index) {
FocusScope.of(context).requestFocus(FocusNode());
}
});
}
@override
Widget build(BuildContext context) {
return indexChangeWidget();
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle:
"${TranslationLoader.lanKeys!.addTip!.tr}${TranslationLoader.lanKeys!.fingerprint!.tr}",
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
children: [
_tabBar(),
_pageWidget(),
],
),
);
}
Widget indexChangeWidget() {
switch (int.parse(widget.selectType)) {
switch (int.parse(state.selectType.value)) {
case 0:
{
//
@ -68,37 +101,18 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
case 2:
{
//
return Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle: "",
isHaveDirection: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage,
arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.beginTime.value,
'endDate': state.endTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if(result != null && result.isNotEmpty){
state.weekdaysList.value = result['validityValue'];
state.beginTime.value = result['starDate'];
state.endTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
Get.log('得到的有效期数据:${state.weekdaysList.value} == ${state.beginTime.value} == ${state.endTime.value}== ${state.effectiveDateTime.value} == ${state.failureDateTime.value}');
}
}),
SizedBox(height: 10.h),
keyBottomWidget()
],
return SingleChildScrollView(
child: Column(
children: [
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
state.nameController),
keyCyclicDate(),
SizedBox(height: 10.h),
keyBottomWidget()
],
),
);
}
default:
@ -127,29 +141,104 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.beginTime.value,
rightTitle: state.timeLimitBeginTime.value,
isHaveLine: true,
isHaveDirection: true,
action: () async {
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.beginTime.value = DateTool().getYMDHNDateString(p, 1);
});
state.timeLimitBeginTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
rightTitle: state.endTime.value,
rightTitle: state.timeLimitEndTime.value,
isHaveDirection: true,
action: () {
Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) {
state.endTime.value = DateTool().getYMDHNDateString(p, 1);
});
Pickers.showDatePicker(context, mode: DateMode.YMDHM,
onConfirm: (p) {
state.timeLimitEndTime.value = DateTool().getYMDHNDateString(p, 1);
});
})),
Container(height: 10.h),
],
);
}
//
Widget keyCyclicDate() {
return Column(
children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
rightTitle:"${state.cycleBeginTime.value}\n${state.cycleEndTime.value}",
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
}
})),
Obx(() => Visibility(
visible: state.weekdaysList.isNotEmpty ? true : false,
child: CommonItem(
leftTitel: "有效日".tr,
rightTitle: state.weekdaysList.value.join(",").toString(),
isHaveDirection: true,
isHaveLine: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
}
}))),
Obx(() => Visibility(
visible: state.effectiveDateTime.value.isNotEmpty,
child: CommonItem(
leftTitel: "有效时间".tr,
rightTitle: "${state.effectiveDateTime.value}-${state.failureDateTime.value}",
isHaveDirection: true,
action: () async {
var result = await Get.toNamed(Routers.seletKeyCyclicDatePage, arguments: {
'validityValue': state.weekdaysList.value,
'starDate': state.cycleBeginTime.value,
'endDate': state.cycleEndTime.value,
'starTime': state.effectiveDateTime.value,
'endTime': state.failureDateTime.value
});
if (result != null && result.isNotEmpty) {
state.weekdaysList.value = result['validityValue'];
state.cycleBeginTime.value = result['starDate'];
state.cycleEndTime.value = result['endDate'];
state.effectiveDateTime.value = result['starTime'];
state.failureDateTime.value = result['endTime'];
}
}))),
],
);
}
Widget keyBottomWidget() {
return Column(
children: [
@ -310,4 +399,69 @@ class _AddRemoteControlPageState extends State<AddRemoteControlPage> {
},
);
}
final List<ItemView> _itemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, selectType: "2"),
];
final List<ItemView> _fromCheckInTypeItemTabs = <ItemView>[
ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, selectType: "0"),
ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, selectType: "1"),
];
TabBar _tabBar() {
return TabBar(
controller: state.tabController,
onTap: (index) {
FocusScope.of(context).requestFocus(FocusNode());
},
tabs: state.fromType.value == 1 ? _itemTabs.map((ItemView item) => _tab(item)).toList() : _fromCheckInTypeItemTabs.map((ItemView item) => _tab(item)).toList(),
isScrollable: true,
indicatorColor: Colors.red,
unselectedLabelColor: Colors.black,
unselectedLabelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
),
automaticIndicatorColorAdjustment: true,
labelColor: AppColors.mainColor,
labelStyle: TextStyle(
color: AppColors.mainColor,
fontSize: 24.sp,
fontWeight: FontWeight.w600),
indicator: CustomUnderlineTabIndicator(
borderSide: BorderSide(color: AppColors.mainColor, width: 4.w),
strokeCap: StrokeCap.round,
width: 30.w),
);
}
Tab _tab(ItemView item) {
return Tab(
child: SizedBox(
width: 1.sw / 5,
child: Text(item.title, textAlign: TextAlign.center)));
}
Widget _pageWidget() {
return Expanded(
child: TabBarView(
controller: state.tabController,
children:
state.fromType.value == 1
? _itemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList()
: _fromCheckInTypeItemTabs.map((ItemView item) => Obx(() => indexChangeWidget())).toList(),
),
);
}
}
class ItemView {
const ItemView({required this.title, required this.selectType});
final String title;
final String selectType;
}

View File

@ -2,13 +2,39 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class AddRemoteControlState{
import '../../../../tools/dateTool.dart';
var beginTime = "".obs;//
var endTime = "".obs;//
class AddRemoteControlState{
final lockId = 0.obs;
final selectType = "0".obs;// 0 1 2
final fromType = 1.obs; // // 1 2
final isStressFingerprint = false.obs;
final isAdministrator = false.obs;//
var timeLimitBeginTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var timeLimitEndTime = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()).obs;//
var cycleBeginTime = "".obs;//
var cycleEndTime = "".obs;//
var effectiveDateTime = "".obs;//
var failureDateTime = "".obs;//
var weekdaysList = [].obs;
var fromTypeTwoStaffName = "".obs; //
final TextEditingController nameController = TextEditingController();
late TabController tabController;
AddRemoteControlState() {
Map map = Get.arguments;
if(map["lockId"]!=null){
lockId.value = map["lockId"];
}
if(map["fromType"]!=null){
fromType.value = map["fromType"];
// 1 2
if(fromType.value == 2){
fromTypeTwoStaffName.value = map["fromTypeTwoStaffName"]; //
}
}
}
}

View File

@ -6,6 +6,7 @@ import 'package:get/get.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';
@ -69,7 +70,10 @@ class _RemoteControlListPageState extends State<RemoteControlListPage> {
'${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.remoteControl!.tr}',
onClick: () async {
var data =
await Get.toNamed(Routers.addRemoteControlManagePage);
await Get.toNamed(Routers.addRemoteControlPage, arguments: {
"lockId": CommonDataManage().currentLockSetInfoData.lockId,
"fromType": 1 // 1 2
});
if (data != null) {
//

View File

@ -298,6 +298,7 @@ class NearbyLockLogic extends BaseGetXController {
IoSenderManage.senderGetStarLockStatuInfo(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
isBeforeAddUser: true,
privateKey: getPrivateKeyList,
);
@ -343,6 +344,7 @@ class NearbyLockLogic extends BaseGetXController {
IoSenderManage.senderGetStarLockStatuInfo(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
isBeforeAddUser: true,
privateKey: getPrivateKeyList,
);
} else if (state == BluetoothConnectionState.disconnected) {

View File

@ -86,7 +86,8 @@ class SaveLockLogic extends BaseGetXController {
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
token: token);
token: token,
isBeforeAddUser: true);
break;
case 0x07:
//
@ -234,7 +235,8 @@ class SaveLockLogic extends BaseGetXController {
needAuthor:1,
publicKey:publicKeyDataList,
privateKey:getPrivateKeyList,
token: getTokenList
token: getTokenList,
isBeforeAddUser: true
);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
dismissEasyLoading();