feat: 1,新增电子反锁UI及本地功能

2,新增可视门铃码国际化UI及本地功能
	3,新增双重认证UI及本地功能
	4,新增双锁联动UI及本地功能
This commit is contained in:
“DaisyWu” 2024-12-17 17:07:59 +08:00
parent 3200df7793
commit eb1c018581
7 changed files with 422 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_main_page.dart';
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeCustomMode/catEyeCustomMode_page.dart';
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/catEyeSet/catEyeSet_page.dart';
import 'package:star_lock/main/lockDetail/lockSet/catEyeSet/videoSlot/videoSlot_page.dart';
import 'package:star_lock/main/lockDetail/lockSet/double_lock_link/double_lock_link_page.dart';
import 'package:star_lock/main/lockDetail/lockSet/faceUnlock/faceUnlock_page.dart';
import 'package:star_lock/main/lockDetail/lockSet/liveVideo/liveVideo_page.dart';
import 'package:star_lock/main/lockDetail/lockSet/motorPower/motorPower_page.dart';
@ -509,6 +510,7 @@ abstract class Routers {
static const String login = '/login'; //
static const String amazonAlexaPage = '/amazonAlexaPage'; //AmazonAlexa
static const String googleHomePage = '/googleHomePage'; //GoogleHome
static const String doubleLockLinkPage = '/doubleLockLinkPage'; //
}
abstract class AppRouters {
@ -1183,5 +1185,8 @@ abstract class AppRouters {
GetPage<dynamic>(
name: Routers.gatewayGetWifiListPage,
page: () => const GatewayGetWifiListPage()),
GetPage<dynamic>(
name: Routers.doubleLockLinkPage,
page: () => const DoubleLockLinkPage()),
];
}

View File

@ -0,0 +1,54 @@
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/lockSet/double_lock_link/double_lock_link_state.dart';
import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart';
import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectLockListEntity.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
class DoubleLockLinkLogic extends BaseGetXController {
final DoubleLockLinkState state = DoubleLockLinkState();
//
Future<SelectLockListEntity> mockNetworkDataRequest() async {
final SelectLockListEntity entity = await ApiRepository.to
.selectLockList(searchStr: state.searchController.text);
List<LockItemData> dataList = <LockItemData>[];
if (entity.errorCode!.codeIsSuccessful) {
dataList = entity.data!.list!;
state.lockItemList.value = dataList;
for (int i = 0; i < dataList.length; i++) {
final LockItemData itemData = dataList[i];
if (itemData.appUnlockOnline == 1) {
state.selectLockIdList.add(itemData.lockId);
}
}
}
return entity;
}
//APP开锁时需手机联网的锁
Future<void> setAppUnlockMustOnlineRequest() async {
final SelectLockListEntity entity =
await ApiRepository.to.setAppUnlockMustOnline(state.selectLockIdList);
if (entity.errorCode!.codeIsSuccessful) {
showToast('操作成功'.tr);
//--
if (Get.isRegistered<LockMainLogic>()) {
Get.find<LockMainLogic>().getStarLockInfo(isUnShowLoading: true);
}
}
}
@override
void onReady() {
super.onReady();
// mockNetworkDataRequest();
}
@override
void onInit() {
super.onInit();
}
}

View File

@ -0,0 +1,149 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/main/lockDetail/lockSet/double_lock_link/double_lock_link_logic.dart';
import 'package:star_lock/main/lockDetail/lockSet/double_lock_link/double_lock_link_state.dart';
import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectLockListEntity.dart';
import 'package:star_lock/tools/keySearchWidget.dart';
import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/tools/submitBtn.dart';
import 'package:star_lock/tools/titleAppBar.dart';
class DoubleLockLinkPage extends StatefulWidget {
const DoubleLockLinkPage({Key? key}) : super(key: key);
@override
State<DoubleLockLinkPage> createState() => _DoubleLockLinkPageState();
}
class _DoubleLockLinkPageState extends State<DoubleLockLinkPage> {
final DoubleLockLinkLogic logic = Get.put(DoubleLockLinkLogic());
final DoubleLockLinkState state = Get.find<DoubleLockLinkLogic>().state;
// ID
int? _selectedLockId;
Future<void> getHttpData() async {
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
logic.mockNetworkDataRequest().then((SelectLockListEntity value) {
setState(() {});
});
}
}
@override
void initState() {
super.initState();
getHttpData();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
resizeToAvoidBottomInset: false,
appBar: TitleAppBar(
barTitle: '双锁联动'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: Obx(
() => state.lockItemList.value.isEmpty
? NoData()
: Column(
children: <Widget>[
KeySearchWidget(
editingController: state.searchController,
onSubmittedAction: () {
state.lockItemList.value = [];
logic.mockNetworkDataRequest();
},
),
Container(
padding: EdgeInsets.all(15.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text(
'对于当前拥有的锁和选中的锁,其中任意一把开启/关闭,另外一把则自动开启/关闭'.tr,
style: TextStyle(fontSize: 22.sp),
),
),
],
),
),
SizedBox(height: 15.h),
Expanded(
child: ListView.builder(
itemCount: state.lockItemList.value.length,
itemBuilder: (BuildContext c, int index) {
final LockItemData itemData =
state.lockItemList.value[index];
return _gatewatListItem(itemData);
},
),
),
SubmitBtn(
btnName: '确定'.tr,
onClick: () {
logic.showToast('关联成功'.tr);
Get.back();
},
),
SizedBox(
height: 40.h,
),
],
),
),
);
}
Widget _gatewatListItem(LockItemData itemData) {
return GestureDetector(
onTap: () {
setState(() {
// ID
_selectedLockId = itemData.lockId;
});
},
child: Container(
height: 80.h,
margin: const EdgeInsets.only(bottom: 2),
padding:
EdgeInsets.only(left: 10.w, right: 20.w, top: 20.h, bottom: 20.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.w),
),
child: Row(
children: <Widget>[
SizedBox(
width: 15.w,
),
Image.asset(
_selectedLockId == itemData.lockId
? 'images/icon_round_select.png'
: 'images/icon_round_unSelect.png',
width: 30.w,
height: 30.w,
),
SizedBox(
width: 10.w,
),
Expanded(
child: Text(
itemData.lockAlias ?? '',
style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w600),
),
),
],
),
),
);
}
}

View File

@ -0,0 +1,11 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/mineSet/appUnlockNeedMobileNetworkingLock/selectLockListEntity.dart';
class DoubleLockLinkState {
RxList<LockItemData> lockItemList = <LockItemData>[].obs;
List selectLockIdList = [];
RxBool isCheckAll = false.obs;
final TextEditingController searchController = TextEditingController();
}

View File

@ -3,9 +3,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:star_lock/blue/blue_manage.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart';
import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSet_state.dart';
import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart';
import 'package:star_lock/tools/showCupertinoAlertView.dart';
import '../../../../appRouters.dart';
import '../../../../app_settings/app_colors.dart';
@ -317,6 +320,21 @@ class _LockSetPageState extends State<LockSetPage>
'lockSetInfoData': state.lockSetInfoData.value
});
}))),
//todo
//
Obx(() => CommonItem(
leftTitel: '电子反锁'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _elecAntiLockSwitch())),
//
Obx(() => CommonItem(
leftTitel: '可视门铃码'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _visualDoorbellCodeSwitch())),
SizedBox(height: 10.h),
//
Obx(() => Visibility(
@ -335,6 +353,25 @@ class _LockSetPageState extends State<LockSetPage>
'lockSetInfoData': state.lockSetInfoData.value
});
}))),
//todo: API接口
//
Obx(() => Visibility(
visible: true,
child: CommonItem(
leftTitel: '双重认证'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: _dualAuthSwitch()))),
//
CommonItem(
leftTitel: '双锁联动'.tr,
rightTitle: '未关联'.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.doubleLockLinkPage);
}),
//
Obx(() => Visibility(
visible: state.lockFeature.value.remoteUnlock == 1,
@ -710,6 +747,64 @@ class _LockSetPageState extends State<LockSetPage>
);
}
//
CupertinoSwitch _elecAntiLockSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isElecAntiLock.value == 1,
onChanged: state.sureBtnState.value == 1
? null
: (bool value) {
setState(() {
state.isElecAntiLock.value = value ? 1 : 0;
});
},
);
}
//
CupertinoSwitch _visualDoorbellCodeSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isVisualDoorbellCode.value == 1,
onChanged: state.sureBtnState.value == 1
? null
: (bool value) {
setState(() {
state.isVisualDoorbellCode.value = value ? 1 : 0;
if (state.isVisualDoorbellCode.value == 1) {
ShowCupertinoAlertView().showVisualDoorbellCodeAlert(
widgetContext: context,
qrCodeUrl: BlueManage().connectDeviceName,
qrCodeText: '请扫描可视门铃码二维码'.tr,
);
} else {}
});
},
);
}
//
CupertinoSwitch _dualAuthSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isDualAuth.value == 1,
onChanged: state.sureBtnState.value == 1
? null
: (bool value) {
setState(() {
state.isDualAuth.value = value ? 1 : 0;
});
},
);
}
//
// CupertinoSwitch _lockExceptionWarningsSwitch() {
// return CupertinoSwitch(

View File

@ -22,13 +22,16 @@ class LockSetState {
RxInt isOpenBlueBroadcast = 0.obs; // 广
RxInt isOpenExceptionWarnings = 0.obs; //
RxInt isOpenStayWarn = 0.obs; //
RxInt isElecAntiLock = 0.obs; //
RxInt isVisualDoorbellCode = 0.obs; //
RxInt isDualAuth = 0.obs; //
TextEditingController passwordTF = TextEditingController();
int settingUpSupportFeatures = 0;
RxBool ifCurrentScreen = true.obs; // ,
RxBool deleteAdministratorIsHaveAllData = false.obs; //
RxInt sureBtnState = 0.obs;// 0() 1()
RxInt sureBtnState = 0.obs; // 0() 1()
final ShowTipView showTipView = ShowTipView();
LockSetState() {

View File

@ -1,16 +1,24 @@
import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/tools/submitBtn.dart';
typedef AuthInfoCallback = void Function(String? idCard, String? name);
class ShowCupertinoAlertView {
bool isSystemEmailSelected = true; //
final GlobalKey _repaintBoundaryKey = GlobalKey();
//
void showQRImageAlert(
@ -138,7 +146,7 @@ class ShowCupertinoAlertView {
style: TextStyle(color: Colors.white, fontSize: 22.sp),
)),
),
SizedBox(width:2.w)
SizedBox(width: 2.w)
// Expanded(
// child: SizedBox(
// width: 2.w,
@ -395,6 +403,101 @@ class ShowCupertinoAlertView {
);
}
//
void showVisualDoorbellCodeAlert(
{required BuildContext widgetContext,
required String qrCodeUrl,
required String qrCodeText}) {
showCupertinoModalPopup(
context: widgetContext,
builder: (BuildContext context) {
return CupertinoActionSheet(
actions: <Widget>[
Container(
color: Colors.white, //
child: CupertinoActionSheetAction(
child: Container(
margin: const EdgeInsets.all(0),
child: Column(
children: <Widget>[
SizedBox(
height: 60.h,
),
if (qrCodeUrl.isNotEmpty)
RepaintBoundary(
key: _repaintBoundaryKey,
child: SizedBox(
width: 200,
height: 200,
child: QrImageView(
data: qrCodeUrl,
version: QrVersions.auto,
size: 200.0,
),
),
)
else
Container(),
SizedBox(
height: 20.h,
),
Padding(
padding: EdgeInsets.only(
left: 60.w, right: 60.w, bottom: 30),
child: Text(
qrCodeText,
style:
TextStyle(fontSize: 24.sp, color: Colors.black),
)),
Container(
margin: EdgeInsets.only(left: 60.w, right: 60.w),
child: OutLineBtn(
btnName: '保存到相册'.tr,
onClick: () async {
//
try {
final RenderRepaintBoundary boundary =
_repaintBoundaryKey.currentContext!
.findRenderObject()!
as RenderRepaintBoundary;
final image = await boundary.toImage();
final ByteData? byteData = await image
.toByteData(format: ImageByteFormat.png);
final Uint8List pngBytes =
byteData!.buffer.asUint8List();
final result =
await ImageGallerySaver.saveImage(
Uint8List.fromList(pngBytes),
quality: 100,
name: 'qr_code');
if (result['isSuccess']) {
EasyLoading.showToast('保存成功'.tr);
} else {
EasyLoading.showToast('保存失败'.tr);
}
} catch (e) {
EasyLoading.showToast('保存失败'.tr);
}
}),
),
SizedBox(
height: 40.h,
)
],
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
),
],
);
},
);
}
// //
// void emailNotifyTypeSlectAlert() {
// showCupertinoDialog(