From 8a5de7d44221aa9bcc8dfab24221b5550e6d5d0a Mon Sep 17 00:00:00 2001 From: liyi Date: Thu, 25 Sep 2025 18:23:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E8=93=9D=E7=89=99?= =?UTF-8?q?=E5=BC=80=E9=94=81=E6=97=B6=E5=87=BA=E7=8E=B0=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E5=93=8D=E5=BA=94=EF=BC=8C=E5=A2=9E=E5=8A=A0=E9=98=B2=E6=8A=96?= =?UTF-8?q?=E5=A4=84=E7=90=86=E3=80=82=E8=B0=83=E6=95=B4=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8=E5=9C=A8=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E8=BF=9B=E8=A1=8C=E8=B5=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 16 +- .../lockDetail/lockDetail_logic.dart | 17 +- .../lockDetail/lockDetail_page.dart | 372 ++++++------------ 3 files changed, 141 insertions(+), 264 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index fbe7327e..1f23c421 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -131,12 +131,12 @@ jobs: echo "🔍 Getting version info from basic-setup job..." # 设置默认版本号,如果环境变量为空 - if [ -z "$NEXT_VERSION" ]; then + if [ -z "${{ needs.basic-setup.outputs.NEXT_VERSION }}" ]; then VERSION_FOR_FILENAME="1-0-0" echo "⚠️ Version not found, using default: $VERSION_FOR_FILENAME" else # 格式化版本号用于文件名 - VERSION_FOR_FILENAME=$(echo "$NEXT_VERSION" | sed 's/v//g' | sed 's/\./-/g') + VERSION_FOR_FILENAME=$(echo "${{ needs.basic-setup.outputs.NEXT_VERSION }}" | sed 's/v//g' | sed 's/\./-/g') echo "✅ Version found: $VERSION_FOR_FILENAME" fi @@ -165,12 +165,12 @@ jobs: echo "🔍 Getting version info from basic-setup job..." # 设置默认版本号,如果环境变量为空 - if [ -z "$NEXT_VERSION" ]; then + if [ -z "${{ needs.basic-setup.outputs.NEXT_VERSION }}" ]; then VERSION_FOR_FILENAME="1-0-0" echo "⚠️ Version not found, using default: $VERSION_FOR_FILENAME" else # 格式化版本号用于文件名 - VERSION_FOR_FILENAME=$(echo "$NEXT_VERSION" | sed 's/v//g' | sed 's/\./-/g') + VERSION_FOR_FILENAME=$(echo "${{ needs.basic-setup.outputs.NEXT_VERSION }}" | sed 's/v//g' | sed 's/\./-/g') echo "✅ Version found: $VERSION_FOR_FILENAME" fi @@ -200,12 +200,12 @@ jobs: echo "🔍 Getting version info from basic-setup job..." # 设置默认版本号,如果环境变量为空 - if [ -z "$NEXT_VERSION" ]; then + if [ -z "${{ needs.basic-setup.outputs.NEXT_VERSION }}" ]; then VERSION_FOR_FILENAME="1-0-0" echo "⚠️ Version not found, using default: $VERSION_FOR_FILENAME" else # 格式化版本号用于文件名 - VERSION_FOR_FILENAME=$(echo "$NEXT_VERSION" | sed 's/v//g' | sed 's/\./-/g') + VERSION_FOR_FILENAME=$(echo "${{ needs.basic-setup.outputs.NEXT_VERSION }}" | sed 's/v//g' | sed 's/\./-/g') echo "✅ Version found: $VERSION_FOR_FILENAME" fi @@ -217,7 +217,7 @@ jobs: echo "🔧 Configuring iOS automatic code signing for CI environment..." # 构建iOS IPA,使用自动签名模式 - flutter build ipa --no-tree-shake-icons --release --flavor sky -t lib/main_sky_full.dart --build-number=$BUILD_NUMBER --build-name="sky-star-lock-release-$VERSION_FOR_FILENAME.ipa" --codesign="auto" + flutter build ipa --no-tree-shake-icons --release --flavor sky -t lib/main_sky_full.dart --build-number=$BUILD_NUMBER --build-name="sky-star-lock-release-$VERSION_FOR_FILENAME.ipa" --codesign # 重命名IPA文件 mv build/ios/ipa/*.ipa "$IPA_FILENAME" @@ -247,5 +247,5 @@ jobs: echo " ✅ IPA: sky-star-lock-release-*.ipa" fi echo "" - echo "🏷️ Version: $NEXT_VERSION" + echo "🏷️ Version: ${{ needs.basic-setup.outputs.NEXT_VERSION }}" echo "📁 Files available in artifacts section" diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 42fd92df..f1831629 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -54,12 +54,27 @@ class LockDetailLogic extends BaseGetXController { //节流器,用来限制开锁按钮的触发频率 FunctionBlocker functionBlocker = FunctionBlocker(duration: const Duration(seconds: 2)); + + // 防抖Timer + Timer? _openDoorReplyDebounceTimer; + + // 带防抖控制的开门回复处理 + void _handleOpenDoorReplyWithDebounce(Reply reply) { + // 取消之前的Timer + _openDoorReplyDebounceTimer?.cancel(); + + // 设置新的Timer,200ms后执行 + _openDoorReplyDebounceTimer = Timer(const Duration(milliseconds: 300), () { + _replyOpenLock(reply); + }); + } + // 监听设备返回的数据 void initReplySubscription() { state.replySubscription = EventBusManager().eventBus!.on().listen((Reply reply) async { // 开门 if (reply is OpenDoorReply) { - _replyOpenLock(reply); + _handleOpenDoorReplyWithDebounce(reply); } // 开完锁之后上传记录 diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 55dae498..50672127 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -34,11 +34,7 @@ import '../../lockMian/entity/lockListInfo_entity.dart'; import 'lockDetail_logic.dart'; class LockDetailPage extends StatefulWidget { - const LockDetailPage( - {required this.isOnlyOneData, - required this.lockListInfoItemEntity, - Key? key}) - : super(key: key); + const LockDetailPage({required this.isOnlyOneData, required this.lockListInfoItemEntity, Key? key}) : super(key: key); final bool isOnlyOneData; final LockListInfoItemEntity lockListInfoItemEntity; @@ -46,18 +42,14 @@ class LockDetailPage extends StatefulWidget { State createState() => _LockDetailPageState(); } -class _LockDetailPageState extends State - with TickerProviderStateMixin, RouteAware { +class _LockDetailPageState extends State with TickerProviderStateMixin, RouteAware { // with RouteAware final LockDetailLogic logic = Get.put(LockDetailLogic()); final LockDetailState state = Get.find().state; @override void initState() { - super.initState(); - - state.animationController = - AnimationController(duration: const Duration(seconds: 1), vsync: this); + state.animationController = AnimationController(duration: const Duration(seconds: 1), vsync: this); state.animationController!.repeat(); //动画开始、结束、向前移动或向后移动时会调用StatusListener state.animationController!.addStatusListener((AnimationStatus status) { @@ -69,6 +61,7 @@ class _LockDetailPageState extends State state.animationController!.forward(); } }); + super.initState(); state.pageController.addListener(() { state.currentPage.value = state.pageController.page!.round(); @@ -77,9 +70,7 @@ class _LockDetailPageState extends State _initRefreshLockDetailInfoDataEventAction(); logic.initReplySubscription(); logic.initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction(); - logic.loadData( - lockListInfoItemEntity: widget.lockListInfoItemEntity, - isOnlyOneData: widget.isOnlyOneData); + logic.loadData(lockListInfoItemEntity: widget.lockListInfoItemEntity, isOnlyOneData: widget.isOnlyOneData); } @override @@ -95,9 +86,8 @@ class _LockDetailPageState extends State void _initRefreshLockDetailInfoDataEventAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _lockRefreshLockDetailInfoDataEvent = eventBus - .on() - .listen((RefreshLockDetailInfoDataEvent event) { + _lockRefreshLockDetailInfoDataEvent = + eventBus.on().listen((RefreshLockDetailInfoDataEvent event) { setState(() {}); }); } @@ -109,17 +99,12 @@ class _LockDetailPageState extends State //鑫泓佳布局 Widget xhjWidget() { - final bool isShowTip = (state.keyInfos.value.keyType == - XSConstantMacro.keyTypeTime || + final bool isShowTip = (state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || state.keyInfos.value.keyType == XSConstantMacro.keyTypeLoop) && - (DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) <= - 15 && - DateTool() - .compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) >= - 0) && + (DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) <= 15 && + DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) >= 0) && (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusNormalUse || - state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusWaitReceive); + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitReceive); return Scaffold( backgroundColor: Colors.white, body: Obx(() { @@ -141,8 +126,7 @@ class _LockDetailPageState extends State maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, - style: TextStyle( - color: const Color(0xffCBA74B), fontSize: 24.sp)), + style: TextStyle(color: const Color(0xffCBA74B), fontSize: 24.sp)), ), ), SizedBox(height: 10.h), @@ -161,10 +145,7 @@ class _LockDetailPageState extends State SizedBox( height: 20.h, ), - labelText( - img: 'images/icon_slider_horizontal.png', - text: '功能'.tr, - child: bottomWidget()), + labelText(img: 'images/icon_slider_horizontal.png', text: '功能'.tr, child: bottomWidget()), btnText( img: 'images/main/icon_main_set.png', text: '设置'.tr, @@ -172,17 +153,13 @@ class _LockDetailPageState extends State if (state.openDoorBtnisUneable.value == false) { return; } - Get.toNamed(Routers.lockSetPage, - arguments: { - 'lockId': state.keyInfos.value.lockId, - 'isOnlyOneData': state.isOnlyOneData - }); + Get.toNamed(Routers.lockSetPage, arguments: { + 'lockId': state.keyInfos.value.lockId, + 'isOnlyOneData': state.isOnlyOneData + }); }), if (!F.isProductionEnv) - labelText( - img: 'images/icon_puzzlepiece_extension.png', - text: '配件'.tr, - child: attachmentWidget()), + labelText(img: 'images/icon_puzzlepiece_extension.png', text: '配件'.tr, child: attachmentWidget()), ], ), ), @@ -201,24 +178,21 @@ class _LockDetailPageState extends State ); } - Widget btnText( - {required String img, required String text, required var onTap}) { + Widget btnText({required String img, required String text, required var onTap}) { return GestureDetector( onTap: onTap, child: Container( margin: EdgeInsets.symmetric(horizontal: 0.05.sw, vertical: 15.h), padding: EdgeInsets.symmetric(horizontal: 0.05.sw, vertical: 30.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(16.r), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.15), - offset: const Offset(0, 0), - blurRadius: 5.r, - spreadRadius: 0, - ), - ]), + decoration: + BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(16.r), boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.15), + offset: const Offset(0, 0), + blurRadius: 5.r, + spreadRadius: 0, + ), + ]), child: Row( children: [ FlavorsImg( @@ -247,22 +221,18 @@ class _LockDetailPageState extends State ); } - Widget labelText( - {required String img, required String text, required Widget child}) { + Widget labelText({required String img, required String text, required Widget child}) { return Container( margin: EdgeInsets.symmetric(horizontal: 0.05.sw, vertical: 15.h), padding: EdgeInsets.symmetric(horizontal: 0.05.sw, vertical: 15.h), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(16.r), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.15), - offset: const Offset(0, 0), - blurRadius: 5.r, - spreadRadius: 0, - ), - ]), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(16.r), boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.15), + offset: const Offset(0, 0), + blurRadius: 5.r, + spreadRadius: 0, + ), + ]), child: Column( children: [ Row( @@ -328,13 +298,10 @@ class _LockDetailPageState extends State Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - Image.asset(showElectricIcon(state.electricQuantity.value), - width: 30.w, height: 24.w), + Image.asset(showElectricIcon(state.electricQuantity.value), width: 30.w, height: 24.w), SizedBox(width: 2.w), Text('${state.electricQuantity.value}%', - style: TextStyle( - fontSize: 18.sp, - color: AppColors.darkGrayTextColor)), + style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor)), SizedBox(width: 2.w), Icon( Icons.info, // 使用内置的 warning 图标,它是一个叹号 @@ -345,24 +312,17 @@ class _LockDetailPageState extends State ], ), Visibility( - visible: state - .keyInfos.value.lockFeature!.isSupportBackupBattery == - 1, + visible: state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ FlavorsImg( - child: Image.asset( - showElectricIcon( - state.electricQuantityStandby.value), - width: 30.w, - height: 24.w), + child: Image.asset(showElectricIcon(state.electricQuantityStandby.value), + width: 30.w, height: 24.w), ), SizedBox(width: 2.w), Text('${state.electricQuantityStandby.value}%', - style: TextStyle( - fontSize: 18.sp, - color: AppColors.darkGrayTextColor)), + style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor)), SizedBox(width: 2.w), FlavorsImg( child: Icon( @@ -386,8 +346,7 @@ class _LockDetailPageState extends State child: GestureDetector( onTap: () { if (state.openDoorBtnisUneable.value == true) { - logic.functionBlocker - .block(isNeedRealNameAuthThenOpenLock); + logic.functionBlocker.block(isNeedRealNameAuthThenOpenLock); } }, onLongPressStart: (LongPressStartDetails details) { @@ -457,12 +416,10 @@ class _LockDetailPageState extends State right: 90.w, bottom: 1, child: Obx(() => Visibility( - visible: - state.keyInfos.value.lockSetting!.remoteUnlock == 1, + visible: state.keyInfos.value.lockSetting!.remoteUnlock == 1, child: GestureDetector( onTap: () { - ShowCupertinoAlertView().isToRemoteUnLockAlert( - remoteUnlockAction: () { + ShowCupertinoAlertView().isToRemoteUnLockAlert(remoteUnlockAction: () { if (state.keyInfos.value.hasGateway != 1) { logic.showToast('附近没有可用网关'.tr); } @@ -508,34 +465,24 @@ class _LockDetailPageState extends State return ListView( children: [ Visibility( - visible: - (state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || - state.keyInfos.value.keyType == - XSConstantMacro.keyTypeLoop) && // 限时、循环 - (DateTool().compareTimeGetDaysFromNow( - state.keyInfos.value.endDate!) <= - 15 && - DateTool().compareTimeGetDaysFromNow( - state.keyInfos.value.endDate!) >= - 0) && // 0到30天 - (state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusNormalUse || - state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusWaitReceive) // 正常使用、待接收 + visible: (state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime || + state.keyInfos.value.keyType == XSConstantMacro.keyTypeLoop) && // 限时、循环 + (DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) <= 15 && + DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!) >= 0) && // 0到30天 + (state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusNormalUse || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusWaitReceive) // 正常使用、待接收 , child: Container( // height: 30.h, width: 1.sw, color: const Color(0xFFFBEFD4), - padding: - EdgeInsets.only(top: 8.h, bottom: 8.h, right: 10.w, left: 10.h), + padding: EdgeInsets.only(top: 8.h, bottom: 8.h, right: 10.w, left: 10.h), child: Text( "${"钥匙将在".tr}${DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!)}${"天后失效".tr}", maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, - style: - TextStyle(color: const Color(0xffCBA74B), fontSize: 24.sp)), + style: TextStyle(color: const Color(0xffCBA74B), fontSize: 24.sp)), ), ), Stack(children: [ @@ -618,16 +565,11 @@ class _LockDetailPageState extends State mainAxisAlignment: MainAxisAlignment.end, children: [ FlavorsImg( - child: Image.asset( - showElectricIcon(state.electricQuantity.value), - width: 30.w, - height: 24.w), + child: Image.asset(showElectricIcon(state.electricQuantity.value), width: 30.w, height: 24.w), ), SizedBox(width: 2.w), Text('${state.electricQuantity.value}%', - style: TextStyle( - fontSize: 18.sp, - color: AppColors.darkGrayTextColor)), + style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor)), SizedBox(width: 2.w), state.keyInfos.value.network?.isOnline == 1 ? Icon( @@ -649,24 +591,17 @@ class _LockDetailPageState extends State ), ), Visibility( - visible: state - .keyInfos.value.lockFeature!.isSupportBackupBattery == - 1, + visible: state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ FlavorsImg( - child: Image.asset( - showElectricIcon( - state.electricQuantityStandby.value), - width: 30.w, - height: 24.w), + child: Image.asset(showElectricIcon(state.electricQuantityStandby.value), + width: 30.w, height: 24.w), ), SizedBox(width: 2.w), Text('${state.electricQuantityStandby.value}%', - style: TextStyle( - fontSize: 18.sp, - color: AppColors.darkGrayTextColor)), + style: TextStyle(fontSize: 18.sp, color: AppColors.darkGrayTextColor)), SizedBox(width: 2.w), FlavorsImg( child: Icon( @@ -756,12 +691,10 @@ class _LockDetailPageState extends State right: 90.w, bottom: 1, child: Obx(() => Visibility( - visible: - state.keyInfos.value.lockSetting!.remoteUnlock == 1, + visible: state.keyInfos.value.lockSetting!.remoteUnlock == 1, child: GestureDetector( onTap: () { - ShowCupertinoAlertView().isToRemoteUnLockAlert( - remoteUnlockAction: () { + ShowCupertinoAlertView().isToRemoteUnLockAlert(remoteUnlockAction: () { if (state.keyInfos.value.hasGateway != 1) { logic.showToast('附近没有可用网关'.tr); } @@ -792,10 +725,7 @@ class _LockDetailPageState extends State logic.getKeyStatusTextAndShow(), maxLines: 2, textAlign: TextAlign.center, - style: TextStyle( - fontSize: 22.sp, - color: AppColors.btnDisableColor, - fontWeight: FontWeight.w500), + style: TextStyle(fontSize: 22.sp, color: AppColors.btnDisableColor, fontWeight: FontWeight.w500), ), ), ), @@ -818,8 +748,7 @@ class _LockDetailPageState extends State Widget adminInfoView({bool center = true, bool max = true}) { return Row( - mainAxisAlignment: - center ? MainAxisAlignment.center : MainAxisAlignment.start, + mainAxisAlignment: center ? MainAxisAlignment.center : MainAxisAlignment.start, children: [ Row( mainAxisSize: max ? MainAxisSize.max : MainAxisSize.min, @@ -834,11 +763,8 @@ class _LockDetailPageState extends State Text( state.keyInfos.value.isLockOwner == 1 ? '超级管理员英文'.tr - : (state.keyInfos.value.keyRight == 1 - ? '授权管理员英文'.tr - : '普通用户'.tr), - style: TextStyle( - fontSize: 20.sp, color: AppColors.darkGrayTextColor), + : (state.keyInfos.value.keyRight == 1 ? '授权管理员英文'.tr : '普通用户'.tr), + style: TextStyle(fontSize: 20.sp, color: AppColors.darkGrayTextColor), ), SizedBox(width: 40.w), ], @@ -860,9 +786,7 @@ class _LockDetailPageState extends State '网关设备英文'.tr, style: TextStyle( fontSize: 20.sp, - color: state.keyInfos.value.hasGateway == 1 - ? AppColors.mainColor - : AppColors.btnDisableColor), + color: state.keyInfos.value.hasGateway == 1 ? AppColors.mainColor : AppColors.btnDisableColor), ), SizedBox(width: 20.w), ], @@ -874,18 +798,14 @@ class _LockDetailPageState extends State child: Image.asset('images/main/icon_lockDetail_needNetwork.png', width: 24.w, height: 20.w, - color: state.isOpenLockNeedOnline.value == 1 - ? AppColors.mainColor - : AppColors.btnDisableColor), + color: state.isOpenLockNeedOnline.value == 1 ? AppColors.mainColor : AppColors.btnDisableColor), ), SizedBox(width: 6.w), Text( '手机需联网英文'.tr, style: TextStyle( fontSize: 20.sp, - color: state.isOpenLockNeedOnline.value == 1 - ? AppColors.mainColor - : AppColors.btnDisableColor), + color: state.isOpenLockNeedOnline.value == 1 ? AppColors.mainColor : AppColors.btnDisableColor), ), ], ) @@ -894,8 +814,7 @@ class _LockDetailPageState extends State } //旋转动画 - Widget xhjBuildRotationTransition( - {required double width, required double height}) { + Widget xhjBuildRotationTransition({required double width, required double height}) { return Positioned( child: RotationTransition( //设置动画的旋转中心 @@ -907,17 +826,14 @@ class _LockDetailPageState extends State 'images/icon_circle_dotted.png', width: width, height: height, - color: state.isOpenPassageMode.value == 1 - ? Colors.red - : AppColors.mainColor, + color: state.isOpenPassageMode.value == 1 ? Colors.red : AppColors.mainColor, ), ), ); } //旋转动画 - Widget buildRotationTransition( - {required double width, required double height}) { + Widget buildRotationTransition({required double width, required double height}) { return Positioned( child: RotationTransition( //设置动画的旋转中心 @@ -949,9 +865,7 @@ class _LockDetailPageState extends State margin: EdgeInsets.symmetric(vertical: 10.0.w, horizontal: 6.0.w), decoration: BoxDecoration( shape: BoxShape.circle, - color: state.currentPage.value == index - ? AppColors.mainColor - : Colors.grey, + color: state.currentPage.value == index ? AppColors.mainColor : Colors.grey, ), ); }), @@ -997,8 +911,7 @@ class _LockDetailPageState extends State // '开门器', state.bottomBtnisUneable.value, () {})); // 新增配件 - showWidgetArr.add(bottomItem('images/main/icon_main_addLock.png', '新增配件'.tr, - state.bottomBtnisEable.value, () { + showWidgetArr.add(bottomItem('images/main/icon_main_addLock.png', '新增配件'.tr, state.bottomBtnisEable.value, () { Navigator.pushNamed(context, Routers.accessoriesListPage); })); @@ -1015,8 +928,7 @@ class _LockDetailPageState extends State crossAxisSpacing: 0.h, mainAxisExtent: 90.0, // 设置每个 item 的固定高度 ), - itemCount: (state.keyInfos.value.isLockOwner == 1 || - state.keyInfos.value.keyRight == 1) + itemCount: (state.keyInfos.value.isLockOwner == 1 || state.keyInfos.value.keyRight == 1) ? getAllWidget().length : getNormalWidget().length, itemBuilder: (context, index) { @@ -1041,8 +953,7 @@ class _LockDetailPageState extends State // 根据权限显示不同的底部按钮 List getBottomWidget() { - if (state.keyInfos.value.isLockOwner == 1 || - state.keyInfos.value.keyRight == 1) { + if (state.keyInfos.value.isLockOwner == 1 || state.keyInfos.value.keyRight == 1) { // 超级管理员、授权管理员 return getAllWidget(); } else { @@ -1062,22 +973,17 @@ class _LockDetailPageState extends State // })); // } // 操作记录 - showWidgetArr.add(bottomItem('images/main/icon_main_operatingRecord.png', - '操作记录'.tr, state.bottomBtnisEable.value, () { + showWidgetArr + .add(bottomItem('images/main/icon_main_operatingRecord.png', '操作记录'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.doorLockLogPage, - arguments: { - 'keyInfo': state.keyInfos.value - }); + arguments: {'keyInfo': state.keyInfos.value}); })); // 设置 if (F.isSKY) { - showWidgetArr - .add(bottomItem('images/main/icon_main_set.png', '设置'.tr, true, () { - Get.toNamed(Routers.lockSetPage, arguments: { - 'lockId': state.keyInfos.value.lockId, - 'isOnlyOneData': state.isOnlyOneData - }); + showWidgetArr.add(bottomItem('images/main/icon_main_set.png', '设置'.tr, true, () { + Get.toNamed(Routers.lockSetPage, + arguments: {'lockId': state.keyInfos.value.lockId, 'isOnlyOneData': state.isOnlyOneData}); })); } @@ -1097,26 +1003,22 @@ class _LockDetailPageState extends State // } // 电子钥匙 - showWidgetArr.add(bottomItem('images/main/icon_main_electronicKey.png', - '电子钥匙'.tr, state.bottomBtnisEable.value, () { + showWidgetArr + .add(bottomItem('images/main/icon_main_electronicKey.png', '电子钥匙'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.electronicKeyListPage); })); // 密码 if (state.keyInfos.value.lockFeature!.password == 1) { - showWidgetArr.add(bottomItem('images/main/icon_main_password.png', - '密码'.tr, state.bottomBtnisEable.value, () { + showWidgetArr.add(bottomItem('images/main/icon_main_password.png', '密码'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.passwordKeyListPage, - arguments: { - 'keyInfo': state.keyInfos.value - }); + arguments: {'keyInfo': state.keyInfos.value}); })); } // ic卡 if (state.keyInfos.value.lockFeature!.icCard == 1) { - showWidgetArr.add(bottomItem('images/main/icon_main_icCard.png', '卡'.tr, - state.bottomBtnisEable.value, () { + showWidgetArr.add(bottomItem('images/main/icon_main_icCard.png', '卡'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.cardListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1125,8 +1027,7 @@ class _LockDetailPageState extends State // 指纹 if (state.keyInfos.value.lockFeature!.fingerprint == 1) { - showWidgetArr.add(bottomItem('images/main/icon_main_fingerprint.png', - '指纹'.tr, state.bottomBtnisEable.value, () { + showWidgetArr.add(bottomItem('images/main/icon_main_fingerprint.png', '指纹'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.fingerprintListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1135,8 +1036,8 @@ class _LockDetailPageState extends State // 遥控 if (state.keyInfos.value.lockFeature!.bluetoothRemoteControl == 1) { - showWidgetArr.add(bottomItem('images/main/icon_main_remoteControl.png', - '遥控'.tr, state.bottomBtnisEable.value, () { + showWidgetArr + .add(bottomItem('images/main/icon_main_remoteControl.png', '遥控'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.remoteControlListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1146,9 +1047,7 @@ class _LockDetailPageState extends State //可视对讲门锁新增->人脸 if (state.keyInfos.value.lockFeature!.d3Face == 1) { showWidgetArr.add( - bottomItem( - 'images/main/icon_face.png', '人脸'.tr, state.bottomBtnisEable.value, - () { + bottomItem('images/main/icon_face.png', '人脸'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.faceListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1158,9 +1057,7 @@ class _LockDetailPageState extends State if (state.keyInfos.value.lockFeature!.isSupportIris == 1) { showWidgetArr.add( - bottomItem( - 'images/main/icon_iris.png', '虹膜'.tr, state.bottomBtnisEable.value, - () { + bottomItem('images/main/icon_iris.png', '虹膜'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.irisListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1170,9 +1067,7 @@ class _LockDetailPageState extends State if (state.keyInfos.value.lockFeature!.palmVein == 1) { showWidgetArr.add( - bottomItem( - 'images/main/icon_palm.png', '掌静脉'.tr, state.bottomBtnisEable.value, - () { + bottomItem('images/main/icon_palm.png', '掌静脉'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.palmListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1183,8 +1078,7 @@ class _LockDetailPageState extends State //可视对讲门锁新增->监控 if (state.keyInfos.value.lockFeature!.isSupportCatEye == 1) { showWidgetArr.add( - bottomItem('images/main/icon_catEyes.png', '监控'.tr, - state.bottomBtnisEable.value, () async { + bottomItem('images/main/icon_catEyes.png', '监控'.tr, state.bottomBtnisEable.value, () async { logic.sendMonitorMessage(); }), ); @@ -1192,33 +1086,28 @@ class _LockDetailPageState extends State // 授权管理员 if (state.keyInfos.value.isLockOwner == 1) { - showWidgetArr.add(bottomItem('images/main/icon_main_authorizedAdmin.png', - '授权管理员'.tr, state.bottomBtnisEable.value, () { + showWidgetArr + .add(bottomItem('images/main/icon_main_authorizedAdmin.png', '授权管理员'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.authorizedAdminListPage, - arguments: { - 'keyInfo': state.keyInfos.value - }); + arguments: {'keyInfo': state.keyInfos.value}); })); } final List endWiddget = []; endWiddget.add( // 操作记录 - bottomItem('images/main/icon_main_operatingRecord.png', '操作记录'.tr, - state.bottomBtnisEable.value, () { + bottomItem('images/main/icon_main_operatingRecord.png', '操作记录'.tr, state.bottomBtnisEable.value, () { // Get.toNamed(Routers.lockOperatingRecordPage, // arguments: {"keyInfo": state.keyInfos.value}); Get.toNamed(Routers.doorLockLogPage, - arguments: { - 'keyInfo': state.keyInfos.value - }); + arguments: {'keyInfo': state.keyInfos.value}); }), ); if (state.keyInfos.value.lockFeature!.isSupportCatEye == 1) { //视频日志 - endWiddget.add(bottomItem('images/main/icon_lockDetail_videoLog.png', - '视频日志'.tr, state.bottomBtnisEable.value, () { + endWiddget + .add(bottomItem('images/main/icon_lockDetail_videoLog.png', '视频日志'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.videoLogPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1227,12 +1116,10 @@ class _LockDetailPageState extends State if (!F.isProductionEnv) { endWiddget.add( // 消息提醒 - bottomItem('images/main/icon_lockDetail_messageReminding.png', - '消息提醒'.tr, state.bottomBtnisEable.value, () { + bottomItem('images/main/icon_lockDetail_messageReminding.png', '消息提醒'.tr, state.bottomBtnisEable.value, () { Get.toNamed(Routers.msgNotificationPage, arguments: { 'lockId': state.keyInfos.value.lockId, - 'isSupportCatEye': - state.keyInfos.value.lockFeature!.isSupportCatEye, + 'isSupportCatEye': state.keyInfos.value.lockFeature!.isSupportCatEye, }); }), ); @@ -1254,8 +1141,7 @@ class _LockDetailPageState extends State return showWidgetArr; } - Widget bottomItem( - String iconUrl, String name, bool bottomBtnisEable, Function() onClick) { + Widget bottomItem(String iconUrl, String name, bool bottomBtnisEable, Function() onClick) { final Widget child = F.sw( skyCall: () => Container( color: Colors.white, @@ -1268,9 +1154,7 @@ class _LockDetailPageState extends State child: Image.asset(iconUrl, width: 42.w, height: 42.w, - color: bottomBtnisEable - ? AppColors.mainColor - : AppColors.lockDetailBottomBtnUneable, + color: bottomBtnisEable ? AppColors.mainColor : AppColors.lockDetailBottomBtnUneable, fit: BoxFit.fitWidth), ), SizedBox(height: 5.h), @@ -1278,9 +1162,7 @@ class _LockDetailPageState extends State child: Text(name, style: TextStyle( fontSize: 20.sp, - color: bottomBtnisEable - ? AppColors.blackColor - : AppColors.lockDetailBottomBtnUneable), + color: bottomBtnisEable ? AppColors.blackColor : AppColors.lockDetailBottomBtnUneable), textAlign: TextAlign.center)) ], ), @@ -1298,9 +1180,7 @@ class _LockDetailPageState extends State child: Image.asset(iconUrl, width: 42.w, height: 42.w, - color: bottomBtnisEable - ? AppColors.mainColor - : AppColors.lockDetailBottomBtnUneable, + color: bottomBtnisEable ? AppColors.mainColor : AppColors.lockDetailBottomBtnUneable, fit: BoxFit.fitWidth), ), SizedBox(height: 15.h), @@ -1313,9 +1193,7 @@ class _LockDetailPageState extends State style: TextStyle( fontSize: 20.sp, height: 1.0, - color: bottomBtnisEable - ? AppColors.blackColor - : AppColors.lockDetailBottomBtnUneable), + color: bottomBtnisEable ? AppColors.blackColor : AppColors.lockDetailBottomBtnUneable), ), ], ), @@ -1347,18 +1225,14 @@ class _LockDetailPageState extends State Widget _unlockSuccessWidget() { String lockAlias = state.keyInfos.value.lockAlias!; - final TextStyle lockAliasTextStyle = - TextStyle(color: AppColors.placeholderTextColor, fontSize: 24.sp); + final TextStyle lockAliasTextStyle = TextStyle(color: AppColors.placeholderTextColor, fontSize: 24.sp); final TextPainter textPainter = TextPainter( - text: TextSpan(text: lockAlias, style: lockAliasTextStyle), - maxLines: 1, - textDirection: TextDirection.ltr) + text: TextSpan(text: lockAlias, style: lockAliasTextStyle), maxLines: 1, textDirection: TextDirection.ltr) ..layout(minWidth: 0, maxWidth: double.infinity); final double textSizeWidth = textPainter.size.width; // 获取文本的尺寸 if (textSizeWidth > 358.w * 2 - 20) { - lockAlias = - '${lockAlias.substring(0, lockAlias.length > 25 ? 25 : lockAlias.length)}...'; + lockAlias = '${lockAlias.substring(0, lockAlias.length > 25 ? 25 : lockAlias.length)}...'; } return Center( child: Stack( @@ -1378,17 +1252,13 @@ class _LockDetailPageState extends State Text(state.iSOpenLock.value == true ? '已开锁'.tr : '已闭锁'.tr, maxLines: 2, overflow: TextOverflow.ellipsis, - style: TextStyle( - color: AppColors.mainColor, - fontSize: 32.sp, - fontWeight: FontWeight.w600)), + style: TextStyle(color: AppColors.mainColor, fontSize: 32.sp, fontWeight: FontWeight.w600)), SizedBox( height: 10.h, ), Text( lockAlias, - style: TextStyle( - color: AppColors.placeholderTextColor, fontSize: 24.sp), + style: TextStyle(color: AppColors.placeholderTextColor, fontSize: 24.sp), maxLines: 2, ), SizedBox( @@ -1396,8 +1266,7 @@ class _LockDetailPageState extends State ), Text( getCurrentFormattedTime(), - style: TextStyle( - color: AppColors.darkGrayTextColor, fontSize: 24.sp), + style: TextStyle(color: AppColors.darkGrayTextColor, fontSize: 24.sp), ) ], )), @@ -1476,10 +1345,7 @@ class _LockDetailPageState extends State // AppLog.log('点击开锁 state.openDoorModel = 0 不需要联网'); // FlutterBuglyPlugin.reportException(exceptionName: '点击了不需要联网开锁'); BuglyTool.uploadException( - message: '点击了不需要联网开锁', - detail: '点击了不需要联网开锁 openDoorModel:${state.openDoorModel}', - upload: false, - begin: true); + message: '点击了不需要联网开锁', detail: '点击了不需要联网开锁 openDoorModel:${state.openDoorModel}', upload: false, begin: true); AppLog.log('点击开锁 state.openDoorModel = 0 不需要联网'); logic.openDoorAction(); } else { @@ -1488,10 +1354,7 @@ class _LockDetailPageState extends State // AppLog.log('点击开锁 state.openDoorModel = 2 需要联网'); // FlutterBuglyPlugin.reportException(exceptionName: '点击了需要联网开锁'); BuglyTool.uploadException( - message: '点击了需要联网开锁', - detail: '点击了需要联网开锁 openDoorModel:${state.openDoorModel}', - upload: false, - begin: true); + message: '点击了需要联网开锁', detail: '点击了需要联网开锁 openDoorModel:${state.openDoorModel}', upload: false, begin: true); AppLog.log('点击开锁 state.openDoorModel = 2 需要联网'); logic.getLockNetToken(); } @@ -1526,8 +1389,7 @@ class _LockDetailPageState extends State state.closedUnlockSuccessfulTimer?.cancel(); _lockRefreshLockDetailInfoDataEvent?.cancel(); state.replySubscription.cancel(); - state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent - ?.cancel(); + state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent?.cancel(); state.LockSetChangeSetRefreshLockDetailWithTypeSubscription?.cancel(); if (state.animationController != null) { state.animationController!.dispose();