From 17bea0f9fa2a30c1dd9bd1f39d67f779caeb86aa Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Tue, 30 Apr 2024 11:33:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E9=91=AB=E6=B3=93?= =?UTF-8?q?=E4=BD=B3=E8=AE=BE=E5=A4=87=E5=8C=B9=E9=85=8D=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mine/addLock/addLock/addLock_page.dart | 15 +- .../addLock/nearbyLock/nearbyLock_page.dart | 67 +++-- .../selectLockType/selectLockType_page.dart | 256 +++++++++++------- 3 files changed, 217 insertions(+), 121 deletions(-) diff --git a/star_lock/lib/mine/addLock/addLock/addLock_page.dart b/star_lock/lib/mine/addLock/addLock/addLock_page.dart index d346f578..55dd9fc4 100644 --- a/star_lock/lib/mine/addLock/addLock/addLock_page.dart +++ b/star_lock/lib/mine/addLock/addLock/addLock_page.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:star_lock/flavors.dart'; import 'package:star_lock/mine/addLock/addLock/addLock_logic.dart'; import 'package:star_lock/tools/appFirstEnterHandle.dart'; import 'package:star_lock/tools/storage.dart'; @@ -30,10 +31,20 @@ class _AddLockPageState extends State with BaseWidget { builder: (AddLockLogic logic) { return Scaffold( backgroundColor: Colors.white, - appBar: TitleAppBar( + appBar: F.sw( + defaultCall: () => TitleAppBar( barTitle: TranslationLoader.lanKeys!.addLock!.tr, haveBack: true, - backgroundColor: AppColors.mainColor), + backgroundColor: AppColors.mainColor, + ), + xhjCall: () => TitleAppBar( + barTitle: TranslationLoader.lanKeys!.addLock!.tr, + haveBack: true, + backgroundColor: Colors.white, + iconColor: AppColors.blackColor, + titleColor: AppColors.blackColor, + ), + ), body: ListView( // mainAxisAlignment: MainAxisAlignment.center, // crossAxisAlignment: CrossAxisAlignment.center, diff --git a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_page.dart b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_page.dart index bc750610..a474bc92 100644 --- a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_page.dart +++ b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_page.dart @@ -1,10 +1,10 @@ - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/flavors.dart'; import '../../../app_settings/app_colors.dart'; import '../../../blue/blue_manage.dart'; import '../../../tools/appRouteObserver.dart'; @@ -27,30 +27,48 @@ class _NearbyLockPageState extends State with RouteAware { void initState() { // TODO: implement initState super.initState(); - } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.nearbyLock!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor, - actionsList: [ - CupertinoActivityIndicator(radius: 18.w, color: Colors.white,), - SizedBox(width: 30.w) - ], + appBar: F.sw( + defaultCall: () => TitleAppBar( + barTitle: TranslationLoader.lanKeys!.nearbyLock!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + actionsList: [ + CupertinoActivityIndicator( + radius: 18.w, + color: Colors.white, + ), + SizedBox(width: 30.w) + ]), + xhjCall: () => TitleAppBar( + barTitle: TranslationLoader.lanKeys!.nearbyLock!.tr, + haveBack: true, + backgroundColor: Colors.white, + iconColor: AppColors.blackColor, + titleColor: AppColors.blackColor, + actionsList: [ + CupertinoActivityIndicator( + radius: 18.w, + color: AppColors.blackColor, + ), + SizedBox(width: 30.w) + ]), ), body: Obx(() { return ListView.separated( itemCount: state.devices.length, itemBuilder: (c, index) { - return nearbyLockItem('images/icon_lockGroup_item.png', state.devices[index], () { + return nearbyLockItem( + 'images/icon_lockGroup_item.png', state.devices[index], () { // Navigator.pushNamed(context, Routers.lockAddressPage); // logic.getPublicKey(state.devices[index].serviceUuids[0].toString()); - state.selectLockName.value = state.devices[index].advertisementData.advName; + state.selectLockName.value = + state.devices[index].advertisementData.advName; logic.connect(state.devices[index].advertisementData.advName); // Get.toNamed(Routers.lockAddressGaoDePage); }); @@ -68,9 +86,16 @@ class _NearbyLockPageState extends State with RouteAware { ); } - Widget nearbyLockItem(String lockTypeIcon, ScanResult scanResult, Function() action ) { + Widget nearbyLockItem( + String lockTypeIcon, ScanResult scanResult, Function() action) { return GestureDetector( - onTap: ((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString()[33] == "1") ? action : null, + onTap: ((scanResult.advertisementData.serviceUuids.isNotEmpty + ? scanResult.advertisementData.serviceUuids[0] + : "") + .toString()[33] == + "1") + ? action + : null, child: Column( // mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -92,7 +117,18 @@ class _NearbyLockPageState extends State with RouteAware { crossAxisAlignment: CrossAxisAlignment.start, children: [ // 第32、33两位00 表示休眠, 01表示唤醒 - Text(scanResult.advertisementData.advName, style: TextStyle(fontSize: 20.sp, color: ((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString()[33] == "1") ? AppColors.blackColor : Colors.grey)), + Text(scanResult.advertisementData.advName, + style: TextStyle( + fontSize: 20.sp, + color: ((scanResult.advertisementData.serviceUuids + .isNotEmpty + ? scanResult.advertisementData + .serviceUuids[0] + : "") + .toString()[33] == + "1") + ? AppColors.blackColor + : Colors.grey)), ], ), SizedBox( @@ -173,5 +209,4 @@ class _NearbyLockPageState extends State with RouteAware { logic.stopScanBlueList(); BlueManage().disconnect(); } - } diff --git a/star_lock/lib/mine/addLock/selectLockType/selectLockType_page.dart b/star_lock/lib/mine/addLock/selectLockType/selectLockType_page.dart index eac43537..56e8b862 100644 --- a/star_lock/lib/mine/addLock/selectLockType/selectLockType_page.dart +++ b/star_lock/lib/mine/addLock/selectLockType/selectLockType_page.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -18,7 +17,8 @@ class SelectLockTypePage extends StatefulWidget { State createState() => _SelectLockTypePageState(); } -class _SelectLockTypePageState extends State with BaseWidget { +class _SelectLockTypePageState extends State + with BaseWidget { final logic = Get.put(SelectLockTypeLogic()); final state = Get.find().state; @@ -26,121 +26,165 @@ class _SelectLockTypePageState extends State with BaseWidget Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( + appBar: F.sw( + defaultCall: () => TitleAppBar( barTitle: TranslationLoader.lanKeys!.selectLockType!.tr, haveBack: true, - backgroundColor: AppColors.mainColor), + backgroundColor: AppColors.mainColor, + ), + xhjCall: () => TitleAppBar( + barTitle: TranslationLoader.lanKeys!.selectLockType!.tr, + haveBack: true, + backgroundColor: Colors.white, + iconColor: AppColors.blackColor, + titleColor: AppColors.blackColor, + ), + ), body: Column( children: [ allLock(), - Expanded( - child: Container( - padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10), - child: GridView.count( - crossAxisCount: 2, - childAspectRatio: 2.83, - crossAxisSpacing: 10, - mainAxisSpacing: 10, - children: [ - lockTypeItem('images/lockType/lockType_doorLock.png', - TranslationLoader.lanKeys!.doorLock!.tr, () { - Navigator.pushNamed(context, Routers.addLockPage, - arguments: {'getLockType': 1}); - }), - if (!F.isLite) - lockTypeItem('images/lockType/lockType_NFCLock.png', - TranslationLoader.lanKeys!.NFCPassiveLock!.tr, () { - // Navigator.pushNamed(context, Routers.addLockPage); - }), - if (!F.isLite) - lockTypeItem('images/lockType/lockType_padlock.png', - TranslationLoader.lanKeys!.padlock!.tr, () { - // Navigator.pushNamed(context, Routers.addLockPage); - }), - lockTypeItem('images/lockType/lockType_safeLock.png', - TranslationLoader.lanKeys!.safeLock!.tr, () { - Navigator.pushNamed(context, Routers.addLockPage, - arguments: {'getLockType': 4}); - }), - lockTypeItem('images/lockType/lockType_parkingLock.png', - TranslationLoader.lanKeys!.parkingLock!.tr, () { - Navigator.pushNamed(context, Routers.addLockPage, - arguments: {'getLockType': 5}); - }), - lockTypeItem('images/lockType/lockType_entranceGuardLock.png', - TranslationLoader.lanKeys!.itelligentAccessControl!.tr, - () { - Navigator.pushNamed(context, Routers.addLockPage, - arguments: {'getLockType': 6}); - }), - - // lockTypeItem('images/lockType/lockType_bicycleLock.png', - // TranslationLoader.lanKeys!.bicycleLock!.tr, () { - // Navigator.pushNamed(context, Routers.addLockPage); - // }), - if (!F.isLite) - lockTypeItem('images/lockType/lockType_gatewayLock.png', - TranslationLoader.lanKeys!.gateway!.tr, () { - // Navigator.pushNamed(context, Routers.gatewayListPage); - }), - if (!F.isLite) - lockTypeItem('images/lockType/lockType_camera.png', '网络摄像头'.tr, - () { - // Navigator.pushNamed(context, Routers.gatewayListPage); - }), - ], - ), - ), - ) + lockTypeList(), ], ), ); } + //锁列表控件 + Widget lockTypeList() { + Widget view = F.sw( + defaultCall: () => GridView.count( + crossAxisCount: 2, + childAspectRatio: 2.83, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + children: getLockTypeList(), + ), + xhjCall: () => GridView.count( + crossAxisCount: 1, + childAspectRatio: 6, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + children: getLockTypeList(), + )); + return Expanded( + child: Container( + padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10), + child: view, + ), + ); + } + + //所有的锁类型匹配 + List getLockTypeList() { + return [ + lockTypeItem('images/lockType/lockType_doorLock.png', + TranslationLoader.lanKeys!.doorLock!.tr, () { + Navigator.pushNamed(context, Routers.addLockPage, + arguments: {'getLockType': 1}); + }), + if (!F.isLite) + lockTypeItem('images/lockType/lockType_NFCLock.png', + TranslationLoader.lanKeys!.NFCPassiveLock!.tr, () { + // Navigator.pushNamed(context, Routers.addLockPage); + }), + if (!F.isLite) + lockTypeItem('images/lockType/lockType_padlock.png', + TranslationLoader.lanKeys!.padlock!.tr, () { + // Navigator.pushNamed(context, Routers.addLockPage); + }), + lockTypeItem('images/lockType/lockType_safeLock.png', + TranslationLoader.lanKeys!.safeLock!.tr, () { + Navigator.pushNamed(context, Routers.addLockPage, + arguments: {'getLockType': 4}); + }), + lockTypeItem('images/lockType/lockType_parkingLock.png', + TranslationLoader.lanKeys!.parkingLock!.tr, () { + Navigator.pushNamed(context, Routers.addLockPage, + arguments: {'getLockType': 5}); + }), + lockTypeItem('images/lockType/lockType_entranceGuardLock.png', + TranslationLoader.lanKeys!.itelligentAccessControl!.tr, () { + Navigator.pushNamed(context, Routers.addLockPage, + arguments: {'getLockType': 6}); + }), + + // lockTypeItem('images/lockType/lockType_bicycleLock.png', + // TranslationLoader.lanKeys!.bicycleLock!.tr, () { + // Navigator.pushNamed(context, Routers.addLockPage); + // }), + if (!F.isLite) + lockTypeItem('images/lockType/lockType_gatewayLock.png', + TranslationLoader.lanKeys!.gateway!.tr, () { + // Navigator.pushNamed(context, Routers.gatewayListPage); + }), + if (!F.isLite) + lockTypeItem('images/lockType/lockType_camera.png', '网络摄像头'.tr, () { + // Navigator.pushNamed(context, Routers.gatewayListPage); + }), + ]; + } + + //搜索全部的按钮 Widget allLock() { + Widget view = Row( + children: [ + SizedBox(width: 30.w), + Image.asset( + 'images/lockType/lockType_allLocks.png', + width: 88.w, + height: 80.w, + ), + SizedBox(width: 40.w), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(TranslationLoader.lanKeys!.allLock!.tr, + style: TextStyle( + fontSize: 24.sp, + )), + Text(TranslationLoader.lanKeys!.searchAllLockType!.tr, + style: TextStyle( + fontSize: 20.sp, color: AppColors.darkGrayTextColor)), + ], + ), + ), + SizedBox(width: 40.w), + Image.asset( + 'images/icon_right_grey.png', + width: 12.w, + height: 21.w, + ), + SizedBox(width: 40.w), + ], + ); + + //风格区分 + view = F.sw( + defaultCall: () => Container( + height: 150.h, + color: Colors.white, + margin: const EdgeInsets.all(10), + child: view, + ), + xhjCall: () => Container( + height: 150.h, + margin: const EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(color: AppColors.mainColor, width: 1), + borderRadius: BorderRadius.circular(20.r), + ), + child: view, + )); + return GestureDetector( onTap: () { Navigator.pushNamed(context, Routers.addLockPage, arguments: {'getLockType': 0}); }, - child: Container( - height: 150.h, - color: Colors.white, - margin: const EdgeInsets.all(10), - child: Row( - children: [ - SizedBox(width: 30.w), - Image.asset( - 'images/lockType/lockType_allLocks.png', - width: 88.w, - height: 80.w, - ), - SizedBox(width: 40.w), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(TranslationLoader.lanKeys!.allLock!.tr, - style: TextStyle( - fontSize: 24.sp, - )), - Text(TranslationLoader.lanKeys!.searchAllLockType!.tr, - style: TextStyle( - fontSize: 20.sp, color: AppColors.darkGrayTextColor)), - ], - ), - ), - SizedBox(width: 40.w), - Image.asset( - 'images/icon_right_grey.png', - width: 12.w, - height: 21.w, - ), - SizedBox(width: 40.w), - ], - ), - ), + child: view, ); } @@ -150,8 +194,14 @@ class _SelectLockTypePageState extends State with BaseWidget onTap: action, child: Container( height: 120.h, - color: Colors.white, - // margin: EdgeInsets.all(10), + decoration: F.sw( + defaultCall: () => const BoxDecoration( + color: Colors.white, + ), + xhjCall: () => BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20.r), + )), child: Row( children: [ SizedBox(width: 30.w),