From ca20145ca317342f569b397a4ae7428c835f11d3 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Tue, 30 Jan 2024 11:18:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=81=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=85=8D=E4=BB=B6=E5=8C=BA=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=88=E6=9C=AA=E5=AE=8C=E5=96=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockDetail/lockDetail_page.dart | 167 +++++++++--------- .../lockDetail/lockDetail_state.dart | 12 +- .../lockSet/lockSet/lockSet_page.dart | 93 +++++----- 3 files changed, 141 insertions(+), 131 deletions(-) diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 757252d7..05d68662 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -80,6 +80,10 @@ class _LockDetailPageState extends State // logic.startScanAction(); listeningAnimations(); + + state.pageController.addListener(() { + state.currentPage.value = state.pageController.page!.round(); + }); } @override @@ -94,21 +98,24 @@ class _LockDetailPageState extends State child: Column( children: [ topWidget(), - Expanded(child: Obx(() => bottomWidget())), - - // SingleChildScrollView( - // scrollDirection: Axis.horizontal, - // child: Row( - // children: [ - // bottomWidget(), - // Container( - // width: 1.sw, - // height: 200, - // color: Colors.white, - // ) - // ], - // ), - // ), + SizedBox( + height: 10.h, + ), + Obx(() => buildPageIndicator()), + Expanded( + child: Container( + margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 30.h), + child: PageView( + scrollDirection: Axis.horizontal, + controller: state.pageController, + // child: Row( + children: [ + Obx(() => bottomWidget()), + Obx(() => attachmentWidget()), + ], + // ), + ), + )) ], ), ), @@ -322,10 +329,66 @@ class _LockDetailPageState extends State ); } +//圆点指示器 + Widget buildPageIndicator() { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: List.generate(2, (index) { + return Container( + width: 10.0.w, + height: 10.0.w, + 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, + ), + ); + }), + ); + } + +//配件区域 + Widget attachmentWidget() { + return SizedBox( + width: ScreenUtil().screenWidth - 20.w, + child: GridView.count( + crossAxisCount: 4, + // childAspectRatio: 3, + crossAxisSpacing: 20.w, + mainAxisSpacing: 0.h, + physics: const NeverScrollableScrollPhysics(), + children: getAttachmentWidget()), + ); + } + + // 配件配置 + List getAttachmentWidget() { + var showWidgetArr = []; + // 无线键盘 + if (state.isAttendance.value == 1) { + showWidgetArr.add(bottomItem('images/main/icon_main_clockingIn.png', + '无线键盘', state.bottomBtnisUneable.value, () {})); + } + // 照明 + showWidgetArr.add(bottomItem('images/main/icon_main_operatingRecord.png', + '照明', state.bottomBtnisUneable.value, () {})); + + // 照明 + showWidgetArr.add(bottomItem('images/main/icon_main_operatingRecord.png', + '开门器', state.bottomBtnisUneable.value, () {})); + + // 新增配件 + showWidgetArr.add(bottomItem('images/main/icon_main_set.png', '新增配件', + state.bottomBtnisUneable.value, () {})); + + return showWidgetArr; + } + Widget bottomWidget() { - return Container( - margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 40.h), - // color: Colors.blue, + return SizedBox( + width: ScreenUtil().screenWidth - 20.w, child: GridView.count( crossAxisCount: 4, // childAspectRatio: 3, @@ -336,74 +399,6 @@ class _LockDetailPageState extends State ); } - //横向滑动区域 - Widget partSectionWidget() { - return SliverToBoxAdapter( - child: SizedBox( - height: 400.0, // Adjust the height as needed - width: ScreenUtil().screenWidth, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: [ - Container( - margin: EdgeInsets.all(10.0), - color: Colors.red, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('GridView 1'), - SizedBox(height: 10.0), - Container( - height: 200.0, - width: 200.0, - child: GridView.count( - crossAxisCount: 2, - children: List.generate(6, (index) { - return Center( - child: Text( - 'Item ${index + 6}', - style: TextStyle(fontSize: 20.0), - ), - ); - }), - ), - ), - ], - ), - ), - Container( - margin: EdgeInsets.all(10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('GridView 2'), - SizedBox(height: 10.0), - Container( - height: 200.0, - width: 200.0, - child: GridView.count( - crossAxisCount: 2, - children: List.generate(6, (index) { - return Center( - child: Text( - 'Item ${index + 6}', - style: TextStyle(fontSize: 20.0), - ), - ); - }), - ), - ), - ], - ), - ), - ], - ), - ), - ), - ); - } - // 根据权限显示不同的底部按钮 List getBottomWidget() { if (state.keyInfos.value.isLockOwner == 1 || diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart index b088909b..7f20fac1 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter/material.dart'; @@ -23,13 +22,13 @@ class LockDetailState { var senderUserId = 0; var isOnlyOneData = false; - var isAttendance = 0.obs;// 是否开启考勤 + var isAttendance = 0.obs; // 是否开启考勤 var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网 var electricQuantity = 0.obs; // 电量 var isOpenPassageMode = 0.obs; // 是否开启了常开模式 var lockAlias = "".obs; // 锁名字 - var currentDeviceUUid = "".obs;// 当前设备的uuid + var currentDeviceUUid = "".obs; // 当前设备的uuid var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 var iSClosedUnlockSuccessfulPopup = false.obs; // 是否关闭了开锁成功弹窗 @@ -41,11 +40,14 @@ class LockDetailState { //过渡动画控制器 late AnimationController animationController; // var lockState = 0.obs;// 0未连接普通状态 1连接开锁中(展示动画) 2已连接开锁成功 3检测可用性 4连接失败 5连接失败重连中 - var openLockBtnState = 0.obs;// 0普通状态(未转动) 1连接中(转动状态) + var openLockBtnState = 0.obs; // 0普通状态(未转动) 1连接中(转动状态) // var connectState = 0.obs;// 0未连接 1连接 + final PageController pageController = PageController(); + var currentPage = 0.obs; + // LockDetailState() { // Map map = Get.arguments; // lockCount = map["lockCount"]; // } -} \ No newline at end of file +} diff --git a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart index e6922ced..e5e5a368 100644 --- a/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/lockSet/lockSet_page.dart @@ -30,7 +30,7 @@ class _LockSetPageState extends State with RouteAware { final state = Get.find().state; Future getHttpData() async { - logic.getLockSettingInfoData().then((LockSetInfoEntity value){ + logic.getLockSettingInfoData().then((LockSetInfoEntity value) { setState(() {}); }); } @@ -56,7 +56,7 @@ class _LockSetPageState extends State with RouteAware { haveBack: true, backgroundColor: AppColors.mainColor), body: EasyRefreshTool( - onRefresh: (){ + onRefresh: () { getHttpData(); }, child: Column( @@ -191,41 +191,42 @@ class _LockSetPageState extends State with RouteAware { Get.toNamed(Routers.doorMagneticPage); // Toast.show(msg: "功能暂未开放"); }))), - // 无线键盘 - Obx(() => Visibility( - visible: state.lockFeature.value.wirelessKeyboard == 1 ? true : false, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.wirelessKeyboard!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.wirelessKeyboardPage); - // Toast.show(msg: "功能暂未开放"); - }))), - // 照明 - Obx(() => Visibility( - visible: state.lockFeature.value.lightingTime == 1 ? true : false, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.illumination!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - logic.showToast("功能暂未开放"); - }))), + //by DaisyWu 田总:移至锁详情配件区 + // // 无线键盘 + // Obx(() => Visibility( + // visible: state.lockFeature.value.wirelessKeyboard == 1 ? true : false, + // child: CommonItem( + // leftTitel: TranslationLoader.lanKeys!.wirelessKeyboard!.tr, + // rightTitle: "", + // isHaveLine: true, + // isHaveDirection: true, + // action: () { + // Get.toNamed(Routers.wirelessKeyboardPage); + // // Toast.show(msg: "功能暂未开放"); + // }))), + // // 照明 + // Obx(() => Visibility( + // visible: state.lockFeature.value.lightingTime == 1 ? true : false, + // child: CommonItem( + // leftTitel: TranslationLoader.lanKeys!.illumination!.tr, + // rightTitle: "", + // isHaveLine: true, + // isHaveDirection: true, + // action: () { + // logic.showToast("功能暂未开放"); + // }))), // 开门器 - Visibility( - visible: state.lockFeature.value.doorStatus == 1 ? true : false, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.doorOpener!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - logic.showToast("功能暂未开放"); - })), - SizedBox(height: 10.h), + // Visibility( + // visible: state.lockFeature.value.doorStatus == 1 ? true : false, + // child: CommonItem( + // leftTitel: TranslationLoader.lanKeys!.doorOpener!.tr, + // rightTitle: "", + // isHaveLine: false, + // isHaveDirection: true, + // action: () { + // logic.showToast("功能暂未开放"); + // })), + // SizedBox(height: 10.h), // 自动闭锁 Obx(() => Visibility( visible: state.lockFeature.value.autoLock == 1 ? true : false, @@ -330,7 +331,10 @@ class _LockSetPageState extends State with RouteAware { }))), // 重置键 Obx(() => Visibility( - visible: (state.lockBasicInfo.value.isLockOwner == 1 && state.lockFeature.value.resetSwitch == 1) ? true : false, + visible: (state.lockBasicInfo.value.isLockOwner == 1 && + state.lockFeature.value.resetSwitch == 1) + ? true + : false, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.resetButton!.tr, rightTitle: (state.lockSettingInfo.value.resetSwitch ?? 0) == 1 @@ -470,7 +474,10 @@ class _LockSetPageState extends State with RouteAware { // 考勤 Obx( () => Visibility( - visible: (state.lockBasicInfo.value.isLockOwner == 1 && state.lockFeature.value.attendance == 1) ? true : false, + visible: (state.lockBasicInfo.value.isLockOwner == 1 && + state.lockFeature.value.attendance == 1) + ? true + : false, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr, rightTitle: "", @@ -481,7 +488,10 @@ class _LockSetPageState extends State with RouteAware { // 开锁提醒 Obx( () => Visibility( - visible: state.lockBasicInfo.value.isLockOwner == 1 && state.lockFeature.value.unlockReminder == 1 ? true : false, + visible: state.lockBasicInfo.value.isLockOwner == 1 && + state.lockFeature.value.unlockReminder == 1 + ? true + : false, child: CommonItem( leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, rightTitle: "", @@ -492,7 +502,10 @@ class _LockSetPageState extends State with RouteAware { // APP开锁时是否需联网 Obx( () => Visibility( - visible: state.lockBasicInfo.value.isLockOwner == 1 && state.lockFeature.value.appUnlockOnline == 1 ? true : false, + visible: state.lockBasicInfo.value.isLockOwner == 1 && + state.lockFeature.value.appUnlockOnline == 1 + ? true + : false, child: CommonItem( leftTitel: TranslationLoader .lanKeys!.whetherInternetRequiredWhenUnlocking!.tr,