From 87e61960c3adc559a53a5ce1556c936afd303315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Tue, 19 Mar 2024 18:04:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E9=94=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=A8=AA=E5=90=91=E5=88=B7=E6=96=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98=202=E3=80=81=E9=94=81=E8=AF=A6=E6=83=85=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=94=81=E7=8A=B6=E6=80=81(=E5=BE=85=E7=94=9F?= =?UTF-8?q?=E6=95=88=E3=80=81=E6=AD=A3=E5=B8=B8=E4=BD=BF=E7=94=A8=E3=80=81?= =?UTF-8?q?=E5=B7=B2=E8=BF=87=E6=9C=9F=E7=AD=89=E7=8A=B6=E6=80=81)=203?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E5=A4=8D=E6=89=80=E6=9C=89=E5=AE=89=E5=8D=93?= =?UTF-8?q?=E6=9C=BA=E5=9E=8B=EF=BC=8C=E5=B7=A6=E6=BB=91=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=204=E3=80=81=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E3=80=81?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E3=80=81=E5=BF=98=E8=AE=B0=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E7=AD=89=E6=A8=A1=E5=9D=97=E5=88=87=E6=8D=A2=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E6=A1=86=E9=9C=80=E4=BA=8C=E6=AC=A1=E7=82=B9=E5=87=BB=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../starLock_forgetPassword_page.dart | 8 +- .../lib/login/login/starLock_login_page.dart | 33 +-- .../lib/login/login/starLock_login_state.dart | 3 + .../register/starLock_register_page.dart | 8 +- .../authorizedAdminList_page.dart | 5 +- .../card/addCardType/addCardType_page.dart | 6 +- .../card/addICCard/addICCard_page.dart | 2 +- .../card/cardList/cardList_logic.dart | 15 +- .../card/cardList/cardList_page.dart | 7 +- .../checkingInStaffList_page.dart | 1 + .../electronicKeyList_page.dart | 8 +- .../face/addFaceType/addFaceType_page.dart | 4 +- .../addFingerprintType_page.dart | 19 +- .../fingerprintList_logic.dart | 16 +- .../fingerprintList/fingerprintList_page.dart | 25 +- .../lockDetail/lockDetail_logic.dart | 24 +- .../lockDetail/lockDetail_page.dart | 241 ++++++++++-------- .../lockDetail/lockDetail_state.dart | 3 +- .../basicInformation_state.dart | 6 +- .../editLockName/editLockName_page.dart | 2 +- .../lockSet/lockTime/lockTime_logic.dart | 140 ++++++---- .../lockSet/lockTime/lockTime_state.dart | 1 + .../passwordKeyList/passwordKeyList_page.dart | 7 +- .../lockMian/lockList/lockList_logic.dart | 27 +- .../main/lockMian/lockList/lockList_page.dart | 9 +- .../lockMian/lockMain/lockMain_logic.dart | 2 +- .../main/lockMian/lockMain/lockMain_page.dart | 1 + .../message/messageList/messageList_page.dart | 1 + .../minePersonInfoEditIphone_page.dart | 4 +- .../minePersonInfoEditName_page.dart | 2 +- .../mineBindPhoneOrEmail_page.dart | 4 +- .../minePersonInfoResetPassword_page.dart | 6 +- star_lock/lib/tools/EasyRefreshTool.dart | 1 + star_lock/lib/tools/dateTool.dart | 24 ++ star_lock/lib/tools/tf_loginInput.dart | 106 ++++---- 35 files changed, 433 insertions(+), 338 deletions(-) diff --git a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart index a017903b..59d29e1d 100644 --- a/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart +++ b/star_lock/lib/login/forgetPassword/starLock_forgetPassword_page.dart @@ -88,7 +88,7 @@ class _StarLockForgetPasswordPageState height: 0.5.h, color: Colors.grey, ), - LoginInput( + LoginInput().tfInput( controller: state.phoneController, onchangeAction: (v) { logic.checkNext(state.phoneController); @@ -107,7 +107,7 @@ class _StarLockForgetPasswordPageState LengthLimitingTextInputFormatter(30), ]), SizedBox(height: 10.h), - LoginInput( + LoginInput().tfInput( controller: state.pwdController, onchangeAction: (v) { logic.checkNext(state.pwdController); @@ -134,7 +134,7 @@ class _StarLockForgetPasswordPageState color: AppColors.placeholderTextColor, fontSize: 20.sp), ), SizedBox(height: 10.w), - LoginInput( + LoginInput().tfInput( controller: state.sureController, onchangeAction: (v) { logic.checkNext(state.sureController); @@ -158,7 +158,7 @@ class _StarLockForgetPasswordPageState Row( children: [ Expanded( - child: LoginInput( + child: LoginInput().tfInput( controller: state.codeController, onchangeAction: (v) { logic.checkNext(state.codeController); diff --git a/star_lock/lib/login/login/starLock_login_page.dart b/star_lock/lib/login/login/starLock_login_page.dart index 8b5d8438..c349dae8 100644 --- a/star_lock/lib/login/login/starLock_login_page.dart +++ b/star_lock/lib/login/login/starLock_login_page.dart @@ -1,11 +1,8 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/flavors.dart'; -import 'package:star_lock/tools/appFirstEnterHandle.dart'; -import 'package:star_lock/tools/storage.dart'; import '../../appRouters.dart'; import '../../app_settings/app_colors.dart'; @@ -57,42 +54,34 @@ class _StarLockLoginPageState extends State { child: Image.asset('images/icon_main_1024.png', width: 110.w, height: 110.w))), SizedBox(height: 50.w), - LoginInput( + LoginInput().tfInput( controller: state.emailOrPhoneController, onchangeAction: (v) { logic.checkNext(state.emailOrPhoneController); }, - leftWidget: Padding( - padding: EdgeInsets.only( - top: 30.w, bottom: 20.w, right: 20.w, left: 5.w), - child: Image.asset( - 'images/icon_login_account.png', - width: 36.w, - height: 36.w, - ), + leftWidget: Image.asset( + 'images/icon_login_account.png', + width: 36.w, + height: 36.w, ), hintText: TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, - keyboardType: TextInputType.number, + // keyboardType: TextInputType.number, inputFormatters: [ // FilteringTextInputFormatter.allow(RegExp('[0-9]')), LengthLimitingTextInputFormatter(30), ]), SizedBox(height: 10.h), - LoginInput( + LoginInput().tfInput( controller: state.pwdController, onchangeAction: (v) { logic.checkNext(state.pwdController); }, isPwd: true, - leftWidget: Padding( - padding: EdgeInsets.only( - top: 30.w, bottom: 20.w, right: 20.w, left: 5.w), - child: Image.asset( - 'images/icon_login_password.png', - width: 36.w, - height: 36.w, - ), + leftWidget: Image.asset( + 'images/icon_login_password.png', + width: 36.w, + height: 36.w, ), hintText: "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}", diff --git a/star_lock/lib/login/login/starLock_login_state.dart b/star_lock/lib/login/login/starLock_login_state.dart index 37d65040..5d79baf6 100644 --- a/star_lock/lib/login/login/starLock_login_state.dart +++ b/star_lock/lib/login/login/starLock_login_state.dart @@ -13,6 +13,9 @@ class StarLockLoginState { TextEditingController emailOrPhoneController = TextEditingController(); TextEditingController pwdController = TextEditingController(); + late FocusNode myFocusNode1; + late FocusNode myFocusNode2; + StarLockLoginState() { // emailOrPhone.value = StoreService.to.getLastUserAccount() as String; emailOrPhoneController.text = emailOrPhone.value; diff --git a/star_lock/lib/login/register/starLock_register_page.dart b/star_lock/lib/login/register/starLock_register_page.dart index 0f7c57ac..0f1c25d6 100644 --- a/star_lock/lib/login/register/starLock_register_page.dart +++ b/star_lock/lib/login/register/starLock_register_page.dart @@ -196,7 +196,7 @@ class _StarLockRegisterPageState extends State { Widget middleTFWidget() { return Column( children: [ - LoginInput( + LoginInput().tfInput( controller: state.phoneOrEmailController, onchangeAction: (v) { logic.checkNext(state.phoneOrEmailController); @@ -218,7 +218,7 @@ class _StarLockRegisterPageState extends State { LengthLimitingTextInputFormatter(30), ]), SizedBox(height: 10.w), - LoginInput( + LoginInput().tfInput( controller: state.pwdController, onchangeAction: (v) { logic.checkNext(state.pwdController); @@ -244,7 +244,7 @@ class _StarLockRegisterPageState extends State { TextStyle(color: AppColors.placeholderTextColor, fontSize: 20.sp), ), SizedBox(height: 10.w), - LoginInput( + LoginInput().tfInput( controller: state.sureController, onchangeAction: (v) { logic.checkNext(state.sureController); @@ -267,7 +267,7 @@ class _StarLockRegisterPageState extends State { Row( children: [ Expanded( - child: LoginInput( + child: LoginInput().tfInput( controller: state.codeController, onchangeAction: (v) { logic.checkNext(state.codeController); diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index c925c2a8..12e3a905 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -78,8 +78,8 @@ class _AuthorizedAdminListPageState extends State { "keyInfo": state.keyInfo.value }).then((val) { if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); + logic.pageNo = 1; + mockRequest(); } }); }, @@ -130,6 +130,7 @@ class _AuthorizedAdminListPageState extends State { backgroundColor: Colors.red, foregroundColor: Colors.white, label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), ), ], ), diff --git a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart index 9b521b34..863320be 100644 --- a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart +++ b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_page.dart @@ -40,7 +40,9 @@ class _AddCardPageState extends State { Widget build(BuildContext context) { state.selectType.value = widget.selectType; state.lockId.value = widget.lockId; - state.nameController.text = widget.fromTypeTwoStaffName; + if(widget.fromTypeTwoStaffName.isNotEmpty){ + state.nameController.text = widget.fromTypeTwoStaffName; + } state.fromType.value = widget.fromType; WidgetsBinding.instance.addPostFrameCallback((_) { @@ -75,7 +77,7 @@ class _AddCardPageState extends State { TranslationLoader.lanKeys!.pleaseEnter!.tr, state.nameController), keyTimeLimitWidget(), - SizedBox(height: 10.h), + // SizedBox(height: 10.h), keyBottomWidget() ], ); diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart index c4fd4748..17fa4ef4 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart @@ -1,4 +1,4 @@ -import 'package:flutter/cupertino.dart'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart index f665f1e8..c55339ef 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -340,13 +340,18 @@ class CardListLogic extends BaseGetXController { ); if(entity.errorCode!.codeIsSuccessful){ if(state.isDeletAll == false){ - showToast("删除成功"); + showToast("删除成功", something: (){ + state.isDeletCardData = false; + pageNo = 1; + getICCardListData(); + }); }else{ - showToast("重置成功"); + showToast("重置成功", something: (){ + state.isDeletCardData = false; + pageNo = 1; + getICCardListData(); + }); } - - state.isDeletCardData = false; - getICCardListData(); } } diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart index b427e91a..1d35e5d7 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -88,7 +88,8 @@ class _CardListPageState extends State with RouteAware { KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { - logic.getICCardListData(); + logic.pageNo = 1; + getHttpData(); }, ), SizedBox(height: 20.h), @@ -103,7 +104,8 @@ class _CardListPageState extends State with RouteAware { "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 }); if (data != null) { - logic.getICCardListData(); + logic.pageNo = 1; + getHttpData(); } }, ), @@ -136,6 +138,7 @@ class _CardListPageState extends State with RouteAware { backgroundColor: Colors.red, foregroundColor: Colors.white, label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), ), ], ), diff --git a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart index 98208fbc..e1f15705 100644 --- a/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart +++ b/star_lock/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_page.dart @@ -76,6 +76,7 @@ class _CheckingInStaffListPageState extends State { backgroundColor: Colors.red, foregroundColor: Colors.white, label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), ), ], ), diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 2cac4ed1..ede2983b 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -86,7 +86,8 @@ class _ElectronicKeyListPageState extends State { KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { - logic.mockNetworkDataRequest(); + logic.pageNo = 1; + mockRequest(); }, ), SizedBox( @@ -106,8 +107,8 @@ class _ElectronicKeyListPageState extends State { "keyInfo": state.keyInfo.value }).then((val) { if (val != null) { - logic.mockNetworkDataRequest(); - setState(() {}); + logic.pageNo = 1; + mockRequest(); } }); }, @@ -166,6 +167,7 @@ class _ElectronicKeyListPageState extends State { backgroundColor: Colors.red, foregroundColor: Colors.white, label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), ), ], ), diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart index cb220a9c..4d40d918 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -39,7 +39,9 @@ class _AddFaceTypePageState extends State { Widget build(BuildContext context) { state.seletType.value = widget.selectType; state.lockId.value = widget.lockId; - state.nameController.text = widget.fromTypeTwoStaffName; + if(widget.fromTypeTwoStaffName.isNotEmpty){ + state.nameController.text = widget.fromTypeTwoStaffName; + } state.fromType.value = widget.fromType; return indexChangeWidget(); diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart index 37399952..fa4b10b9 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprintSelectType/addFingerprintType_page.dart @@ -40,7 +40,9 @@ class _AddFingerprintTypePageState extends State { Widget build(BuildContext context) { state.selectType.value = widget.selectType; state.lockId.value = widget.lockId; - state.nameController.text = widget.fromTypeTwoStaffName; + if(widget.fromTypeTwoStaffName.isNotEmpty){ + state.nameController.text = widget.fromTypeTwoStaffName; + } state.fromType.value = widget.fromType; WidgetsBinding.instance.addPostFrameCallback((_) { @@ -143,10 +145,7 @@ class _AddFingerprintTypePageState extends State { onConfirm: (p) { state.beginTime.value = '${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}'; - state.beginTimeTimestamp.value = - DateTime.parse(state.beginTime.value) - .millisecondsSinceEpoch - .toString(); + state.beginTimeTimestamp.value = DateTime.parse(state.beginTime.value).millisecondsSinceEpoch.toString(); }); })), Obx(() => CommonItem( @@ -156,12 +155,8 @@ class _AddFingerprintTypePageState extends State { action: () { Pickers.showDatePicker(context, mode: DateMode.YMDHM, onConfirm: (p) { - state.endTime.value = - '${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}'; - state.endTimeTimestamp.value = - DateTime.parse(state.endTime.value) - .millisecondsSinceEpoch - .toString(); + state.endTime.value = '${p.year}-${p.month!.toString().padLeft(2, '0')}-${p.day!.toString().padLeft(2, '0')} ${p.hour!.toString().padLeft(2, '0')}:${p.minute!.toString().padLeft(2, '0')}'; + state.endTimeTimestamp.value = DateTime.parse(state.endTime.value).millisecondsSinceEpoch.toString(); }); })), Container(height: 10.h), @@ -299,7 +294,7 @@ class _AddFingerprintTypePageState extends State { ], style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor), controller: state.nameController, - autofocus: false, + // autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( //输入里面输入文字内边距设置 diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index 4fa245be..8702e69c 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -334,6 +334,7 @@ class FingerprintListLogic extends BaseGetXController{ // 获取指纹列表 Future getFingerprintsListData() async{ + // state.fingerprintItemListData.value.clear(); FingerprintListDataEntity entity = await ApiRepository.to.getFingerprintsListData( lockId: state.lockId.value.toString(), pageNo: pageNo.toString(), @@ -372,13 +373,18 @@ class FingerprintListLogic extends BaseGetXController{ ); if(entity.errorCode!.codeIsSuccessful){ if(state.isDeletAll == false){ - showToast("删除成功"); + showToast("删除成功", something:(){ + state.isDeletFingerprintData = false; + pageNo = 1; + getFingerprintsListData(); + }); }else{ - showToast("重置成功"); + showToast("重置成功", something:(){ + state.isDeletFingerprintData = false; + pageNo = 1; + getFingerprintsListData(); + }); } - - state.isDeletFingerprintData = false; - getFingerprintsListData(); } } diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index 93d7c274..6d004520 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -68,7 +68,7 @@ class _FingerprintListPageState extends State with RouteAwa onPressed: () async { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { - showDeletAlertDialog(context); + showDeletAlertDialog(); } else { // Get.toNamed(Routers.selectLockTypePage); logic.showToast("演示模式"); @@ -90,7 +90,8 @@ class _FingerprintListPageState extends State with RouteAwa KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { - logic.getFingerprintsListData(); + logic.pageNo = 1; + getHttpData(); }, ), SizedBox( @@ -106,7 +107,8 @@ class _FingerprintListPageState extends State with RouteAwa "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 }); if (data != null) { - logic.getFingerprintsListData(); + logic.pageNo = 1; + getHttpData(); } }, ), @@ -133,11 +135,12 @@ class _FingerprintListPageState extends State with RouteAwa children: [ SlidableAction( onPressed: (BuildContext context){ - showIosTipViewDialog(context); + showIosTipViewDialog(fingerprintItemData.fingerprintId); }, backgroundColor: Colors.red, - foregroundColor: Colors.white, + // foregroundColor: Colors.white, label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), ), ], ), @@ -156,7 +159,8 @@ class _FingerprintListPageState extends State with RouteAwa "fingerprintItemData": fingerprintItemData, }); if (data != null) { - logic.getFingerprintsListData(); + logic.pageNo = 1; + getHttpData(); } }), ); @@ -171,9 +175,9 @@ class _FingerprintListPageState extends State with RouteAwa ) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - ScreenUtil().bottomBarHeight - 190.h - 64.h)); } - void showIosTipViewDialog(BuildContext context) { + void showIosTipViewDialog(int? fingerprintId) { showDialog( - context: context, + context: Get.context!, builder: (BuildContext context) { return ShowIosTipView( title: "提示", @@ -182,6 +186,7 @@ class _FingerprintListPageState extends State with RouteAwa Get.back(); state.isDeletFingerprintData = true; state.isDeletAll = false; + state.deletKeyID = fingerprintId.toString(); state.deletUserID = (await Storage.getUid())!; logic.senderAddFingerprint(); }, @@ -262,9 +267,9 @@ class _FingerprintListPageState extends State with RouteAwa ); } - void showDeletAlertDialog(BuildContext context) { + void showDeletAlertDialog() { showCupertinoDialog( - context: context, + context: Get.context!, builder: (context) { return CupertinoAlertDialog( title: const Text("提示"), diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 0900fe5e..6f46c4cb 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -6,6 +6,7 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; import '../../../blue/blue_manage.dart'; @@ -20,6 +21,7 @@ import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; +import '../../../translations/trans_lib.dart'; import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import 'lockDetail_state.dart'; import 'lockNetToken_entity.dart'; @@ -93,8 +95,6 @@ class LockDetailLogic extends BaseGetXController { getLockRecordLastUploadDataTime(); state.openLockBtnState.value = 0; - - eventBus.fire(RefreshLockDetailInfoDataEvent()); break; case 0x06: @@ -651,7 +651,8 @@ class LockDetailLogic extends BaseGetXController { lockUserNo: state.lockUserNo.toString()); if (entity.errorCode!.codeIsSuccessful) { if (state.isOpenLockNeedOnline.value == 0) { - state.bottomBtnisUneable.value = false; + state.bottomBtnisEable.value = true; + eventBus.fire(RefreshLockDetailInfoDataEvent()); eventBus.fire(RefreshLockListInfoDataEvent()); openDoorAction(1); } else { @@ -725,6 +726,23 @@ class LockDetailLogic extends BaseGetXController { }); } + String getKeyStatusTextAndShow(){ + String text = ""; + if (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitIneffective || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) { + text = "你的钥匙${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}"; + } else { + text = state.isOpenPassageMode.value == 1 + ? "常开模式启动!长按闭锁" + : TranslationLoader + .lanKeys!.clickUnlockAndHoldDownClose!.tr; + } + return text; + } + // late StreamSubscription> // _scanListDiscoveredDeviceSubscription; // void _scanListDiscoveredDeviceSubscriptionAction() { diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 160a825e..3b976415 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -11,6 +11,7 @@ import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_tool/io_tool.dart'; +import '../../../common/XSConstantMacro/XSConstantMacro.dart'; import '../../../tools/appRouteObserver.dart'; import '../../../tools/dateTool.dart'; import '../../../tools/eventBusEventManage.dart'; @@ -43,45 +44,8 @@ class _LockDetailPageState extends State with TickerProviderStat void initState() { // TODO: implement initState super.initState(); - // Get.log("LockDetailPage initState1111"); + Get.log("LockDetailPage initState1111"); - state.keyInfos.value = widget.lockListInfoItemEntity; - state.lockUserNo = state.keyInfos.value.lockUserNo!; - if (state.lockUserNo == 0) { - state.bottomBtnisUneable.value = true; - } - state.isOnlyOneData = widget.isOnlyOneData; - // print("state.lockUserNo==${state.lockUserNo}"); - state.senderUserId = state.keyInfos.value.senderUserId!; - state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!; - state.isOpenLockNeedOnline.value = - state.keyInfos.value.lockSetting!.appUnlockOnline!; - state.electricQuantity.value = state.keyInfos.value.electricQuantity!; - state.isOpenPassageMode.value = state.keyInfos.value.passageMode!; - state.lockAlias.value = state.keyInfos.value.lockAlias!; - - BlueManage().connectDeviceName = - state.keyInfos.value.bluetooth!.bluetoothDeviceName!; - - List publicKeyData = - state.keyInfos.value.bluetooth!.publicKey!.cast(); - var saveStrList = changeIntListToStringList(publicKeyData); - Storage.setStringList(saveBluePublicKey, saveStrList); - - // 私钥 - List privateKeyData = - state.keyInfos.value.bluetooth!.privateKey!.cast(); - var savePrivateKeyList = changeIntListToStringList(privateKeyData); - Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); - - // signKey - List signKeyData = - state.keyInfos.value.bluetooth!.signKey!.cast(); - var saveSignKeyList = changeIntListToStringList(signKeyData); - Storage.setStringList(saveBlueSignKey, saveSignKeyList); - - var saveTokenList = changeIntListToStringList([0, 0, 0, 0]); - Storage.setStringList(saveBlueToken, saveTokenList); // logic.startScanAction(); listeningAnimations(); @@ -93,6 +57,14 @@ class _LockDetailPageState extends State with TickerProviderStat _initRefreshLockDetailInfoDataEventAction(); } + @override + void didChangeDependencies() { + super.didChangeDependencies(); + Get.log("LockDetailPage didChangeDependencies2222"); + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + StreamSubscription? _lockRefreshLockDetailInfoDataEvent; void _initRefreshLockDetailInfoDataEventAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus @@ -101,12 +73,74 @@ class _LockDetailPageState extends State with TickerProviderStat }); } + void loadData(){ + // print("widget.lockListInfoItemEntity.lockUserNo:${widget.lockListInfoItemEntity.lockUserNo}"); + // print("state.lockUserNo:${state.lockUserNo}"); + + state.keyInfos.value = widget.lockListInfoItemEntity; + state.lockUserNo = state.keyInfos.value.lockUserNo!; + if (state.lockUserNo == 0) { + state.bottomBtnisEable.value = false; + }else{ + state.bottomBtnisEable.value = true; + } + // print("state.keyInfos.value.keyStatus:${state.keyInfos.value.keyStatus}"); + if (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitIneffective || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) { + state.openDoorBtnisUneable.value = false; + }else{ + state.openDoorBtnisUneable.value = true; + } + + state.isOnlyOneData = widget.isOnlyOneData; + // print("state.lockUserNo==${state.lockUserNo}"); + state.senderUserId = state.keyInfos.value.senderUserId!; + state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!; + state.isOpenLockNeedOnline.value = + state.keyInfos.value.lockSetting!.appUnlockOnline!; + state.electricQuantity.value = state.keyInfos.value.electricQuantity!; + state.isOpenPassageMode.value = state.keyInfos.value.passageMode!; + state.lockAlias.value = state.keyInfos.value.lockAlias!; + + BlueManage().connectDeviceName = + state.keyInfos.value.bluetooth!.bluetoothDeviceName!; + + List publicKeyData = + state.keyInfos.value.bluetooth!.publicKey!.cast(); + var saveStrList = changeIntListToStringList(publicKeyData); + Storage.setStringList(saveBluePublicKey, saveStrList); + + // 私钥 + List privateKeyData = + state.keyInfos.value.bluetooth!.privateKey!.cast(); + var savePrivateKeyList = changeIntListToStringList(privateKeyData); + Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); + + // signKey + List signKeyData = + state.keyInfos.value.bluetooth!.signKey!.cast(); + var saveSignKeyList = changeIntListToStringList(signKeyData); + Storage.setStringList(saveBlueSignKey, saveSignKeyList); + + var saveTokenList = changeIntListToStringList([0, 0, 0, 0]); + Storage.setStringList(saveBlueToken, saveTokenList); + } + @override Widget build(BuildContext context) { + loadData(); + return ListView( children: [ Visibility( - visible: false, + visible: ( + (state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || state.keyInfos.value.keyType == XSConstantMacro.keyTypeLoop) && // 限时、循环 + (DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) < 30 && DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) > 0) &&// 0到30天 + (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusNormalUse || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitReceive)// 正常使用、待接收 + ) ? true : false, child: Container( // height: 30.h, color: const Color(0xFFFBEFD4), @@ -114,7 +148,7 @@ class _LockDetailPageState extends State with TickerProviderStat child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text("钥匙将在2天后失效", + Text("钥匙将在${DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!)}天后失效", style: TextStyle( color: const Color(0xffCBA74B), fontSize: 24.sp)) ], @@ -259,21 +293,39 @@ class _LockDetailPageState extends State with TickerProviderStat children: [ Center( child: GestureDetector( + onTap: state.openDoorBtnisUneable.value == true ? () { + // Get.log("点击开锁"); + setState(() { + startOpenLock(); + }); + } : null, + onLongPressStart: state.openDoorBtnisUneable.value == true ? (details) { + Get.log("长按闭锁"); + setState(() { + startUnLock(); + }); + // startUnLock(); + }:null, child: Stack( children: [ Image.asset( - // state.connectState.value == 0 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png', - state.isOpenPassageMode.value == 1 + state.openDoorBtnisUneable.value == false ? 'images/main/icon_main_openLockBtn_grey.png' : (state.isOpenPassageMode.value == 1 ? 'images/main/icon_main_normallyOpenMode_center.png' - : 'images/main/icon_main_openLockBtn_center.png', + : 'images/main/icon_main_openLockBtn_center.png'), width: 330.w, height: 330.w, ), + state.openDoorBtnisUneable.value == false ? Positioned( + child: Image.asset( + 'images/main/icon_main_openLockBtn_grey.png', + width: 330.w, + height: 330.w, + ), + ) : state.openLockBtnState.value == 1 ? buildRotationTransition() : Positioned( child: Image.asset( - // 'images/main/icon_main_openLockBtn_circle.png', state.isOpenPassageMode.value == 1 ? 'images/main/icon_main_normallyOpenMode_circle.png' : 'images/main/icon_main_openLockBtn_circle.png', @@ -282,19 +334,6 @@ class _LockDetailPageState extends State with TickerProviderStat )), ], ), - onTap: () { - // Get.log("点击开锁"); - setState(() { - startOpenLock(); - }); - }, - onLongPressStart: (details) { - Get.log("长按闭锁"); - setState(() { - startUnLock(); - }); - // startUnLock(); - }, )), ], ), @@ -321,10 +360,7 @@ class _LockDetailPageState extends State with TickerProviderStat mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - state.isOpenPassageMode.value == 1 - ? "常开模式启动!长按闭锁" - : TranslationLoader - .lanKeys!.clickUnlockAndHoldDownClose!.tr, + logic.getKeyStatusTextAndShow(), style: TextStyle( fontSize: 22.sp, color: AppColors.btnDisableColor, @@ -468,7 +504,7 @@ class _LockDetailPageState extends State with TickerProviderStat // 新增配件 showWidgetArr.add(bottomItem('images/main/icon_main_addLock.png', '新增配件', - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Navigator.pushNamed(context, Routers.accessoriesListPage); })); @@ -507,7 +543,7 @@ class _LockDetailPageState extends State with TickerProviderStat showWidgetArr.add(bottomItem( 'images/main/icon_main_clockingIn.png', TranslationLoader.lanKeys!.checkingIn!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.checkingInListPage, arguments: state.keyInfos.value); })); @@ -516,14 +552,14 @@ class _LockDetailPageState extends State with TickerProviderStat showWidgetArr.add(bottomItem( 'images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.lockOperatingRecordPage, arguments: {"keyInfo": state.keyInfos.value}); })); // 设置 showWidgetArr.add(bottomItem('images/main/icon_main_set.png', - TranslationLoader.lanKeys!.set!.tr, state.bottomBtnisUneable.value, () { + TranslationLoader.lanKeys!.set!.tr, state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.lockSetPage, arguments: { "lockId": state.keyInfos.value.lockId, "isOnlyOneData": state.isOnlyOneData @@ -541,7 +577,7 @@ class _LockDetailPageState extends State with TickerProviderStat showWidgetArr.add(bottomItem( 'images/main/icon_main_clockingIn.png', TranslationLoader.lanKeys!.checkingIn!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.checkingInListPage, arguments: state.keyInfos.value); })); @@ -551,7 +587,7 @@ class _LockDetailPageState extends State with TickerProviderStat showWidgetArr.add(bottomItem( 'images/main/icon_main_electronicKey.png', TranslationLoader.lanKeys!.electronicKey!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.electronicKeyListPage, arguments: {"keyInfo": state.keyInfos.value}); })); @@ -560,7 +596,7 @@ class _LockDetailPageState extends State with TickerProviderStat showWidgetArr.add(bottomItem( 'images/main/icon_main_password.png', TranslationLoader.lanKeys!.password!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.passwordKeyListPage, arguments: {"keyInfo": state.keyInfos.value}); })); @@ -570,7 +606,7 @@ class _LockDetailPageState extends State with TickerProviderStat showWidgetArr.add(bottomItem( 'images/main/icon_main_icCard.png', TranslationLoader.lanKeys!.card!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { // logic.showToast("普通用户第一次需要在锁旁边操作哦。", something: () { // logic.showEasyLoading(); // }); @@ -585,7 +621,7 @@ class _LockDetailPageState extends State with TickerProviderStat showWidgetArr.add(bottomItem( 'images/main/icon_main_fingerprint.png', TranslationLoader.lanKeys!.fingerprint!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.fingerprintListPage, arguments: { "lockId": state.keyInfos.value.lockId, }); @@ -597,7 +633,7 @@ class _LockDetailPageState extends State with TickerProviderStat showWidgetArr.add(bottomItem( 'images/main/icon_main_remoteControl.png', TranslationLoader.lanKeys!.remoteControl!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.remoteControlListPage); })); } @@ -608,7 +644,7 @@ class _LockDetailPageState extends State with TickerProviderStat bottomItem( 'images/main/icon_face.png', TranslationLoader.lanKeys!.humanFace!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.faceList, arguments: { "lockId": state.keyInfos.value.lockId, }); // Toast.show(msg: "功能暂未开放"); @@ -622,7 +658,7 @@ class _LockDetailPageState extends State with TickerProviderStat bottomItem( 'images/main/icon_catEyes.png', TranslationLoader.lanKeys!.monitoring!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.realTimePicturePage, arguments: { "lockName": state.keyInfos.value.lockName, "isMonitoring": true @@ -636,7 +672,7 @@ class _LockDetailPageState extends State with TickerProviderStat showWidgetArr.add(bottomItem( 'images/main/icon_main_authorizedAdmin.png', TranslationLoader.lanKeys!.authorizedAdmin!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.authorizedAdminListPage, arguments: {"keyInfo": state.keyInfos.value}); })); @@ -651,7 +687,7 @@ class _LockDetailPageState extends State with TickerProviderStat bottomItem( 'images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { // Get.toNamed(Routers.lockOperatingRecordPage, // arguments: {"keyInfo": state.keyInfos.value}); Get.toNamed(Routers.doorLockLogPage, @@ -661,7 +697,7 @@ class _LockDetailPageState extends State with TickerProviderStat bottomItem( 'images/main/icon_lockDetail_videoLog.png', TranslationLoader.lanKeys!.videoLog!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { //视频日志 Get.toNamed(Routers.videoLogPage); }), @@ -669,14 +705,11 @@ class _LockDetailPageState extends State with TickerProviderStat bottomItem( 'images/main/icon_lockDetail_messageReminding.png', TranslationLoader.lanKeys!.messageReminding!.tr, - state.bottomBtnisUneable.value, () { + state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.msgNotificationPage); }), // 设置 - bottomItem( - 'images/main/icon_main_set.png', - TranslationLoader.lanKeys!.set!.tr, - state.bottomBtnisUneable.value, () { + bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { // logic.clickItemBtnAction(10); Get.toNamed(Routers.lockSetPage, arguments: { "lockId": state.keyInfos.value.lockId, @@ -689,16 +722,13 @@ class _LockDetailPageState extends State with TickerProviderStat } // - Widget bottomItem( - String iconUrl, String name, bool isForbidden, Function() onClick) { + Widget bottomItem(String iconUrl, String name, bool openDoorBtnisUneable, bool bottomBtnisEable, Function() onClick) { var width = 42.w; var height = 42.h; return GestureDetector( - onTap: isForbidden - ? () { - logic.showToast("请在锁旁边完成第一次开锁"); - } - : onClick, + onTap:openDoorBtnisUneable ? (bottomBtnisEable ? onClick : () { + logic.showToast("请在锁旁边完成第一次开锁"); + }) : null, child: Container( // height: 300.h, color: Colors.white, @@ -707,14 +737,13 @@ class _LockDetailPageState extends State with TickerProviderStat children: [ SizedBox( width: width, - height: - height, // isForbidden ? "${iconUrl}_uneable.png" :"${iconUrl}.png" + height: height, child: Image.asset(iconUrl, width: width, height: height, - color: isForbidden - ? AppColors.lockDetailBottomBtnUneable - : AppColors.mainColor, + color: openDoorBtnisUneable ? (bottomBtnisEable + ? AppColors.mainColor + : AppColors.lockDetailBottomBtnUneable) : AppColors.lockDetailBottomBtnUneable, fit: BoxFit.fitWidth), ), SizedBox(height: 10.w), @@ -722,9 +751,9 @@ class _LockDetailPageState extends State with TickerProviderStat child: Text(name, style: TextStyle( fontSize: 20.sp, - color: isForbidden - ? AppColors.lockDetailBottomBtnUneable - : AppColors.blackColor), + color:openDoorBtnisUneable ? (bottomBtnisEable + ? AppColors.blackColor + : AppColors.lockDetailBottomBtnUneable) : AppColors.lockDetailBottomBtnUneable), textAlign: TextAlign.center)) ], )), @@ -747,8 +776,6 @@ class _LockDetailPageState extends State with TickerProviderStat } }); }); - - // logic.connectBlueAndAnimationController(); } String showElectricIcon(int electricnumber) { @@ -865,7 +892,7 @@ class _LockDetailPageState extends State with TickerProviderStat // 电子钥匙lockUserNo为0 要先添加用户 logic.addUserConnectBlue(); } else { - print("state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}"); + // print("state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}"); if (state.isOpenLockNeedOnline.value == 0) { // 不需要联网 logic.openDoorAction(1); @@ -894,14 +921,14 @@ class _LockDetailPageState extends State with TickerProviderStat } } - @override - void didChangeDependencies() { - // TODO: implement didChangeDependencies - super.didChangeDependencies(); - - /// 路由订阅 - AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); - } + // @override + // void didChangeDependencies() { + // // TODO: implement didChangeDependencies + // super.didChangeDependencies(); + // + // /// 路由订阅 + // AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + // } @override void dispose() { diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart index 095a450e..9acdd804 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -35,7 +35,8 @@ class LockDetailState { var iSOpenLock = true.obs; // 是开锁还是关锁 Timer? closedUnlockSuccessfulTimer; - var bottomBtnisUneable = false.obs; // 是否不可用 用于限制底部按钮是否可用 + var bottomBtnisEable = true.obs; // 是否不可用 用于限制底部按钮是否可用 + var openDoorBtnisUneable = true.obs; // 当钥匙状态不能使用的情况下开锁按钮禁止使用,默认可用 //过渡动画控制器 AnimationController? animationController; diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_state.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_state.dart index cd3a2595..250b474e 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_state.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_state.dart @@ -11,7 +11,9 @@ class BasicInformationState { BasicInformationState() { var map = Get.arguments; - lockSetInfoData.value = map["lockSetInfoData"]; - lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!; + if(map["lockSetInfoData"] != null){ + lockSetInfoData.value = map["lockSetInfoData"]; + lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!; + } } } diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_page.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_page.dart index 36666840..04039e89 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/editLockName/editLockName_page.dart @@ -42,7 +42,7 @@ class _EditLockNamePageState extends State { ), body: Container( margin: EdgeInsets.only(left: 20.w, right: 20.w), - child: LoginInput( + child: LoginInput().tfInput( controller: state.changeLockNameController, leftWidget: const SizedBox(), hintText: "请输入名称", diff --git a/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart b/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart index a4b1352e..046e02cb 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_logic.dart @@ -1,10 +1,10 @@ import 'dart:async'; - import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import '../../../../blue/blue_manage.dart'; +import '../../../../blue/io_protocol/io_getStarLockStatusInfo.dart'; import '../../../../blue/io_protocol/io_timing.dart'; import '../../../../blue/io_reply.dart'; import '../../../../blue/io_tool/io_tool.dart'; @@ -28,58 +28,56 @@ class LockTimeLogic extends BaseGetXController{ } // 获取锁状态 - // if(reply is GetLockStatuReply) { - // _replyGetLockStatus(reply); - // } + if(reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value == true) { + _replyGetStarLockStatusInfo(reply); + } }); } // 获取锁状态数据解析 - // Future _replyGetLockStatus(Reply reply) async { - // int status = reply.data[2]; - // switch(status){ - // case 0x00: - // //成功 - // print("${reply.commandType}数据解析成功"); - // - // // 锁当前时间 - // var lockTime = reply.data.sublist(60, 64); - // - // int value = ( - // (0xff & lockTime[(0)]) << 24 | - // (0xff & lockTime[1]) << 16 | - // (0xff & lockTime[2]) << 8 | - // (0xFF & lockTime[3])); - // - // String dataEime = DateTool().dateToYMDHNSString("$value"); - // state.dateTime.value = dataEime; - // - // // String dataEime = DateTool().dateToYMDHNSString("${value}"); - // // state.dateTime.value = dataEime; - // print("lockTime:$lockTime value:$value dataEime:$dataEime"); - // break; - // case 0x06: - // //无权限 - // print("${reply.commandType}需要鉴权"); - // - // break; - // case 0x07: - // //无权限 - // print("${reply.commandType}用户无权限"); - // - // break; - // case 0x09: - // // 权限校验错误 - // print("${reply.commandType}权限校验错误"); - // - // break; - // default: - // //失败 - // print("${reply.commandType}失败"); - // - // break; - // } - // } + Future _replyGetStarLockStatusInfo(Reply reply) async { + int status = reply.data[2]; + switch (status) { + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + + cancelBlueConnetctToastTimer(); + dismissEasyLoading(); + + // 有效时间 + var indate = reply.data.sublist(149, 153); + int indateValue = ((0xff & indate[(0)]) << 24 | + (0xff & indate[1]) << 16 | + (0xff & indate[2]) << 8 | + (0xFF & indate[3])); + state.dateTime.value = DateTool().dateToYMDHNSString("$indateValue"); + // state.dateTime = indateValue * 1000; + print("indate:$indate indateValue:$indateValue"); + + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType}失败"); + + break; + } + } // 校时数据解析 Future _replyTiming(Reply reply) async { @@ -88,17 +86,20 @@ class LockTimeLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType}数据解析成功"); + // var lockTime = reply.data.sublist(4, 8); - // // int value = ( // (0xff & lockTime[(0)]) << 24 | // (0xff & lockTime[1]) << 16 | // (0xff & lockTime[2]) << 8 | // (0xFF & lockTime[3])); - // + // String dataEime = DateTool().dateToYMDHNSString("$value"); // state.dateTime.value = dataEime; + String dataEime = DateTool().dateToYMDHNSString("${state.dateTimestamp.value}"); + state.dateTime.value = dataEime; + state.sureBtnState.value = 0; cancelBlueConnetctToastTimer(); dismissEasyLoading(); @@ -153,7 +154,8 @@ class LockTimeLogic extends BaseGetXController{ IoSenderManage.senderTimingCommand( lockID:BlueManage().connectDeviceName, userID:await Storage.getUid(), - nowTime:DateTime.now().millisecondsSinceEpoch~/1000, + // nowTime:DateTime.now().millisecondsSinceEpoch~/1000, + nowTime: state.dateTimestamp.value, token:getTokenList, needAuthor:1, signKey:getSignKeyList, @@ -170,6 +172,33 @@ class LockTimeLogic extends BaseGetXController{ }); } + // 获取锁状态 更新电量 + Future getStarLockStatus() async { + showEasyLoading(); + showBlueConnetctToastTimer(action: () { + dismissEasyLoading(); + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected) { + dismissEasyLoading(); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + IoSenderManage.senderGetStarLockStatuInfo( + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + privateKey: getPrivateKeyList, + ); + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + if (state.ifCurrentScreen.value == true) { + showBlueConnetctToast(); + } + } + }); + } + // 从网关获取时间 void getLockTimeFromGateway() async{ var entity = await ApiRepository.to.getLockTimeFromGateway( @@ -186,8 +215,7 @@ class LockTimeLogic extends BaseGetXController{ lockId: state.lockSetInfoData.value.lockId.toString(), ); if(entity.errorCode!.codeIsSuccessful){ - String dataEime = DateTool().dateToYMDHNSString("${entity.data!.date!}"); - state.dateTime.value = dataEime; + state.dateTimestamp.value = entity.data!.date!; if(isSendBlue){ sendTiming(); } @@ -201,8 +229,10 @@ class LockTimeLogic extends BaseGetXController{ print("onReady()"); _initReplySubscription(); + + // getStarLockStatus(); // getLockTimeFromGateway(); - getServerDatetime(false); + // getServerDatetime(false); } @override diff --git a/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart b/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart index 596e5954..f6eb3226 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockTime/lockTime_state.dart @@ -5,6 +5,7 @@ import '../lockSet/lockSetInfo_entity.dart'; class LockTimeState{ var lockSetInfoData = LockSetInfoData().obs; var dateTime = "".obs; + var dateTimestamp = 0.obs; var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 199a9a08..1beec62b 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -83,7 +83,8 @@ class _PasswordKeyListPageState extends State { KeySearchWidget( editingController: state.searchController, onSubmittedAction: () { - logic.mockNetworkDataRequest(); + logic.pageNo = 1; + getHttpData(); }, ), SizedBox( @@ -100,7 +101,8 @@ class _PasswordKeyListPageState extends State { Navigator.pushNamed(context, Routers.passwordKeyManagePage, arguments: {"keyInfo": state.keyInfo.value}).then((val) { if (val != null) { - logic.mockNetworkDataRequest(); + logic.pageNo = 1; + getHttpData(); } }); }), @@ -137,6 +139,7 @@ class _PasswordKeyListPageState extends State { backgroundColor: Colors.red, foregroundColor: Colors.white, label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), ), ], ), diff --git a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart index 3713b576..9e1c8e1f 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_logic.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_logic.dart @@ -1,6 +1,7 @@ import 'package:star_lock/tools/baseGetXController.dart'; import '../../../common/XSConstantMacro/XSConstantMacro.dart'; +import '../../../tools/dateTool.dart'; import '../entity/lockListInfo_entity.dart'; import 'lockList_state.dart'; @@ -27,35 +28,11 @@ class LockListLogic extends BaseGetXController{ if(keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop){ // 当是正常使用跟待接收状态的时候 if(keyInfo.keyStatus == XSConstantMacro.keyStatusNormalUse || keyInfo.keyStatus == XSConstantMacro.keyStatusWaitReceive) { - return "余${compareTimeGetDaysFromNow(keyInfo.endDate!)}天"; + return "余${DateTool().compareTimeGetDaysFromNow(keyInfo.endDate!)}天"; } else { return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!); } } return ""; } - - /// 获取是否超过现在的时间 - bool compareTimeIsOvertime(int endTiem){ - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime - DateTime now = DateTime.now(); // 获取当前时间 - if (now.isAfter(dateTime)) { - print('The timestamp is after the current time.'); - // 过期 - return true; - } else { - print('The timestamp is not after the current time.'); - return false; - } - } - - /// 获取两个距离当前时间相差几天 1705132260000 - int compareTimeGetDaysFromNow(int endTiem){ - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime - DateTime now = DateTime.now(); // 获取当前时间 - Duration difference = dateTime.difference(now); // 计算两个日期之间的差异 - int days = difference.inDays; // 获取差异的天数 - print('dateTime:$dateTime now:$now The difference is $days days.'); - return days; - } } \ No newline at end of file diff --git a/star_lock/lib/main/lockMian/lockList/lockList_page.dart b/star_lock/lib/main/lockMian/lockList/lockList_page.dart index 066140b7..b9bd2daf 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_page.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_page.dart @@ -6,6 +6,7 @@ import 'package:get/get.dart'; import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; import '../../../common/XSConstantMacro/XSConstantMacro.dart'; +import '../../../tools/dateTool.dart'; import '../entity/lockListInfo_entity.dart'; import 'lockListGroup_page.dart'; import 'lockList_logic.dart'; @@ -98,7 +99,7 @@ class _LockListPageState extends State { } // print("lockItemList.length:${lockItemList.length} == ${index+1} $isLast"); return lockInfoListItem(keyInfo, isLast, () { - if(logic.compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime){ + if(DateTool().compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime){ logic.showToast("钥匙已过期"); return; } @@ -123,7 +124,7 @@ class _LockListPageState extends State { // height: 122.h, margin: isLast ? EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w) : EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), decoration: BoxDecoration( - color: (logic.compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime) ? AppColors.greyBackgroundColor : Colors.white, + color: (DateTool().compareTimeIsOvertime(keyInfo.endDate!) && keyInfo.keyType == XSConstantMacro.keyTypeTime) ? AppColors.greyBackgroundColor : Colors.white, borderRadius: BorderRadius.circular(20.w), ), child: Column( @@ -193,7 +194,7 @@ class _LockListPageState extends State { )), SizedBox(height: 20.h), Visibility( - visible: (keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) ? true : false, + visible: ((keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop) && (DateTool().compareTimeGetDaysFromNow(keyInfo.endDate!) < 30 && DateTool().compareTimeGetDaysFromNow(keyInfo.endDate!) > 0)) ? true : false, // visible: true, child:Row( children: [ @@ -202,7 +203,7 @@ class _LockListPageState extends State { padding: EdgeInsets.only(right: 5.w, left: 5.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(5.w), - color: logic.compareTimeIsOvertime(keyInfo.endDate!) ? AppColors.listTimeYellowColor : AppColors.mainColor, + color: DateTool().compareTimeIsOvertime(keyInfo.endDate!) ? AppColors.listTimeYellowColor : AppColors.mainColor, ), child: Text(logic.getKeyEffective(keyInfo), style: TextStyle(fontSize: 18.sp, color: Colors.white) // child: Text(logic.compareTimeIsOvertime(keyInfo.endDate!) ? "已过期" : "余${logic.compareTimeGetDaysFromNow(keyInfo.endDate!)}天", style: TextStyle(fontSize: 18.sp, color: Colors.white) diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart index e11e1cc4..ada7765e 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -85,7 +85,7 @@ class LockMainLogic extends BaseGetXController { print("onReady()"); // 开启UDP - UdpHelp().openUDP(); + // UdpHelp().openUDP(); BlueManage(); } diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart index d3946e64..c1b77d24 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart @@ -144,6 +144,7 @@ class _StarLockMainPageState extends State with BaseWidget { case 1: // 只有一条数据 Storage.setBool(ifIsDemoModeOrNot, false); + print("state.lockListInfoEntity.value.data!.groupList![0].lockList![0]:${state.lockListInfoEntity.value.data!.groupList![0].lockList![0].endDate}"); returnWidget = LockDetailPage( isOnlyOneData: true, lockListInfoItemEntity: state.lockListInfoEntity.value.data!.groupList![0].lockList![0]); diff --git a/star_lock/lib/mine/message/messageList/messageList_page.dart b/star_lock/lib/mine/message/messageList/messageList_page.dart index 2f747938..cd34b08e 100644 --- a/star_lock/lib/mine/message/messageList/messageList_page.dart +++ b/star_lock/lib/mine/message/messageList/messageList_page.dart @@ -77,6 +77,7 @@ class _MessageListPageState extends State with TickerProviderSt backgroundColor: Colors.red, foregroundColor: Colors.white, label: '删除', + padding: EdgeInsets.only(left: 5.w, right: 5.w), ), ], ), diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoEditIphone/minePersonInfoEditIphone_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoEditIphone/minePersonInfoEditIphone_page.dart index 93bff920..cae1e879 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoEditIphone/minePersonInfoEditIphone_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoEditIphone/minePersonInfoEditIphone_page.dart @@ -89,7 +89,7 @@ class _MinePersonInfoEditIphonePageState color: Colors.grey, ), SizedBox(height: 10.w), - LoginInput( + LoginInput().tfInput( controller: _phoneController, isPwd: true, leftWidget: const SizedBox(), @@ -102,7 +102,7 @@ class _MinePersonInfoEditIphonePageState Row( children: [ Expanded( - child: LoginInput( + child: LoginInput().tfInput( controller: _codeController, isPwd: true, leftWidget: const SizedBox(), diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/minePersonInfoEditName_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/minePersonInfoEditName_page.dart index b843c979..f25d9c32 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/minePersonInfoEditName_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoEditName/minePersonInfoEditName_page.dart @@ -50,7 +50,7 @@ class _MinePersonInfoEditNamePageState padding: EdgeInsets.all(15.w), child: Column( children: [ - LoginInput( + LoginInput().tfInput( controller: state.nickNameController, onchangeAction: (textStr) { logic.checkNext(state.nickNameController); diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart index 169bc5c0..3ede9d13 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart @@ -45,7 +45,7 @@ class _MineBindPhoneOrEmailPageState extends State { : TranslationLoader.lanKeys!.changeEmailTip!.tr, style: TextStyle(fontSize: 20.sp), )), - LoginInput( + LoginInput().tfInput( controller: state.accountController, isPwd: false, onchangeAction: (textStr) { @@ -62,7 +62,7 @@ class _MineBindPhoneOrEmailPageState extends State { Row( children: [ Expanded( - child: LoginInput( + child: LoginInput().tfInput( controller: state.codeController, isPwd: false, leftWidget: const SizedBox(), diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_page.dart index 2d450d8a..fd1b7ca7 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoResetPassword/minePersonInfoResetPassword_page.dart @@ -36,7 +36,7 @@ class _MinePersonInfoResetPasswordPageState margin: EdgeInsets.only(left: 30.w, right: 30.w), child: Column( children: [ - LoginInput( + LoginInput().tfInput( controller: state.oldPwdController, onchangeAction: (textStr) { logic.changeInput(state.oldPwdController); @@ -50,7 +50,7 @@ class _MinePersonInfoResetPasswordPageState inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), - LoginInput( + LoginInput().tfInput( controller: state.newPwdController, onchangeAction: (textStr) { logic.changeInput(state.newPwdController); @@ -64,7 +64,7 @@ class _MinePersonInfoResetPasswordPageState inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), - LoginInput( + LoginInput().tfInput( controller: state.surePwdController, onchangeAction: (textStr) { logic.changeInput(state.surePwdController); diff --git a/star_lock/lib/tools/EasyRefreshTool.dart b/star_lock/lib/tools/EasyRefreshTool.dart index 22e5a744..1a086fa4 100644 --- a/star_lock/lib/tools/EasyRefreshTool.dart +++ b/star_lock/lib/tools/EasyRefreshTool.dart @@ -47,6 +47,7 @@ class _EasyRefreshToolState extends State { controller: _controller, header: const MaterialHeader(), footer: const MaterialFooter(), + triggerAxis: Axis.vertical, onRefresh: widget.onRefresh!=null?() async { if(widget.onRefresh != null){ widget.onRefresh!(); diff --git a/star_lock/lib/tools/dateTool.dart b/star_lock/lib/tools/dateTool.dart index aca77373..39700f2a 100644 --- a/star_lock/lib/tools/dateTool.dart +++ b/star_lock/lib/tools/dateTool.dart @@ -53,4 +53,28 @@ class DateTool { String appointmentDate = formatDate(nowDate, [HH,':',nn]); return appointmentDate; } + + /// 获取是否超过现在的时间 + bool compareTimeIsOvertime(int endTiem){ + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime + DateTime now = DateTime.now(); // 获取当前时间 + if (now.isAfter(dateTime)) { + print('The timestamp is after the current time.'); + // 过期 + return true; + } else { + print('The timestamp is not after the current time.'); + return false; + } + } + + /// 获取两个距离当前时间相差几天 1705132260000 + int compareTimeGetDaysFromNow(int endTiem){ + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(endTiem); // 将时间戳转换为 DateTime + DateTime now = DateTime.now(); // 获取当前时间 + Duration difference = dateTime.difference(now); // 计算两个日期之间的差异 + int days = difference.inDays; // 获取差异的天数 + print('dateTime:$dateTime now:$now The difference is $days days.'); + return days; + } } \ No newline at end of file diff --git a/star_lock/lib/tools/tf_loginInput.dart b/star_lock/lib/tools/tf_loginInput.dart index e3dc9d6b..9e162c0c 100644 --- a/star_lock/lib/tools/tf_loginInput.dart +++ b/star_lock/lib/tools/tf_loginInput.dart @@ -8,67 +8,61 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; * */ typedef BlockStrCallback = void Function(dynamic textStr); -class LoginInput extends StatelessWidget { - TextEditingController? controller; - List? inputFormatters; - TextInputType? keyboardType; - Color? background; - String? hintText; - bool? isHaveLeftWidget; - Widget? leftWidget; - String? label; - bool? isPwd; - Widget? rightSlot; - BlockStrCallback? onchangeAction; - LoginInput( - {Key? key, - required this.controller, - this.rightSlot, - this.label, - this.isPwd, - this.inputFormatters, - this.keyboardType, - this.background, - this.hintText, - this.isHaveLeftWidget = true, - this.leftWidget, - this.onchangeAction}) - : super(key: key); - @override - Widget build(BuildContext context) { - return Container( +class LoginInput{ + + Widget tfInput({ + TextEditingController? controller, + List? inputFormatters, + TextInputType? keyboardType, + Color? background, + String? hintText, + bool? isHaveLeftWidget, + Widget? leftWidget, + String? label, + bool? isPwd, + Widget? rightSlot, + BlockStrCallback? onchangeAction}) { + return SizedBox( // color: Colors.red, - // width: 1.sp, + width: 1.sp, // height: 200.h, child: Column( children: [ - TextField( - //输入框一行 - maxLines: 1, - controller: controller, - onChanged: onchangeAction, - autofocus: false, - inputFormatters:inputFormatters, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only( - top: 8.0, left: -19.0, right: -15.0, bottom: 8.0), - labelText: label, - labelStyle: TextStyle(fontSize: 22.sp), - hintStyle: TextStyle(fontSize: 22.sp), - hintText: hintText, - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - icon: isHaveLeftWidget == true - ? leftWidget - : SizedBox( - width: 20.w, - height: 40.w, - ), - ), - obscureText: isPwd ?? false, + Row( + children: [ + leftWidget ?? SizedBox(width: 36.w, height: 36.w), + SizedBox(width: 40.w,), + Expanded( + child: TextField( + //输入框一行 + maxLines: 1, + controller: controller, + onChanged: onchangeAction, + // autofocus: false, + inputFormatters:inputFormatters, + decoration: InputDecoration( + //输入里面输入文字内边距设置 + contentPadding: const EdgeInsets.only( + top: 8.0, left: -19.0, right: -15.0, bottom: 8.0), + labelText: label, + labelStyle: TextStyle(fontSize: 22.sp), + hintStyle: TextStyle(fontSize: 22.sp), + hintText: hintText, + //不需要输入框下划线 + border: InputBorder.none, + //左边图标设置 + // icon: isHaveLeftWidget == true + // ? leftWidget + // : SizedBox( + // width: 20.w, + // height: 40.w, + // ), + ), + obscureText: isPwd ?? false, + ), + ), + ], ), Container( height: 0.5.h, From 7cc1e40b365855dbf6d970061a12ead81ce69265 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 19 Mar 2024 18:26:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=B8=BA=E6=9E=81?= =?UTF-8?q?=E5=85=89=E6=8E=A8=E9=80=81=EF=BC=88=E5=AE=89=E5=8D=93=E5=89=8D?= =?UTF-8?q?=E5=8F=B0=E6=94=B6=E6=B6=88=E6=81=AF=E6=B5=8B=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E3=80=81iOS=E5=89=8D=E5=90=8E=E5=8F=B0=E9=83=BD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/android/app/build.gradle | 26 ++- .../android/app/src/main/AndroidManifest.xml | 85 ++++++---- .../kotlin/com/skychip/lock/MainActivity.kt | 21 +-- star_lock/android/build.gradle | 17 +- star_lock/ios/Podfile | 1 + .../ios/Runner/AliyunEmasServices-Info.plist | 20 +-- star_lock/ios/Runner/AppDelegate.h | 7 +- star_lock/ios/Runner/AppDelegate.m | 38 +++-- star_lock/ios/Runner/Info.plist | 160 +++++++++--------- star_lock/lib/app.dart | 52 +++--- star_lock/lib/tools/jpush_flutter.dart | 33 ++++ star_lock/lib/tools/xs_aliyunPush.dart | 2 + star_lock/pubspec.yaml | 1 + 13 files changed, 263 insertions(+), 200 deletions(-) create mode 100644 star_lock/lib/tools/jpush_flutter.dart diff --git a/star_lock/android/app/build.gradle b/star_lock/android/app/build.gradle index 93273b5f..4370f69c 100644 --- a/star_lock/android/app/build.gradle +++ b/star_lock/android/app/build.gradle @@ -23,7 +23,7 @@ if (flutterVersionName == null) { } apply plugin: 'com.android.application' -apply plugin: 'com.aliyun.ams.emas-services' // 引用emas-services插件 +// apply plugin: 'com.aliyun.ams.emas-services' // 引用emas-services插件 apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" @@ -114,7 +114,7 @@ android { } defaultConfig { - + applicationId "com.skychip.lock" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. minSdkVersion 25 @@ -129,6 +129,18 @@ android { //设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so) abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64" } + + manifestPlaceholders = [ + JPUSH_PKGNAME : "com.skychip.lock", + //JPush 上注册的包名对应的 Appkey. + JPUSH_APPKEY : "7ff37d174c1a568a89e98dad", + //暂时填写默认值即可. + JPUSH_CHANNEL : "flutter_channel", + + //若不集成厂商通道,可直接跳过以下配置 + XIAOMI_APPID : "MI-2882303761520287291", + XIAOMI_APPKEY : "MI-5352028744291", + ] splits { abi { enable true @@ -140,6 +152,7 @@ android { } } } + buildTypes { release { // 高德地图导致release编译模式下应用闪退,根据:[高德地图在Debug模式下运行正常但是打Release包时则闪退解决办法](https://blog.csdn.net/weixin_39370093/article/details/109631210) @@ -163,7 +176,10 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation('com.amap.api:location:5.6.0') implementation('com.amap.api:3dmap:8.1.0') - implementation 'com.aliyun.ams:alicloud-android-push:3.8.7' - //小米依赖 - implementation 'com.aliyun.ams:alicloud-android-third-push-xiaomi:3.8.7' +// implementation 'com.aliyun.ams:alicloud-android-push:3.8.7' +// //小米依赖 +// implementation 'com.aliyun.ams:alicloud-android-third-push-xiaomi:3.8.7' +// implementation 'cn.jiguang.sdk:jpush:4.0.9' +// implementation 'cn.jiguang.sdk:jcore:2.8.2' +// implementation 'cn.jiguang.sdk.plugin:xiaomi:4.0.9'//版本号和对应的JPush版本号相同 } diff --git a/star_lock/android/app/src/main/AndroidManifest.xml b/star_lock/android/app/src/main/AndroidManifest.xml index 25941a2b..112101d3 100644 --- a/star_lock/android/app/src/main/AndroidManifest.xml +++ b/star_lock/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - + @@ -18,10 +18,6 @@ - - - - @@ -35,7 +31,10 @@ - + + @@ -49,36 +48,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -94,5 +64,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/star_lock/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt b/star_lock/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt index f3c4205b..33902047 100644 --- a/star_lock/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt +++ b/star_lock/android/app/src/main/kotlin/com/skychip/lock/MainActivity.kt @@ -16,9 +16,7 @@ import com.alibaba.sdk.android.push.register.MiPushRegister class MainActivity: FlutterActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - initAliyunPushService() - - MiPushRegister.register(applicationContext, "2882303761520287291", "5352028744291"); +// initJPushService() GeneratedPluginRegistrant.registerWith(flutterEngine!!) MethodChannel(flutterEngine?.dartExecutor!!.binaryMessenger, "starLockFlutterSend").setMethodCallHandler { call, result -> @@ -63,23 +61,6 @@ class MainActivity: FlutterActivity() { startActivity(Intent.createChooser(shareIntent, null)) } - private fun initAliyunPushService() { - PushServiceFactory.init(applicationContext) - val pushService = PushServiceFactory.getCloudPushService() - - val callback = object : CommonCallback, com.alibaba.sdk.android.push.CommonCallback { - override fun onSuccess(response: String?) { - Log.e("TAG","success $response") - } - - override fun onFailed(errorCode: String?, errorMessage: String?) { - Log.e("TAG","error $errorMessage") - } - } - - pushService.register(applicationContext,callback) - } - override fun configureFlutterEngine(flutterEngine: FlutterEngine) { GeneratedPluginRegistrant.registerWith(flutterEngine); MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "starLockFlutterSend").setMethodCallHandler { diff --git a/star_lock/android/build.gradle b/star_lock/android/build.gradle index bb5a7cca..67d2c573 100644 --- a/star_lock/android/build.gradle +++ b/star_lock/android/build.gradle @@ -4,16 +4,17 @@ buildscript { google() mavenCentral() mavenLocal() - maven { // 添加Maven仓库地址 - url 'https://maven.aliyun.com/nexus/content/repositories/releases/' - } +// maven { // 添加Maven仓库地址 +// url 'https://maven.aliyun.com/nexus/content/repositories/releases/' +// } } dependencies { classpath 'com.android.tools.build:gradle:7.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // 添加emas-services插件 - classpath 'com.aliyun.ams:emas-services:1.0.4' +// classpath 'com.aliyun.ams:emas-services:1.0.4' + // classpath "cn.jiguang.sdk:jpush:4.0.9" } } @@ -21,11 +22,11 @@ buildscript { allprojects { repositories { google() -// mavenCentral() + mavenCentral() jcenter() - maven { // 添加Maven仓库地址 - url 'https://maven.aliyun.com/nexus/content/repositories/releases/' - } +// maven { // 添加Maven仓库地址 +// url 'https://maven.aliyun.com/nexus/content/repositories/releases/' +// } } } diff --git a/star_lock/ios/Podfile b/star_lock/ios/Podfile index fc1e6a3b..f60e3f48 100644 --- a/star_lock/ios/Podfile +++ b/star_lock/ios/Podfile @@ -36,6 +36,7 @@ end source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/aliyun/aliyun-specs.git' pod 'AlicloudPush', '~> 1.9.9' +pod 'JPush' post_install do |installer| installer.pods_project.targets.each do |target| diff --git a/star_lock/ios/Runner/AliyunEmasServices-Info.plist b/star_lock/ios/Runner/AliyunEmasServices-Info.plist index ea7823a7..4b1af180 100644 --- a/star_lock/ios/Runner/AliyunEmasServices-Info.plist +++ b/star_lock/ios/Runner/AliyunEmasServices-Info.plist @@ -5,23 +5,23 @@ config emas.appKey - 333904046 + 334068745 emas.appSecret - 3eead09a7fc7416cb4082319aa6f48c6 + bee9c200835e4951a85dc8709c319560 emas.bundleId cn.star-lock.starLock hotfix.idSecret - 333904046-2 + 334068745-2 hotfix.rsaSecret - MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCS0i6gEzmEoaXFe0gDcur1sdkE2ecWXRay3h+O11F0FmoNfQx+V4i+pt2se+KDAx/GQq8Axj4DnjzE4KT0TeVmrutI1FF4h2Tv5Ge9KT0yuCayiQPW5gkqTDxaehkRDyCzGkwaLkVslN2kFqammWsODTQw2a0/lziMrNpQU8bnjjYbKS1eIQUPM9s6smwN2A4RErAP7X1knsT1tCHoCgfgjZf1nddQSMw4vy9FBpKZDYD1gjdo5+U93VopVLpMqcbOVXbQeUwpArURNnY/dbSkrGsC2TXAfaYa+sVXPchy0pZ7C2wU2/6INkFBpw2QjFQ4uAcNXwoEn5x5iBw4VbnPAgMBAAECggEAfoowLT7kf+9iFIZgVrig0QlrZcb4aEnq2lafFFl3lnoLBX0VW37OGKNwwswzOX9jz1iBxEUYBb5H2ddT1Euev5Vaq/ZyEVOAJ1HQJzR3zlLw50c3y+uPUqlKCyDYod9L65FqrdXbd+4F6Pqsv0HTBtVSehfiPcBzuKrxrfHGqKKWx4C620SxPqtpNaYXaENyqfZ3qyKw+xtWGJtxjQ8DFkeWJ1C8O7ZxJ33SpwpEb9UIJpDtPcaKbwccLn/w5214kYAqE7m5aTmLUTFRYay2Hez1gPUKVirt/QDfEfHRv6xbv5jePl0snXWK0VwgoR3hLDuF9etM3UFLr40eQNICQQKBgQDCBjM7NvscgRCJ7E8vdcfxlebUhooZUewc9gBsTpPMcS8xZXP8desc1smZvokPtIKKwPdECw6rGf1a+sb6dnHMNjWBUbHTxWnYKqVlDDXJkgcSynK+74wRCfzmFamtQmJ1qVATHRVLoVSzmCwn9q+HsGWLAsMXDu5qbL6B91La2QKBgQDBuBHfPo4AwqefsPn5isw0bFYuc5rGSbfRTAlOC09BDJb2E9bz8QiC0A/Ar8i2fx9UbHKj96NYwMGwS49Bu/Behq5v2TnODbA6j5lN4fMbRBaCMs4TINUjG4xGeFehELiFIJvCJ+3z6zRBuXmCkxtso3VM6uVSn8TX1gjBgzxA5wKBgHjJYVVoyfUZyBEE4tr56OpV1qjRxOE0Zdg1sVe7pzkr8SRAM2+kfSSr9j9XJX54cpgsvwJGG/CasmXUHtFHsVpfGPoTwK/EgzsGeYapjkaZOPwSulJxUHI/FIisTcBFxoPXTrlHbr1xhwhzIHIUmXvQbbaXlpohOn1Yi1Tfgl4pAoGAJBdZLRCIgFfDxxq/1+AmH3Y3sDvVkC/X0WSrLyEoSORBk+MqXxR/E3AUH0Ag0u9oNOBnk2jlw/lVnLTXIdYT+Gh7Q1djT6J5PM/YLgx0sJXE48j3X9T0ILBXOCHfoaBt4E+s9UVfLdyaRcx6ePtTVrA1gHka9IPTtqqnwvXiWe0CgYBjmKSq2uBXSzAWMAR5KbUYDzUoqWGGHyRHtX4IqlLYF6paabzJDxPg2QScv9e8+js5Vmbg/G5RUPhYMqJIatAzLQDujaLovLGPXlx2xQXf4Nn0M5AnvKXMF+m8xBY5KnT5SWjI9Uq9QVJMcMl43Nq1V4NSsnB8SIZsGVOgxB9tuw== + MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCuBisIWHUAiWQHltp/eHdK/sBfC1Pk8XBhziYIFWfZTVWR8QnLUbefnXJcW0C2nHzVRKv9LtbO/hWpz8IoZUisJsi5FmEwFCXf0cSMkaOI0wD7rpFmXVuMuSBJvPhvdT9lKzNx6rLaLRNdz2v/4Iat0Fphmqe6VqnHOnn9NBKzmg2NStW5U1rpxH+SovHTpX9aphHrXjJzkpmxJC0VDK3vZTUZANIiR0WQVGXChzGeEctILEqQ/4K5hwUrs3jFF1k4Qr/RyjzBMGw0HSDCA4nuasYSPDCv7phScqmn52/cUTXxY9BfGFvyvLIPC7FgD1tGOmrYeJJU3GleEJ+Y1uuRAgMBAAECggEAcXf8HxjuUUdEPd6S4YK+5dttu4s7TJBQ4rTz/1lVuU6/eMVdyYCi5iRXKPknHOq0SqrYKeGclqL9pReeVZCU7grr3iNFg3/foiy4p59erhxHC9QrYj+FLiCXeP0KUEJ275RXmvOZYsD5W7WfidvwdOzhwbqBmvJfCVSLrhmCCDBYIleLnmELai63jTTxy1ICKv/hnFMm04nyrO6tsR4La0nWXWC5VGZRk3O0eVTi1DyN0l0FO2zy2KJewTVaTGUDGDKuXUdZWltzsM6zOXvfLbSBkzJrfPeJzYKnoyVSMNUfq8yR7fMIWXxo2G/Li1JoUEzBt+3ilPdxIWWOiXY7QQKBgQD1/G7Egp9R1UMHe9Gaxa/lwjz6k2fv+08pRrVHUs0sdI4BjsIp1syLYUQjMqbH7rJrV2qTLFvpaUkQqBPkvmNcbEWeDk4UdFN/bFU+7F9C17CxBb9D54ZxTLOFmvNobnPHJXyKpBCLCycjWa2CIMSjuPKqkDn5TN9d+Q7WvogQ/QKBgQC1G8bfNvZ/uiCZWcSrYTuo5uDIxEWC6jpwitLPCvROQyRy+cBg5sOEFoqX11nbn7RJ1CzoG5wb1QPxkbaP3ryFgA/5xON4r9m/3yF08bVJpLYbzub+kTmlo2YDsHkc+7U4J5XoF0Jwwr+A1CIJahpD78l58h9uMRLKZqsV8teDJQKBgEBzEkaUfs+/E5/bVjC6CPsm6Dky8/GRo80JxKdaT32NUEOiNscli1QdeO/L7pzFsqOjNL44yiAewNEHaKbvJzNo/tiJoPWFAPeK187zuYXW42mOOu28tKHs2cBwt8Ot5NHRxY7Bq7/yfR+q+GX21e6bn6EGxtnFxWRmw/eJ1ja1AoGASDCRPeo/qTv8wIOatCFm0XVuBjjN6FgLAU8kpmicZxG2Vqoct8NkDaOajNnHNJbdG0yatc5DlIh9MO4/Eevbw27/bzS+4x1dM3DyehXaiEdCW6VGSBSFIPQXtsLCE/51BrQoucGDt0S5ZtWn147Wd1v+OEB9rMOc1NbFvVL1+o0CgYEApnA58wOgtxJGggaa4LS6T+VTsx73mzz3YP8AAHsgePeFCqS/MdDwaoLlAKBRkDm07KkaRh0/Nofn3jSRs7zlFHSOUmhsAI0htEQx1x4f3MoBIuDtozv/eMT/XbGrNsP2i696TN39stnczrV3ZD7jzFvveEHRARaF4MvuLcRBrdQ= httpdns.accountId - 125761 + 100674 httpdns.secretKey - f77f39c6f0e66d7c169aa7e8d87dfe13 + 6cd4984095d53f6f311424cc9299257b appmonitor.tlog.rsaSecret - MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSlqdpwcdPniL1ahrYfTy47aD8Ay7D7qLyKO5QeXy64V+CQ0UvYwyTtfPRzvlXbwmc2ONjwKHq2B7SRhwHuBwURZNp5Iw1XaGCmqPPMOpL9UnYEIO90x3sFebIRHmXscyRVniGhmmdOXpVaP6BA3RWK1uwH/FBetzom6H+dcNMPQIDAQAB + MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCku9yUXBjd9m7V8fflC6XTwJEc8D8GSe5KzgXQZXk12S3KaZrx82Cu6/nOD7RNtZvsxrYd69bzkrG84tvIwwVSefWuPiDAiY2uiigpSXXda0FjQXZ0xHPJGcsrbI67y/2xFeK0pD9542Y4FBYPq6BcslAYFUVFD8bN+K/GBXkJRwIDAQAB appmonitor.rsaSecret - MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSlqdpwcdPniL1ahrYfTy47aD8Ay7D7qLyKO5QeXy64V+CQ0UvYwyTtfPRzvlXbwmc2ONjwKHq2B7SRhwHuBwURZNp5Iw1XaGCmqPPMOpL9UnYEIO90x3sFebIRHmXscyRVniGhmmdOXpVaP6BA3RWK1uwH/FBetzom6H+dcNMPQIDAQAB + MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCku9yUXBjd9m7V8fflC6XTwJEc8D8GSe5KzgXQZXk12S3KaZrx82Cu6/nOD7RNtZvsxrYd69bzkrG84tvIwwVSefWuPiDAiY2uiigpSXXda0FjQXZ0xHPJGcsrbI67y/2xFeK0pD9542Y4FBYPq6BcslAYFUVFD8bN+K/GBXkJRwIDAQAB services @@ -65,7 +65,7 @@ status 1 version - 1.2.0 + 1.2.0-no-memory man_service @@ -79,7 +79,7 @@ status 1 version - 2.0.4 + 1.9.9.1-notnull diff --git a/star_lock/ios/Runner/AppDelegate.h b/star_lock/ios/Runner/AppDelegate.h index bb4ca173..582d3c3b 100644 --- a/star_lock/ios/Runner/AppDelegate.h +++ b/star_lock/ios/Runner/AppDelegate.h @@ -9,9 +9,14 @@ #import #import +#import "JPUSHService.h" +#import + +#import "JPUSHService.h" +#import -@interface AppDelegate : FlutterAppDelegate +@interface AppDelegate : FlutterAppDelegate @property (strong, nonatomic) UIWindow *window; diff --git a/star_lock/ios/Runner/AppDelegate.m b/star_lock/ios/Runner/AppDelegate.m index 56817721..557f519a 100644 --- a/star_lock/ios/Runner/AppDelegate.m +++ b/star_lock/ios/Runner/AppDelegate.m @@ -7,6 +7,7 @@ #import + @interface AppDelegate() @end @@ -18,6 +19,18 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { +// //【注册通知】通知回调代理(可选) +// JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init]; +// entity.types = JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSound|JPAuthorizationOptionProvidesAppNotificationSettings; +// [JPUSHService registerForRemoteNotificationConfig:entity delegate:self]; +// +// //【初始化sdk】 +// // notice: 2.1.5 版本的 SDK 新增的注册方法,改成可上报 IDFA,如果没有使用 IDFA 直接传 nil +// [JPUSHService setupWithOption:launchOptions appKey:@"7ff37d174c1a568a89e98dad" +// channel:@"flutter_channel" +// apsForProduction:NO +// advertisingIdentifier:nil]; + // [self initCloudPush]; // [CloudPushSDK sendNotificationAck:launchOptions]; XSFlutterManager *VC = [[XSFlutterManager alloc] init]; @@ -29,7 +42,7 @@ - (void)initCloudPush { // SDK初始化 - [CloudPushSDK asyncInit:@"333904046" appSecret:@"3eead09a7fc7416cb4082319aa6f48c6" callback:^(CloudPushCallbackResult *res) { + [CloudPushSDK asyncInit:@"334068745" appSecret:@"bee9c200835e4951a85dc8709c319560" callback:^(CloudPushCallbackResult *res) { if (res.success) { NSLog(@"Push SDK init success, deviceId: %@.", [CloudPushSDK getDeviceId]); } else { @@ -62,13 +75,16 @@ * 苹果推送注册成功回调,将苹果返回的deviceToken上传到CloudPush服务器 */ - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { - [CloudPushSDK registerDevice:deviceToken withCallback:^(CloudPushCallbackResult *res) { - if (res.success) { - NSLog(@"Register deviceToken success."); - } else { - NSLog(@"Register deviceToken failed, error: %@", res.error); - } - }]; +// [CloudPushSDK registerDevice:deviceToken withCallback:^(CloudPushCallbackResult *res) { +// if (res.success) { +// NSLog(@"Register deviceToken success."); +// } else { +// NSLog(@"Register deviceToken failed, error: %@", res.error); +// } +// }]; + //sdk注册DeviceToken + [JPUSHService registerDeviceToken:deviceToken]; + } /* * 苹果推送注册失败回调 @@ -98,12 +114,6 @@ NSLog(@"Receive message title: %@, content: %@.", title, body); } -//- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { -// // 点击通知将App从关闭状态启动时,将通知打开回执上报 -// // [CloudPushSDK handleLaunching:launchOptions];(Deprecated from v1.8.1) -// [CloudPushSDK sendNotificationAck:launchOptions]; -// return YES; -//} /* * App处于启动状态时,通知打开回调 */ diff --git a/star_lock/ios/Runner/Info.plist b/star_lock/ios/Runner/Info.plist index 6484c6e2..33b2277b 100644 --- a/star_lock/ios/Runner/Info.plist +++ b/star_lock/ios/Runner/Info.plist @@ -1,82 +1,84 @@ - - CADisableMinimumFrameDurationOnPhone - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - $(BUNDLE_DISPLAY_NAME) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(BUNDLE_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSRequiresIPhoneOS - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - NSBluetoothAlwaysUsageDescription - The app uses bluetooth to find, connect and transfer data between different devices - NSBluetoothPeripheralUsageDescription - The app uses bluetooth to find, connect and transfer data between different devices - NSCameraUsageDescription - 照片 - NSContactsUsageDescription - Reason we need access to the contact list - NSLocationAlwaysAndWhenInUseUsageDescription - 应用在前台和后台的时候可以搜到更新的位置信息 - NSLocationAlwaysUsageDescription - 应用在后台的时候可以搜到更新的位置信息 - NSLocationWhenInUseUsageDescription - 应用在前台的时候可以搜到更新的位置信息 - NSMicrophoneUsageDescription - 应用请求麦克风用来通话 - NSPhotoLibraryUsageDescription - 用于相册 - UIApplicationSceneManifest - - UISceneConfigurations - - - UIApplicationSupportsIndirectInputEvents - - UIBackgroundModes - - remote-notification - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - UIInterfaceOrientationPortrait - - UIViewControllerBasedStatusBarAppearance - - io.flutter.embedded_views_preview - - - \ No newline at end of file + + CADisableMinimumFrameDurationOnPhone + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + $(BUNDLE_DISPLAY_NAME) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(BUNDLE_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSBluetoothAlwaysUsageDescription + The app uses bluetooth to find, connect and transfer data between different devices + NSBluetoothPeripheralUsageDescription + The app uses bluetooth to find, connect and transfer data between different devices + NSCameraUsageDescription + 照片 + NSContactsUsageDescription + Reason we need access to the contact list + NSLocationAlwaysAndWhenInUseUsageDescription + 应用在前台和后台的时候可以搜到更新的位置信息 + NSLocationAlwaysUsageDescription + 应用在后台的时候可以搜到更新的位置信息 + NSLocationWhenInUseUsageDescription + 应用在前台的时候可以搜到更新的位置信息 + NSMicrophoneUsageDescription + 应用请求麦克风用来通话 + NSPhotoLibraryUsageDescription + 用于相册 + UIApplicationSceneManifest + + UISceneConfigurations + + + UIApplicationSupportsIndirectInputEvents + + UIBackgroundModes + + remote-notification + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortrait + + UIViewControllerBasedStatusBarAppearance + + NSUserTrackingUsageDescription + 需要访问您的隐私数据,以提供个性化的体验。 + io.flutter.embedded_views_preview + + + diff --git a/star_lock/lib/app.dart b/star_lock/lib/app.dart index ff5793ef..27fa403e 100644 --- a/star_lock/lib/app.dart +++ b/star_lock/lib/app.dart @@ -1,15 +1,16 @@ -import 'package:aliyun_push/aliyun_push.dart'; +// import 'package:aliyun_push/aliyun_push.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/flavors.dart'; import 'package:star_lock/tools/app_manager.dart'; import 'package:star_lock/tools/bindings/app_binding.dart'; -import 'package:star_lock/tools/storage.dart'; -import 'package:star_lock/tools/xs_aliyunPush.dart'; +// import 'package:star_lock/tools/storage.dart'; +// import 'package:star_lock/tools/xs_aliyunPush.dart'; import 'package:star_lock/translations/app_dept.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -30,6 +31,8 @@ class MyApp extends StatefulWidget { // final RouteObserver routeObserver = RouteObserver(); class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { + final JPush jpush = JPush(); + @override Widget build(BuildContext context) { return ScreenUtilInit( @@ -101,7 +104,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); - initFlutterAliyunPush(); + initJPushService(); } @override @@ -109,6 +112,24 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { WidgetsBinding.instance.removeObserver(this); super.dispose(); } + + Future initJPushService() async { + jpush.setup( + appKey: "7ff37d174c1a568a89e98dad", + channel: "flutter_channel", + production: false, + debug: true, + ); + jpush.applyPushAuthority( + const NotificationSettingsIOS(sound: true, alert: true, badge: true)); + // jpush.setChannelAndSound( + // channel: "flutter_channel", channelID: "115700", sound: "default"); + + // Platform messages may fail, so we use a try/catch PlatformException. + jpush.getRegistrationID().then((rid) { + print("flutter get registration id : $rid"); + }); + } } void openBlueScan() { @@ -146,26 +167,3 @@ Future getMicrophonePermission() async { } return false; } - -//初始化阿里云推送 -Future initFlutterAliyunPush() async { - final data = await Storage.getString(saveUserLoginData); - if (data != null) { - final aliyunPush = AliyunPush(); - XSAliyunPushProvider().init(aliyunPush); - XSAliyunPushProvider().initAliyunPush(); - - if (Platform.isAndroid) { - XSAliyunPushProvider().initAliyunThirdPush(); - } - - //暂使用DeviceID推送 - aliyunPush.getDeviceId().then((deviceId) async { - print('得到的DeviceId$deviceId'); - if (deviceId.isNotEmpty) { - XSAliyunPushProvider() - .pushBindDeviceID(deviceId, Platform.isAndroid ? 10 : 20); - } - }); - } -} diff --git a/star_lock/lib/tools/jpush_flutter.dart b/star_lock/lib/tools/jpush_flutter.dart new file mode 100644 index 00000000..fda3ee01 --- /dev/null +++ b/star_lock/lib/tools/jpush_flutter.dart @@ -0,0 +1,33 @@ +import 'package:jpush_flutter/jpush_flutter.dart'; + +class JPushProvider { + final JPush jpush = JPush(); + + Future initJPush() async { + jpush.setup( + appKey: "7ff37d174c1a568a89e98dad", + channel: "flutter_channel", + production: false, + debug: true, + ); + + jpush.applyPushAuthority(const NotificationSettingsIOS( + sound: true, + alert: true, + badge: true, + )); + + // // Add event handler + // jpush.addEventHandler( + // onReceiveNotification: (Map message) { + // print("Receive notification: $message"); + // }, + // onOpenNotification: (Map message) { + // print("Open notification: $message"); + // }, + // onReceiveMessage: (Map message) { + // print("Receive message: $message"); + // }, + // ); + } +} diff --git a/star_lock/lib/tools/xs_aliyunPush.dart b/star_lock/lib/tools/xs_aliyunPush.dart index 600dfc94..4a922ebb 100644 --- a/star_lock/lib/tools/xs_aliyunPush.dart +++ b/star_lock/lib/tools/xs_aliyunPush.dart @@ -1,3 +1,4 @@ +/* import 'dart:io'; import 'package:aliyun_push/aliyun_push.dart'; @@ -133,3 +134,4 @@ class XSAliyunPushProvider { if (entity.errorCode!.codeIsSuccessful) {} } } +*/ \ No newline at end of file diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 54a0eb76..8a654d9e 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -114,6 +114,7 @@ dependencies: cached_network_image: ^3.2.0 webview_flutter: ^4.2.3 aliyun_push: ^0.1.6 + jpush_flutter: ^2.5.1 #视频播放器 video_player: ^2.7.1