From 32e9368dcf8269195492cc6dad34c1d6f811b567 Mon Sep 17 00:00:00 2001 From: ante <448468458@qq.com> Date: Thu, 18 Apr 2024 16:27:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=E6=98=9F=E6=98=9F=E9=94=81ui=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 10244 bytes star_lock/android/app/build.gradle | 22 +- star_lock/android/build.gradle | 2 + star_lock/flavorizr.yaml | 2 +- star_lock/ios/Flutter/xhjDebug.xcconfig | 6 +- star_lock/ios/Flutter/xhjProfile.xcconfig | 6 +- star_lock/ios/Flutter/xhjRelease.xcconfig | 6 +- .../ios/Runner.xcodeproj/project.pbxproj | 40 +- star_lock/lib/flavors.dart | 4 +- .../lockDetail/lockDetail_page.dart | 349 +++++++++--------- .../lockMain/xhj/lockMain_xhj_page.dart | 48 +-- .../lib/{main_xhj.dart => main_xhj_full.dart} | 0 star_lock/lib/main_xhj_lite.dart | 9 + .../minePersonInfo_page.dart | 10 + star_lock/lib/tools/pay/wx_pay_tool.dart | 2 +- star_lock/lib/widget/flavors_img.dart | 27 ++ star_lock/pubspec.yaml | 5 +- 17 files changed, 298 insertions(+), 240 deletions(-) rename star_lock/lib/{main_xhj.dart => main_xhj_full.dart} (100%) create mode 100644 star_lock/lib/main_xhj_lite.dart create mode 100644 star_lock/lib/widget/flavors_img.dart diff --git a/.DS_Store b/.DS_Store index a95f5409ebc2504e185257b3930bfe0a53414672..82334faf27d99ac0cec45108068c884343b5ee59 100644 GIT binary patch literal 10244 zcmeHMTWl0n7(V~Bz!^KxDHd9m%Py>3#HO^RkfL0+H-rMVVYltJpzG|;v>iJ;Q+H-} zfrg~S7!}k9qb5EfL0^0zUht9_yd@f=5H4wm5;X*`Pd@R2iN^oTnT0Mayr@YNXOcPp z{Qo)sKj(b&f9LEuO9+9stlCIOh!8^YW>S{0C~>iRcHeRdo`v}V`V(WgF`BZ{W4E;Q z4L$-s0zLvh0zLvh0@DQnT(j9lE4cJa9|0c$AA#!#u=yc`Hou zb}xLE*#pXuCnKJm;1X-_0`7{EyMnjH0Pc?Vkk>Ba$q6pGI{|O=0p6Rz+o6E_c8ni# zn-hp|>6bnNJ_5HQ!1nItq@D~Doj6nX@9@nl@u_ubtD_@nSV^?e<-v6B^tsPli|f@p z){l+cI2#a-Uq)9V5}P?sl4FK$I}HsNK`1MqF>@B3MJwpT z(Ge>jbrdISw<(!DOp95Tkt{qb$v$1nC*q1Z@+G;R=&;3nyT&k zMtKDlshE&!$H$wRn(IQ%P3sTVg~m5DHQ@8w^#>1%bY6JP1G^KWM%uIvv##R=<4r_l zHrKD0NARh{$fjZ&96H@~n^tzNosYk4U19u}3gZ{=s*q*}V!eI+(m-5KS!Pr}pe5u= z8$sBPYEMSX;o$pImXS@Hc0#U7DMl)5D2~=@7_2ecD(zIpGK?O})*an42jY&l&nW~d zs)`TVR>o;}gC%4+YiqkTjHTza4vdJQ=CZeSkFhXzpO&#vh9eCe2=T<6nng>OuU^x< zVN=`Iu7@To<*K<-wKTs!r`vkc(0cQ_>WmC1c1kl<-5egoFJU_RkgjFKDyS1Dt2aP;!5IjVkR4>Z57#qd3;I56*S}Lnzuc0J0gPYb%EmYni_UHHrxv^T>NX0mw zb)~V>Hn(jFv{Ly?`UrdRPQ`Y*$27Chr7eL@N(b!`C8KrcF)0fk+bMNFAljKrr>Z+v z#vS#JC4s;I3)QNsn(7TY&=c5At;?z8X)GJ4Ky6_mcDRgHU9=-E(me46srrW zC)tv_n5-ZzxVXp25EAeZd6pa{C&?-D5jjIHk{`%V~$SSZvBYlIe|Rp=7Bg&y8_p+LUD z;xP#d>ZQnM=e%h}I8mBb!3Vc(?~-;-ds=-vhY{)S>Ur~PLX2H4n_91@A9%muVky{*q|o-=Ow$5=91Aar1i^v->d^1qX7N;rlVipMWRf zDR>&5ffwLKc*)K4V{jZ^gV*5%ya{i?+wdWrf{)=7_!K^auVE6thb!>oP5Hd5IG^Ea z>3p8L7+<_{;p`c{7?;TWv~^=yzH`f|3v}o!cN#AdFBi?2hGh<8zX}{I?y|4>2>1y2 z2>1y22>1w0YXr)8??UYSzw`G0|4-{N_?`0+@DccD2tav9w4)7U-0l}WJ8KW&{V3k- zV(lilbX~AuO_<$1jz@(Z$FK5i-jR@7AMtDxT)OV)=enchr}_W+p8@PxvG`cc-~SiR MtNi`{|6>3DH>r2;BLDyZ delta 301 zcmZn(XfcprU|?W$DortDU=RQ@Ie-{Mvv5sJ6q~50$jG-bU^g=(-(((v>UvfNJ%&t% z6oyoW#GG`);N<+=0-#bLs5%2AkYsc7U0jlK@{@p~9C;7d-=8t(s3W?H6ap#=GLUW9 z0MtI2Q9@+$ECFuDos*Xd6lzFTR~s4_80aXN8CurrC{$Y-0of+TX0^4P9HPql){}&gVTq3Bp`Jnh4#>MO$9D>Y1BY{AG8%Vf } StreamSubscription? _lockRefreshLockDetailInfoDataEvent; + void _initRefreshLockDetailInfoDataEventAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus _lockRefreshLockDetailInfoDataEvent = @@ -224,24 +230,33 @@ class _LockDetailPageState extends State Widget topWidget() { return Column( children: [ - SizedBox(height: 50.h), + F.sw( + defaultCall: () => SizedBox(height: 50.h), + xhjCall: () => Padding( + padding: EdgeInsets.only( + top: 12.h, + left: 15.w, + bottom: 16.h, + right: 15.w, + ), + child: adminInfoView(center: false, add: true), + ), + ), Stack( - alignment: Alignment.center, children: [ - SizedBox( - width: 1.sw - 120.w * 2, - child: Center( - child: Text( - state.lockAlias.value, - style: TextStyle( - fontSize: 22.sp, - fontWeight: FontWeight.w400, - color: state.isOpenPassageMode.value == 1 - ? AppColors.openPassageModeColor - : AppColors.darkGrayTextColor), - ))), + Center( + child: Text( + state.lockAlias.value, + style: TextStyle( + fontSize: 22.sp, + fontWeight: FontWeight.w400, + color: state.isOpenPassageMode.value == 1 + ? AppColors.openPassageModeColor + : AppColors.darkGrayTextColor), + )), Positioned( child: Column( + mainAxisSize: MainAxisSize.min, children: [ GestureDetector( onTap: () { @@ -252,20 +267,24 @@ class _LockDetailPageState extends State child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - Image.asset( - showElectricIcon(state.electricQuantity.value), - width: 30.w, - height: 24.w), + FlavorsImg( + 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)), SizedBox(width: 2.w), - Icon( - Icons.info, // 使用内置的 warning 图标,它是一个叹号 - color: AppColors.mainColor, // 设置图标颜色为红色 - size: 25.w, // 设置图标大小为 30 + FlavorsImg( + child: Icon( + Icons.info, // 使用内置的 warning 图标,它是一个叹号 + color: AppColors.mainColor, // 设置图标颜色为红色 + size: 25.w, // 设置图标大小为 30 + ), ), SizedBox(width: 20.w), ], @@ -274,18 +293,24 @@ class _LockDetailPageState extends State Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - Image.asset(showElectricIcon(state.electricQuantity.value), - width: 30.w, height: 24.w), + FlavorsImg( + child: Image.asset( + showElectricIcon(state.electricQuantity.value), + width: 30.w, + height: 24.w), + ), SizedBox(width: 2.w), Text("--%", style: TextStyle( fontSize: 18.sp, color: AppColors.darkGrayTextColor)), SizedBox(width: 2.w), - Icon( - Icons.info, // 使用内置的 warning 图标,它是一个叹号 - color: AppColors.mainColor, // 设置图标颜色为红色 - size: 25.w, // 设置图标大小为 30 + FlavorsImg( + child: Icon( + Icons.info, // 使用内置的 warning 图标,它是一个叹号 + color: AppColors.mainColor, // 设置图标颜色为红色 + size: 25.w, // 设置图标大小为 30 + ), ), SizedBox(width: 20.w), ], @@ -294,7 +319,10 @@ class _LockDetailPageState extends State )) ], ), - SizedBox(height: 30.h), + F.sw( + defaultCall: () => SizedBox(height: 30.h), + xhjCall: () => SizedBox(height: 15.h), + ), Container( // width: 1.sw, color: Colors.white, @@ -317,37 +345,43 @@ class _LockDetailPageState extends State setState(() { startUnLock(); }); - // startUnLock(); } : null, child: Stack( children: [ - Image.asset( - 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'), - width: 330.w, - height: 330.w, + FlavorsImg( + child: Image.asset( + 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'), + width: 330.w, + height: 330.w, + // color: AppColors.primaryTopColor, + ), ), state.openDoorBtnisUneable.value == false ? Positioned( - child: Image.asset( - 'images/main/icon_main_openLockBtn_grey.png', - width: 330.w, - height: 330.w, + child: FlavorsImg( + child: Image.asset( + 'images/main/icon_main_openLockBtn_grey.png', + width: 330.w, + height: 330.w, + ), ), ) : state.openLockBtnState.value == 1 ? buildRotationTransition() : Positioned( + child: FlavorsImg( child: Image.asset( - state.isOpenPassageMode.value == 1 - ? 'images/main/icon_main_normallyOpenMode_circle.png' - : 'images/main/icon_main_openLockBtn_circle.png', - width: 330.w, - height: 330.w, + state.isOpenPassageMode.value == 1 + ? 'images/main/icon_main_normallyOpenMode_circle.png' + : 'images/main/icon_main_openLockBtn_circle.png', + width: 330.w, + height: 330.w, + ), )), ], ), @@ -358,21 +392,6 @@ class _LockDetailPageState extends State SizedBox( height: 30.h, ), - // Row( - // mainAxisAlignment: MainAxisAlignment.center, - // children: [ - // Text( - // '门已上锁', - // style: TextStyle( - // fontSize: 26.sp, - // color: Colors.black, - // fontWeight: FontWeight.w500), - // ), - // ], - // ), - // SizedBox( - // height: 6.h, - // ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -388,47 +407,7 @@ class _LockDetailPageState extends State SizedBox( height: 30.h, ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - 'images/icon_electronicKey_admin.png', - width: 24.w, - height: 20.w, - color: AppColors.blackColor, //应根据状态显示(当前角色为超级管理员 应显示蓝色图标) - ), - SizedBox(width: 6.w), - Text( - state.keyInfos.value.isLockOwner == 1 - ? TranslationLoader.lanKeys!.superAdmin!.tr - : (state.keyInfos.value.keyRight == 1 - ? TranslationLoader.lanKeys!.authorizedAdmin!.tr - : TranslationLoader.lanKeys!.normalUser!.tr), - style: TextStyle( - fontSize: 20.sp, color: AppColors.darkGrayTextColor), - ), - SizedBox(width: 80.w), - Image.asset( - state.keyInfos.value.remoteEnable == 1 - ? 'images/main/icon_main_remoteUnlocking.png' - : 'images/main/icon_main_remoteUnlocking_grey.png', - width: 24.w, - height: 20.w, - // color: state.keyInfos.value.remoteEnable == 1 - // ? AppColors.btnDisableColor - // : AppColors.mainColor, - ), - SizedBox(width: 6.w), - Text( - TranslationLoader.lanKeys!.gatewayDevice!.tr, - style: TextStyle( - fontSize: 20.sp, - color: state.keyInfos.value.remoteEnable == 1 - ? AppColors.mainColor - : AppColors.btnDisableColor), - ), - ], - ), + F.sw(defaultCall: () => adminInfoView(), xhjCall: () => SizedBox()), SizedBox( height: 20.h, ), @@ -442,6 +421,77 @@ class _LockDetailPageState extends State ); } + Widget adminInfoView({bool center = true, bool add = false}) { + return Row( + mainAxisAlignment: + center ? MainAxisAlignment.center : MainAxisAlignment.start, + children: [ + Image.asset( + 'images/icon_electronicKey_admin.png', + width: 24.w, + height: 20.w, + color: AppColors.blackColor, //应根据状态显示(当前角色为超级管理员 应显示蓝色图标) + ), + SizedBox(width: 6.w), + Text( + state.keyInfos.value.isLockOwner == 1 + ? TranslationLoader.lanKeys!.superAdmin!.tr + : (state.keyInfos.value.keyRight == 1 + ? TranslationLoader.lanKeys!.authorizedAdmin!.tr + : TranslationLoader.lanKeys!.normalUser!.tr), + style: TextStyle(fontSize: 20.sp, color: AppColors.darkGrayTextColor), + ), + if (add) SizedBox(width: 20.w) else SizedBox(width: 80.w), + FlavorsImg( + child: Image.asset( + state.keyInfos.value.remoteEnable == 1 + ? 'images/main/icon_main_remoteUnlocking.png' + : 'images/main/icon_main_remoteUnlocking_grey.png', + width: 24.w, + height: 20.w, + ), + ), + SizedBox(width: 6.w), + Text( + TranslationLoader.lanKeys!.gatewayDevice!.tr, + style: TextStyle( + fontSize: 20.sp, + color: state.keyInfos.value.remoteEnable == 1 + ? AppColors.mainColor + : AppColors.btnDisableColor), + ), + if (add) ...[ + const Spacer(), + GestureDetector( + onTap: () { + Get.toNamed(Routers.selectLockTypePage); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + FlavorsImg( + child: Image.asset( + 'images/mine/icon_mine_main_addLock.png', + width: 24.w, + height: 20.w, + ), + ), + Text( + TranslationLoader.lanKeys!.addDevice!.tr, + style: TextStyle( + fontSize: 20.sp, color: AppColors.darkGrayTextColor), + ) + ], + ), + ), + ), + ] + ], + ); + } + //旋转动画 Widget buildRotationTransition() { return Positioned( @@ -451,12 +501,14 @@ class _LockDetailPageState extends State //动画控制器 turns: state.animationController!, //将要执行动画的子view - child: Image.asset( - state.isOpenPassageMode.value == 1 - ? 'images/main/icon_main_normallyOpenMode_circle.png' - : 'images/main/icon_main_openLockBtn_circle.png', - width: 330.w, - height: 330.w, + child: FlavorsImg( + child: Image.asset( + state.isOpenPassageMode.value == 1 + ? 'images/main/icon_main_normallyOpenMode_circle.png' + : 'images/main/icon_main_openLockBtn_circle.png', + width: 330.w, + height: 330.w, + ), ), ), ); @@ -487,7 +539,7 @@ class _LockDetailPageState extends State return SizedBox( width: ScreenUtil().screenWidth - 20.w, child: GridView.count( - crossAxisCount: 4, + crossAxisCount: F.sw(defaultCall: () => 4, xhjCall: () => 3), // childAspectRatio: 3, crossAxisSpacing: 20.w, mainAxisSpacing: 0.h, @@ -532,12 +584,14 @@ class _LockDetailPageState extends State return SizedBox( width: ScreenUtil().screenWidth - 20.w, child: GridView.count( - crossAxisCount: 4, + crossAxisCount: F.sw(defaultCall: () => 4, xhjCall: () => 3), // childAspectRatio: 3, crossAxisSpacing: 25.h, mainAxisSpacing: 0.h, physics: const NeverScrollableScrollPhysics(), - children: getBottomWidget()), + children: F.sw( + defaultCall: () => getBottomWidget(), + xhjCall: () => getBottomWidget().reversed.toList())), ); } @@ -554,7 +608,7 @@ class _LockDetailPageState extends State // 普通用户 List getNormalWidget() { - var showWidgetArr = []; + List showWidgetArr = []; // 考勤 if (state.isAttendance.value == 1) { showWidgetArr.add(bottomItem( @@ -630,9 +684,6 @@ class _LockDetailPageState extends State TranslationLoader.lanKeys!.card!.tr, state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { - // logic.showToast("普通用户第一次需要在锁旁边操作哦。", something: () { - // logic.showEasyLoading(); - // }); Get.toNamed(Routers.cardListPage, arguments: { "lockId": state.keyInfos.value.lockId, }); @@ -727,10 +778,6 @@ class _LockDetailPageState extends State arguments: {"keyInfo": state.keyInfos.value}); })); } - // bottomItem('images/main/icon_main_authorizedAdmin.png', TranslationLoader.lanKeys!.authorizedAdmin!.tr, state.bottomBtnisUneable.value, () { - // Get.toNamed(Routers.authorizedAdminListPage, - // arguments: {"keyInfo": state.keyInfos.value}); - // }) var endWiddget = []; endWiddget.add( @@ -788,8 +835,8 @@ class _LockDetailPageState extends State // Widget bottomItem(String iconUrl, String name, bool openDoorBtnisUneable, bool bottomBtnisEable, Function() onClick) { - var width = 42.w; - var height = 42.h; + var width = F.sw(defaultCall: () => 42.w, xhjCall: () => 63.w); + var height = F.sw(defaultCall: () => 42.h, xhjCall: () => 63.h); return GestureDetector( onTap: openDoorBtnisUneable ? (bottomBtnisEable @@ -807,16 +854,16 @@ class _LockDetailPageState extends State SizedBox( width: width, height: height, - child: Image.asset( - iconUrl, - width: width, - height: height, - color: openDoorBtnisUneable - ? (bottomBtnisEable - ? AppColors.mainColor - : AppColors.lockDetailBottomBtnUneable) - : AppColors.lockDetailBottomBtnUneable, - // fit: BoxFit.fitWidth + child: FlavorsImg( + child: Image.asset(iconUrl, + width: width, + height: height, + color: openDoorBtnisUneable + ? (bottomBtnisEable + ? AppColors.mainColor + : AppColors.lockDetailBottomBtnUneable) + : AppColors.lockDetailBottomBtnUneable, + fit: BoxFit.fitWidth), ), ), SizedBox(height: 10.w), @@ -933,25 +980,6 @@ class _LockDetailPageState extends State return formattedTime; } - // void showDeletAlertDialog(BuildContext context, String dateStr) { - // showCupertinoDialog( - // context: context, - // builder: (context) { - // return CupertinoAlertDialog( - // content: Text('锁更新时间:$dateStr'), - // actions: [ - // CupertinoDialogAction( - // child: Text(TranslationLoader.lanKeys!.sure!.tr), - // onPressed: () { - // Get.back(); - // }, - // ), - // ], - // ); - // }, - // ); - // } - startOpenLock() { if (state.openLockBtnState.value == 1) { return; @@ -996,15 +1024,6 @@ class _LockDetailPageState extends State } } - // @override - // void didChangeDependencies() { - // // TODO: implement didChangeDependencies - // super.didChangeDependencies(); - // - // /// 路由订阅 - // AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); - // } - @override void dispose() { // TODO: implement dispose @@ -1043,12 +1062,6 @@ class _LockDetailPageState extends State BlueManage().stopScan(); BlueManage().disconnect(); state.openLockBtnState.value = 0; - - // if(state.animationController != null){ - // state.animationController.reset(); - // state.animationController.forward(); - // state.animationController.dispose(); - // } } /// 从下级返回 当前界面即将出现 @@ -1068,9 +1081,5 @@ class _LockDetailPageState extends State logic.cancelBlueConnetctToastTimer(); BlueManage().stopScan(); state.openLockBtnState.value = 0; - - // if (state.animationController!.isAnimating) { - // state.animationController!.stop(); - // } } } diff --git a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart index c7d7190d..0e050f5f 100644 --- a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart @@ -79,7 +79,7 @@ class _StarLockMainXHJPageState extends State ), ), bottomNavigationBar: Container( - height: 100.h + Get.bottomBarHeight, + padding: EdgeInsets.only(top: 20.h), decoration: const BoxDecoration( color: Colors.transparent, border: Border( @@ -89,28 +89,32 @@ class _StarLockMainXHJPageState extends State ), ), ), - child: Row( - children: [ - // navigationBarItem(Icons.start, '场景', false, () { - // logic.setIndex(0); - // }), + child: SafeArea( + top: false, + child: Row( + children: [ + // navigationBarItem(Icons.start, '场景', false, () { + // logic.setIndex(0); + // }), - navigationBarItem(Icons.devices, - TranslationLoader.lanKeys!.device!.tr, logic, 0, () { - logic.setIndex(0); - }), - navigationBarItem(Icons.message, - TranslationLoader.lanKeys!.message!.tr, logic, 1, () { - logic.setIndex(1); - }), - navigationBarItem(Icons.shopping_cart, '商城'.tr, logic, 2, () { - logic.setIndex(2); - }), - navigationBarItem(Icons.account_circle, '我的'.tr, logic, 3, - () { - logic.setIndex(3); - }), - ], + navigationBarItem(Icons.devices, + TranslationLoader.lanKeys!.device!.tr, logic, 0, () { + logic.setIndex(0); + }), + navigationBarItem(Icons.message, + TranslationLoader.lanKeys!.message!.tr, logic, 1, () { + logic.setIndex(1); + }), + navigationBarItem(Icons.shopping_cart, '商城'.tr, logic, 2, + () { + logic.setIndex(2); + }), + navigationBarItem(Icons.account_circle, '我的'.tr, logic, 3, + () { + logic.setIndex(3); + }), + ], + ), ), ), ); diff --git a/star_lock/lib/main_xhj.dart b/star_lock/lib/main_xhj_full.dart similarity index 100% rename from star_lock/lib/main_xhj.dart rename to star_lock/lib/main_xhj_full.dart diff --git a/star_lock/lib/main_xhj_lite.dart b/star_lock/lib/main_xhj_lite.dart new file mode 100644 index 00000000..7546bbe0 --- /dev/null +++ b/star_lock/lib/main_xhj_lite.dart @@ -0,0 +1,9 @@ +import 'flavors.dart'; + +import 'main.dart' as runner; + +Future main() async { + F.appFlavor = Flavor.xhj; + F.isLite = true; + await runner.main(); +} diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart index 7942bf90..61b95e05 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart @@ -161,6 +161,16 @@ class _MinePersonInfoPageState extends State { Get.toNamed(Routers.valueAddedServicesPage); }, ), + if (widget.showAbout) + CommonItem( + leftTitel: TranslationLoader.lanKeys!.set!.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.back(); + Get.toNamed(Routers.mineSetPage); + }, + ), if (widget.showAbout) CommonItem( leftTitel: TranslationLoader.lanKeys!.about!.tr, diff --git a/star_lock/lib/tools/pay/wx_pay_tool.dart b/star_lock/lib/tools/pay/wx_pay_tool.dart index fe40b1b3..d5231c51 100644 --- a/star_lock/lib/tools/pay/wx_pay_tool.dart +++ b/star_lock/lib/tools/pay/wx_pay_tool.dart @@ -15,7 +15,7 @@ class WxPayTool { static Future pay(Payment payment, WeChatResponseSubscriber listener) async { if (!isInit) { isInit = true; - await init(payment.appId, '123'); + await init(payment.appId, 'https://lock.skychip.top/apple-app-site-association.json'); //回调 responseListener(WeChatResponse response) { if (response is WeChatPaymentResponse) { diff --git a/star_lock/lib/widget/flavors_img.dart b/star_lock/lib/widget/flavors_img.dart new file mode 100644 index 00000000..72f2d7bb --- /dev/null +++ b/star_lock/lib/widget/flavors_img.dart @@ -0,0 +1,27 @@ +import 'package:colorfilter_generator/addons.dart'; +import 'package:colorfilter_generator/colorfilter_generator.dart'; +import 'package:flutter/material.dart'; +import 'package:star_lock/flavors.dart'; + +class FlavorsImg extends StatelessWidget { + FlavorsImg({required this.child, key}); + + Widget child; + + ColorFilterGenerator myFilter = ColorFilterGenerator(name: "xhj", filters: [ + // ColorFilterAddons.addictiveColor(1, 22, 93), + ColorFilterAddons.addictiveColor(1, 22, 93), + // ColorFilterAddons.grayscale(),z + ]); + + @override + Widget build(BuildContext context) { + if (F.appFlavor != Flavor.xhj) { + return child; + } + return ColorFiltered( + colorFilter: ColorFilter.matrix(myFilter.matrix), + child: child, + ); + } +} diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index d2f41b92..a01d9c95 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -32,8 +32,10 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.27+2024041101:打包提审 # 1.0.27+2024041102:打包预发布环境给田总测试 # 1.0.28+2024041702:打包给欧阳回归测试 +# 1.0.27+2024041702 打包星星锁提审华为 +# 1.0.27+2024041703 打包星星锁提审ios -version: 1.0.28+2024041702 +version: 1.0.27+2024041803 environment: sdk: '>=2.12.0 <3.0.0' @@ -161,6 +163,7 @@ dependencies: fluwx: ^4.5.5 system_settings: ^2.0.0 expandable: ^5.0.1 + colorfilter_generator: ^0.0.8 dev_dependencies: From 86cd2a760a650304dadcff394984eba2d31e5913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 18 Apr 2024 16:30:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=89=E6=8B=A9=E5=9B=BD=E5=AE=B6=E5=9C=B0?= =?UTF-8?q?=E5=8C=BA=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/login/login/starLock_login_page.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/star_lock/lib/login/login/starLock_login_page.dart b/star_lock/lib/login/login/starLock_login_page.dart index 7813f22e..f8668ce0 100644 --- a/star_lock/lib/login/login/starLock_login_page.dart +++ b/star_lock/lib/login/login/starLock_login_page.dart @@ -62,7 +62,7 @@ class _StarLockLoginPageState extends State { child: Image.asset('images/icon_main_1024.png', width: 110.w, height: 110.w))), SizedBox(height: 50.w), - CommonItem( + Obx(() => CommonItem( leftTitel: "${"你所在的".tr}${TranslationLoader.lanKeys!.countryAndRegion!.tr}", rightTitle: "", isHaveLine: true, @@ -83,7 +83,7 @@ class _StarLockLoginPageState extends State { state.countryName.value = result['countryName']; } }, - ), + )), LoginInput( controller: state.emailOrPhoneController, onchangeAction: (v) { From ed4ab94246df6808b268fa64b5ba5ccf37a78dd5 Mon Sep 17 00:00:00 2001 From: ante <448468458@qq.com> Date: Thu, 18 Apr 2024 17:41:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=E5=B0=86=E4=B8=80=E4=BA=9B=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=9B=BF=E6=8D=A2=E6=88=90=E6=96=B0=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=A1=86=EF=BC=8C=E5=88=A0=E9=99=A4=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_en.json | 4 +- star_lock/images/lan/lan_keys.json | 6 +- star_lock/images/lan/lan_zh.json | 5 +- star_lock/lib/app.dart | 35 --- .../lockDetail/lockDetail_logic.dart | 291 +----------------- .../mine/addLock/addLock/addLock_logic.dart | 25 +- .../mine/addLock/addLock/addLock_page.dart | 180 ++++------- .../gaode/lockAddressGaoDe_page.dart | 279 ++++++----------- .../lib/permission/permission_dialog.dart | 62 ++++ 9 files changed, 253 insertions(+), 634 deletions(-) diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index d1ea88b2..2a415d3a 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -724,5 +724,7 @@ "商城":"mall", "我的":"my", "微信公众号推送":"Wechat public account", - "开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置":"To open wechat to receive alarm messages, you need to pay attention to Skye Smart Lock wechat public account first, please save the QR code and use wechat to scan the Settings" + "开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置":"To open wechat to receive alarm messages, you need to pay attention to Skye Smart Lock wechat public account first, please save the QR code and use wechat to scan the Settings", + "蓝牙":"Bluetooth", + "需要访问蓝牙权限才能使用添加钥匙功能的位置信息":"Access to Bluetooth permissions is required to use the location information of the add key function" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 9cc2ce0b..6c9c5263 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -723,5 +723,9 @@ "商城":"mall", "我的":"my", "微信公众号推送":"微信公众号推送", - "开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置":"开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置" + "开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置":"开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置", + "蓝牙":"蓝牙", + "需要访问蓝牙权限才能使用添加钥匙功能的位置信息":"需要访问蓝牙权限才能使用添加钥匙功能的位置信息" + + } diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 0107221a..52ecc6c0 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -725,5 +725,8 @@ "商城":"商城", "我的":"我的", "微信公众号推送":"微信公众号推送", - "开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置":"开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置" + "开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置":"开启微信接收报警消息需要先关注斯凯智能锁微信公众号,请保存二维码并使用微信扫一扫设置", + "蓝牙":"蓝牙", + "需要访问蓝牙权限才能使用添加钥匙功能的位置信息":"需要访问蓝牙权限才能使用添加钥匙功能的位置信息" + } diff --git a/star_lock/lib/app.dart b/star_lock/lib/app.dart index 28167871..ba772731 100644 --- a/star_lock/lib/app.dart +++ b/star_lock/lib/app.dart @@ -116,23 +116,6 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget { } } -void openBlueScan() { - if (Platform.isIOS) { - print("有蓝牙权限开始扫描"); - // startScanAction(); - } else { - getMicrophonePermission().then((value) { - if (value) { - // 有权限 - print("有蓝牙权限开始扫描"); - // startScanAction(); - } else { - //没有权限 - openAppSettings(); //打开app系统设置 - } - }); - } -} Future getLoginStatus() async { final data = await Storage.getString(saveUserLoginData); @@ -141,21 +124,3 @@ Future getLoginStatus() async { } return false; } - -///请求蓝牙权限 -Future getMicrophonePermission() async { - // You can request multiple permissions at once. - Map statuses = await [ - Permission.bluetoothScan, - Permission.bluetoothConnect, - Permission.location, - ].request(); - - //granted 通过,denied 被拒绝,permanentlyDenied 拒绝且不在提示 - if (statuses[Permission.bluetoothScan]!.isGranted && - statuses[Permission.bluetoothConnect]!.isGranted && - statuses[Permission.location]!.isGranted) { - return true; - } - return false; -} diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 586253e5..77e69d85 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -320,13 +320,6 @@ class LockDetailLogic extends BaseGetXController { state.lockUserNo = reply.data[47]; _updateLockUserNo(); - // if (state.isOpenLockNeedOnline.value == 0) { - // openDoorAction(1); - // } else { - // getLockNetToken(); - // } - // eventBus.fire(RefreshLockDetailInfoDataEvent()); - // clickPushBtnAction(); break; case 0x06: //无权限 @@ -438,19 +431,6 @@ class LockDetailLogic extends BaseGetXController { var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); - // print("调用了开锁事件 openDoorTokenPubToken:$getTokenList getPrivateKeyList:$getPrivateKeyList"); - // ListlistData = await IoSenderManage.senderOpenLock( - // keyID: BlueManage().connectDeviceName, - // userID: await Storage.getUid(), - // openMode: openMode, - // openTime: DateTime.now().millisecondsSinceEpoch ~/ 1000, - // onlineToken: state.lockNetToken, - // token: getTokenList, - // needAuthor: 1, - // signKey: signKeyDataList, - // privateKey: getPrivateKeyList, - // ); - Get.log("openMode:${state.openDoorModel}"); BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { if (deviceConnectionState == BluetoothConnectionState.connected) { @@ -478,91 +458,6 @@ class LockDetailLogic extends BaseGetXController { }); } - // 编辑用户事件 - // Future editLockUserAction() async { - // BlueManage().bludSendData(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { - // if (state == DeviceConnectionState.connected){ - // var publicKey = await Storage.getStringList(saveBluePublicKey); - // List publicKeyDataList = changeStringListToIntList(publicKey!); - // - // var privateKey = await Storage.getStringList(saveBluePrivateKey); - // List getPrivateKeyList = changeStringListToIntList(privateKey!); - // - // var token = await Storage.getStringList(saveBlueToken); - // List getTokenList = changeStringListToIntList(token!); - // print("openDoorTokenPubToken:$getTokenList"); - // - // print("publicKey:$publicKey publicKeyDataList:$publicKeyDataList privateKey:$privateKey getPrivateKeyList:$getPrivateKeyList token:$token getTokenList:$getTokenList"); - // IoSenderManage.senderEditUser( - // lockID:BlueManage().connectDeviceName, - // authUserID:await Storage.getUid(), - // keyID:"1", - // userID:await Storage.getUid(), - // openMode:1, - // keyType:1, - // startDate:0x11223344, - // expireDate:0x11223344, - // role:255, - // password:"123456", - // needAuthor:1, - // publicKey:publicKeyDataList, - // privateKey:getPrivateKeyList, - // token: getTokenList - // ); - // } - // }); - // } - - // 备用逻辑,进入管理钥匙界面获取锁状态 - // Future _connectBlue(String bluetoothDeviceName) async { - // // 进来之后首先连接 - // BlueManage().connect(bluetoothDeviceName, (DeviceConnectionState state) async { - // if(EasyLoading.isShow){ - // EasyLoading.dismiss(); - // } - // if (state == DeviceConnectionState.connected){ - // // var privateKey = await Storage.getStringList(saveBluePrivateKey); - // // List getPrivateKeyList = changeStringListToIntList(privateKey!); - // // // IoSenderManage.senderGetLockStatu( - // // // lockID:BlueManage().connectDeviceName, - // // // userID:await Storage.getUid(), - // // // privateKey:getPrivateKeyList, - // // // ); - // // IoSenderManage.senderGetStarLockStatuInfo( - // // lockID:BlueManage().connectDeviceName, - // // userID:await Storage.getUid(), - // // privateKey:getPrivateKeyList, - // // ); - // } - // }, isShowLoading: false); - // } - - // 获取锁状态 更新电量 - // Future getStarLockStatus() async { - // showEasyLoading(); - // showBlueConnetctToastTimer(action: () { - // dismissEasyLoading(); - // }); - // BlueManage().bludSendData(BlueManage().connectDeviceName, - // (DeviceConnectionState deviceConnectionState) async { - // if (deviceConnectionState == DeviceConnectionState.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 == DeviceConnectionState.disconnected) { - // dismissEasyLoading(); - // cancelBlueConnetctToastTimer(); - // if (state.ifCurrentScreen.value == true) { - // showBlueConnetctToast(); - // } - // } - // }); - // } // 查询事件记录(时间查询) Future senderReferEventRecordTime(int time) async { @@ -593,45 +488,6 @@ class LockDetailLogic extends BaseGetXController { }); } - // // 0开锁 1长按闭锁 2密码 3卡 4指纹 5遥控 6人脸 7监控 8操作记录 9消息提醒 10设置 - // clickItemBtnAction(int type){ - // state.clickNextType = type; - // if (state.lockUserNo == 0) { - // // 电子钥匙lockUserNo为0 要先添加用户 - // addUserConnectBlue(); - // } else { - // clickPushBtnAction(); - // } - // } - // - // clickPushBtnAction(){ - // // 0开锁 1长按闭锁 2密码 3卡 4指纹 5遥控 6人脸 7监控 8操作记录 9消息提醒 10设置 - // switch(state.clickNextType){ - // case 0: - // // 开锁 - // startOpenLock(); - // break; - // case 1: - // // 长按闭锁 - // startUnLock(); - // break; - // case 2: - // // 密码 - // Get.toNamed(Routers.passwordKeyListPage, arguments: {"keyInfo": state.keyInfos.value}); - // break; - // case 3: - // // 卡 - // Get.toNamed(Routers.passwordKeyListPage, arguments: {"keyInfo": state.keyInfos.value}); - // break; - // case 10: - // // 设置 - // Get.toNamed(Routers.lockSetPage, arguments: { - // "lockId": state.keyInfos.value.lockId, - // "isOnlyOneData": state.isOnlyOneData, - // }); - // break; - // } - // } // 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口 void getLockNetToken() async { @@ -706,17 +562,6 @@ class LockDetailLogic extends BaseGetXController { } } - //电量更新请求 - // Future uploadElectricQuantityRequest(String electricQuantity) async { - // KeyOperationRecordEntity entity = await ApiRepository.to - // .uploadElectricQuantity( - // electricQuantity, state.keyInfos.value.lockId.toString()); - // if (entity.errorCode!.codeIsSuccessful) { - // showToast("电量更新成功", something: () { - // eventBus.fire(RefreshLockListInfoDataEvent()); - // }); - // } - // } /// 锁设置里面开启关闭考勤刷新锁详情 void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() { @@ -773,81 +618,6 @@ class LockDetailLogic extends BaseGetXController { return text; } - // late StreamSubscription> - // _scanListDiscoveredDeviceSubscription; - // void _scanListDiscoveredDeviceSubscriptionAction() { - // _scanListDiscoveredDeviceSubscription = EventBusManager().eventBus!.on>().listen((List list) { - // final knownDeviceIndex = list.indexWhere((d) => d.name == state.keyInfos.value.bluetooth!.bluetoothDeviceName!); - // if (knownDeviceIndex >= 0) { - // // 存在的时候赋值 - // state.currentDeviceUUid.value = (list[knownDeviceIndex].serviceUuids.isNotEmpty ? list[knownDeviceIndex].serviceUuids[0] : "").toString(); - // } - // }); - // } - - //开锁成功弹出的小界面 - // void _showFullScreenOverlay(BuildContext context) { - // Future.delayed(const Duration(seconds: 3), () { - // if (state.iSClosedUnlockSuccessfulPopup.value != true) { - // state.iSClosedUnlockSuccessfulPopup.value = true; - // Get.back(); - // } - // }); - // showModalBottomSheet( - // context: context, - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // builder: (BuildContext context) { - // return GestureDetector( - // onTap: () { - // if (state.iSClosedUnlockSuccessfulPopup.value != true) { - // state.iSClosedUnlockSuccessfulPopup.value = true; - // Get.back(); - // } - // }, - // child: Container( - // height: MediaQuery.of(context).size.height, - // width: MediaQuery.of(context).size.width, - // color: Colors.black.withOpacity(0.2), - // child: _unlockSuccessWidget(), - // ), - // ); - // }, - // ); - // } - - // Widget _unlockSuccessWidget() { - // return Stack( - // alignment: Alignment.center, - // children: [ - // Image.asset( - // 'images/main/unlocked_bg.png', - // width: 358.w, - // height: 348.h, - // ), - // Positioned( - // top: ScreenUtil().screenHeight / 2, - // child: Column( - // children: [ - // Text( - // state.keyInfos.value.lockAlias!, - // style: TextStyle( - // color: AppColors.placeholderTextColor, fontSize: 24.sp), - // ), - // SizedBox( - // height: 10.h, - // ), - // Text( - // getCurrentFormattedTime(), - // style: TextStyle( - // color: AppColors.darkGrayTextColor, fontSize: 24.sp), - // ) - // ], - // )) - // ], - // ); - // } - String getCurrentFormattedTime() { // 获取当前时间 DateTime now = DateTime.now(); @@ -856,82 +626,23 @@ class LockDetailLogic extends BaseGetXController { return formattedTime; } - Future positionPermissionAlert() async { - //安卓平台下首次进入应用需向用户告知获取权限用途弹窗 - if (Platform.isAndroid) { - AppFirstEnterHandle().getAppFirstEnter(state.widgetContext, isAgreePosition); - var getFlag = await Storage.getString(isAgreePosition); - if (getFlag == isAgreePosition) { - openBlueSet(); - } - } else { - openBlueSet(); - } - } - - openBlueSet() { - if (!Platform.isIOS) { - getMicrophonePermission().then((value) { - if (!value) { - //没有权限 打开app系统设置 - openAppSettings(); - } else { - // 有权限 - } - }); - } - } - - ///请求权限 - Future getMicrophonePermission() async { - // You can request multiple permissions at once. - Map statuses = await [ - Permission.bluetoothScan, - Permission.bluetoothConnect, - Permission.location, - ].request(); - - //granted 通过,denied 被拒绝,permanentlyDenied 拒绝且不在提示 - if (statuses[Permission.bluetoothScan]!.isGranted && - statuses[Permission.bluetoothConnect]!.isGranted && - statuses[Permission.location]!.isGranted) { - return true; - } - return false; - } - @override Future onReady() async { - // TODO: implement onReady super.onReady(); - Get.log("LockDetailPage onReady"); - // _initReplySubscription(); - // _initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction(); - - // openBlueSet(); - await PermissionDialog.request(Permission.location); - - // positionPermissionAlert(); + await PermissionDialog.requestBluetooth(); } @override void onInit() { - // TODO: implement onInit super.onInit(); Get.log("LockDetailPage onInit"); - - // 进来获取锁状态 - // connectBlue(); } @override void onClose() { - // TODO: implement onClose super.onClose(); Get.log("LockDetailPage onClose"); - - // _scanListDiscoveredDeviceSubscription.cancel(); } } diff --git a/star_lock/lib/mine/addLock/addLock/addLock_logic.dart b/star_lock/lib/mine/addLock/addLock/addLock_logic.dart index f54c9bf9..fccb00a0 100644 --- a/star_lock/lib/mine/addLock/addLock/addLock_logic.dart +++ b/star_lock/lib/mine/addLock/addLock/addLock_logic.dart @@ -1,22 +1,23 @@ +import 'dart:io'; + +import 'package:get/get.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:star_lock/appRouters.dart'; import 'package:star_lock/mine/addLock/addLock/addLock_state.dart'; +import 'package:star_lock/permission/permission_dialog.dart'; import 'package:star_lock/tools/baseGetXController.dart'; -import '../../../blue/blue_manage.dart'; class AddLockLogic extends BaseGetXController { final AddLockState state = AddLockState(); @override void onReady() { - // TODO: implement onReady super.onReady(); - - // BlueManage().stopScan(); } @override void onInit() { - // TODO: implement onInit super.onInit(); } @@ -24,4 +25,18 @@ class AddLockLogic extends BaseGetXController { void onClose() { // TODO: implement onClose } + + //跳转到附近的锁页面先判断权限 + Future getNearByLimits() async { + if (!Platform.isIOS) { + bool bluetoothRequest = await PermissionDialog.requestBluetooth(); + bool locationRequest = await PermissionDialog.request(Permission.location); + if (!bluetoothRequest || !locationRequest) { + return; + } + } + Get.toNamed(Routers.nearbyLockPage); + } + + } diff --git a/star_lock/lib/mine/addLock/addLock/addLock_page.dart b/star_lock/lib/mine/addLock/addLock/addLock_page.dart index 657816f2..d346f578 100644 --- a/star_lock/lib/mine/addLock/addLock/addLock_page.dart +++ b/star_lock/lib/mine/addLock/addLock/addLock_page.dart @@ -23,125 +23,71 @@ class AddLockPage extends StatefulWidget { } class _AddLockPageState extends State with BaseWidget { - final logic = Get.put(AddLockLogic()); - final state = Get.find().state; - @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Colors.white, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.addLock!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor), - body: ListView( - // mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 100.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - TranslationLoader.lanKeys!.lightTouchScreen!.tr, - style: TextStyle( - fontSize: 24.sp, + return GetBuilder( + init: AddLockLogic(), + builder: (AddLockLogic logic) { + return Scaffold( + backgroundColor: Colors.white, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.addLock!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: ListView( + // mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: 100.h, ), - ), - ], - ), - SizedBox( - height: 120.h, - ), - Obx(() => Image.asset( - state.lockTypeImg.value, - width: 278.w, - height: 278.w, - )), - SizedBox( - height: 120.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, - style: TextStyle(fontSize: 20.sp, fontWeight: FontWeight.w500), - ), - ], - ), - SizedBox( - height: 120.h, - ), - Container( - margin: EdgeInsets.only(left: 20.w, right: 20.w), - child: SubmitBtn( - btnName: TranslationLoader.lanKeys!.next!.tr, - borderRadius: 20.w, - onClick: () { - getNearByLimits(); - }), - ), - ], - ), - ); - } - - void onShow() {} - - void onHide() {} - - //跳转到附近的锁页面先判断权限 - void getNearByLimits() { - if (Platform.isIOS) { - Navigator.pushNamed(context, Routers.nearbyLockPage); - } else { - positionPermissionAlert(); - } - } - - ///请求权限 - Future getMicrophonePermission() async { - // You can request multiple permissions at once. - Map statuses = await [ - Permission.bluetoothScan, - Permission.bluetoothConnect, - Permission.location, - ].request(); - - //granted 通过,denied 被拒绝,permanentlyDenied 拒绝且不在提示 - if (statuses[Permission.bluetoothScan]!.isGranted && - statuses[Permission.bluetoothConnect]!.isGranted && - statuses[Permission.location]!.isGranted) { - return true; - } - return false; - } - - Future positionPermissionAlert() async { - //安卓平台下首次进入应用需向用户告知获取权限用途弹窗 - if (Platform.isAndroid) { - AppFirstEnterHandle().getAppFirstEnter(context, isAgreePosition); - var getFlag = await Storage.getString(isAgreePosition); - if (getFlag == isAgreePosition) { - onPermissionPush(); - } - } else { - onPermissionPush(); - } - } - - void onPermissionPush() { - getMicrophonePermission().then((value) { - if (value) { - // 有权限 - Navigator.pushNamed(context, Routers.nearbyLockPage); - } else { - //没有权限 - openAppSettings(); //打开app系统设置 - } - }); + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + TranslationLoader.lanKeys!.lightTouchScreen!.tr, + style: TextStyle( + fontSize: 24.sp, + ), + ), + ], + ), + SizedBox( + height: 120.h, + ), + Obx(() => Image.asset( + logic.state.lockTypeImg.value, + width: 278.w, + height: 278.w, + )), + SizedBox( + height: 120.h, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + TranslationLoader.lanKeys!.lightTouchScreenTip!.tr, + style: TextStyle( + fontSize: 20.sp, fontWeight: FontWeight.w500), + ), + ], + ), + SizedBox( + height: 120.h, + ), + Container( + margin: EdgeInsets.only(left: 20.w, right: 20.w), + child: SubmitBtn( + btnName: TranslationLoader.lanKeys!.next!.tr, + borderRadius: 20.w, + onClick: () { + logic.getNearByLimits(); + }), + ), + ], + ), + ); + }); } } diff --git a/star_lock/lib/mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart b/star_lock/lib/mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart index 53374cd5..62596772 100644 --- a/star_lock/lib/mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart +++ b/star_lock/lib/mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'dart:io'; @@ -11,6 +10,7 @@ import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:amap_flutter_map/amap_flutter_map.dart'; import 'package:amap_flutter_base/amap_flutter_base.dart'; +import 'package:star_lock/permission/permission_dialog.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -28,12 +28,14 @@ class LockAddressGaoDePage extends StatefulWidget { State createState() => _LockAddressGaoDePageState(); } -class _LockAddressGaoDePageState extends State with RouteAware{ +class _LockAddressGaoDePageState extends State + with RouteAware { final logic = Get.put(LockAddressGaoDeLogic()); final state = Get.find().state; // 高德地图 - static AMapApiKey amapApiKeys = AMapApiKey(iosKey: F.aMapKey.iosKey, androidKey: F.aMapKey.androidKey); + static AMapApiKey amapApiKeys = + AMapApiKey(iosKey: F.aMapKey.iosKey, androidKey: F.aMapKey.androidKey); AMapController? mapController; AMapFlutterLocation location = AMapFlutterLocation(); @@ -44,72 +46,29 @@ class _LockAddressGaoDePageState extends State with RouteA @override void initState() { super.initState(); - AMapFlutterLocation.updatePrivacyAgree(true); AMapFlutterLocation.updatePrivacyShow(true, true); - requestPermission(); - AMapFlutterLocation.setApiKey(F.aMapKey.androidKey, F.aMapKey.iosKey); - - // EasyLoading.show(); - // Future.delayed(const Duration(seconds: 10), () { //asynchronous delay - // print("10s之后 菊花没有隐藏的话,强制隐藏菊花"); - // if(EasyLoading.isShow){ - // EasyLoading.dismiss(); - // } - // }); - // requestLocation(); } Future requestPermission() async { - final status = await Permission.location.request(); - print("Permission.location.request()=status:$status"); - permissionStatus = status; - if(Platform.isIOS){ + final status = await PermissionDialog.request(Permission.location); + if (Platform.isIOS || status) { _setLocationOption(); requestIOSLocation(); } - switch (status) { - case PermissionStatus.denied: - // print("拒绝"); - break; - case PermissionStatus.granted: - if(Platform.isIOS){ - // _setLocationOption(); - // requestIOSLocation(); - }else{ - requestAndroidLocation(); - location.startLocation(); - } - break; - case PermissionStatus.limited: - // print("限制"); - break; - case PermissionStatus.permanentlyDenied: - // print("永久的否认"); - break; - case PermissionStatus.provisional: - // print("临时"); - break; - default: - // print("其他状态"); - // requestLocation(); - break; - } } Future requestAndroidLocation() async { location.onLocationChanged().listen((event) { - // print("listenLocationChanged$event"); - // EasyLoading.dismiss(); - if (event.isNotEmpty) { - setState(() { - addressInfo = event; - }); - location.stopLocation(); - } - }); + if (event.isNotEmpty) { + setState(() { + addressInfo = event; + }); + location.stopLocation(); + } + }); } Future requestIOSLocation() async { @@ -136,25 +95,6 @@ class _LockAddressGaoDePageState extends State with RouteA barTitle: TranslationLoader.lanKeys!.lockAddress!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - // actionsList: [ - // TextButton( - // child: Text( - // TranslationLoader.lanKeys!.next!.tr, - // style: TextStyle(color: Colors.white, fontSize: 24.sp), - // ), - // onPressed: () { - // if(addressInfo!.isEmpty){ - // Toast.show(msg:"还未获取到位置信息哦,请耐心等待一下!"); - // return; - // } - // Get.toNamed(Routers.saveLockPage, arguments: { - // "addressInfo": addressInfo, - // "pwdTimestamp": state.pwdTimestamp.value, - // }); - // // Navigator.pushNamed(context, Routers.saveLockPage); - // }, - // ), - // ], ), body: ListView( children: [ @@ -168,74 +108,89 @@ class _LockAddressGaoDePageState extends State with RouteA ), ), SizedBox( - child: - (addressInfo != null && addressInfo!.containsKey("latitude")) ? - Column( - children: [ - SizedBox( - height: 1.sw/5*4, - width: 1.sw, - child: AMapWidget( - apiKey: amapApiKeys, - // 初始化地图中心 - initialCameraPosition: ( - CameraPosition( - target: LatLng(double.parse(addressInfo!['latitude'].toString()), double.parse(addressInfo!['longitude'].toString())), - zoom: 10.0, - ) - ), - //定位小蓝点 - myLocationStyleOptions: MyLocationStyleOptions( - true, - ), - // 普通地图normal,卫星地图satellite,夜间视图night,导航视图 navi,公交视图bus, - mapType: MapType.normal, - // 缩放级别范围 - minMaxZoomPreference: const MinMaxZoomPreference(3, 20), - // 隐私政策包含高德 必须填写 - privacyStatement: const AMapPrivacyStatement(hasAgree: true, hasContains: true, hasShow: true), - // 地图创建成功时返回AMapController - onMapCreated: (AMapController controller) { - mapController = controller; - }, - ), - ), - Container( - // color: Colors.red, - margin: EdgeInsets.only(left: 25.w, top: 20.h, right: 25.w), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, + child: (addressInfo != null && addressInfo!.containsKey("latitude")) + ? Column( children: [ - Flexible(child: Text("检查以确保以下地址是正确的".tr, style: TextStyle(fontSize: 24.sp))), - ], - ), - ), - // SizedBox(height: 20.h), - Container( - // color: Colors.red, - // height: 45.h, - margin: EdgeInsets.only(left: 25.w, top: 20.h, right: 25.w), - child:Column( - children: [ - Row( + SizedBox( + height: 1.sw / 5 * 4, + width: 1.sw, + child: AMapWidget( + apiKey: amapApiKeys, + // 初始化地图中心 + initialCameraPosition: (CameraPosition( + target: LatLng( + double.parse( + addressInfo!['latitude'].toString()), + double.parse( + addressInfo!['longitude'].toString())), + zoom: 10.0, + )), + //定位小蓝点 + myLocationStyleOptions: MyLocationStyleOptions( + true, + ), + // 普通地图normal,卫星地图satellite,夜间视图night,导航视图 navi,公交视图bus, + mapType: MapType.normal, + // 缩放级别范围 + minMaxZoomPreference: + const MinMaxZoomPreference(3, 20), + // 隐私政策包含高德 必须填写 + privacyStatement: const AMapPrivacyStatement( + hasAgree: true, hasContains: true, hasShow: true), + // 地图创建成功时返回AMapController + onMapCreated: (AMapController controller) { + mapController = controller; + }, + ), + ), + Container( + // color: Colors.red, + margin: + EdgeInsets.only(left: 25.w, top: 20.h, right: 25.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, children: [ - Expanded( - child: Text(addressInfo!["address"].toString() ?? "", style: const TextStyle(color: Colors.grey, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip)) - ), + Flexible( + child: Text("检查以确保以下地址是正确的".tr, + style: TextStyle(fontSize: 24.sp))), ], ), - SizedBox(height: 5.h), - Container(height: 1.h, color: AppColors.mainColor,), - ], - ) - ), - ], - ) : SizedBox( - height: 1.sw/5*4 + 65.h*2, - child: Center(child: Text('地图加载中,请稍候。。。'.tr))) - , + ), + // SizedBox(height: 20.h), + Container( + // color: Colors.red, + // height: 45.h, + margin: EdgeInsets.only( + left: 25.w, top: 20.h, right: 25.w), + child: Column( + children: [ + Row( + children: [ + Expanded( + child: Text( + addressInfo!["address"].toString() ?? + "", + style: const TextStyle( + color: Colors.grey, + fontSize: 16, + fontWeight: FontWeight.w500, + overflow: TextOverflow.clip))), + ], + ), + SizedBox(height: 5.h), + Container( + height: 1.h, + color: AppColors.mainColor, + ), + ], + )), + ], + ) + : SizedBox( + height: 1.sw / 5 * 4 + 65.h * 2, + child: Center(child: Text('地图加载中,请稍候。。。'.tr))), ), - SizedBox(height:200.h), + SizedBox(height: 200.h), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ @@ -261,7 +216,7 @@ class _LockAddressGaoDePageState extends State with RouteA style: TextStyle(color: Colors.black, fontSize: 24.sp), ), onPressed: () { - if(addressInfo!.isEmpty){ + if (addressInfo!.isEmpty) { logic.showToast("还未获取到位置信息哦,请耐心等待一下!".tr); return; } @@ -279,50 +234,9 @@ class _LockAddressGaoDePageState extends State with RouteA ), ], ) - // Positioned( - // left: 20.w, right: 20.w, bottom: 100.h, - // child: Container( - // // height: h(106), - // decoration: BoxDecoration( - // color: AppColors.mainColor, - // borderRadius: BorderRadius.circular(15.w), - // ), - // child:Column( - // children: [ - // Container( - // // height: h(53), - // padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w), - // child: Row( - // children: [ - // Image.asset('images/main/icon_addUserShowAddress.png', width: 30.w, height: 30.w), - // SizedBox(width: 10.w), - // Expanded( - // child: Text(addressInfo!["address"].toString() ?? "", style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500, overflow: TextOverflow.clip)) - // ), - // ], - // ), - // ), - // // Container(height: 1.h, color: const Color(0xFF021732),), - // // Container( - // // // height: h(52), - // // padding: EdgeInsets.only(top: 15.h, bottom: 15, left:15.w, right: 15.w), - // // child: Row( - // // children: [ - // // Image.asset('images/main/icon_addUserAddressShowTime.png', width: 30.w, height: 30.w), - // // SizedBox(width: 10.w,), - // // Expanded( - // // child: Text(DateTool().getNowDateYMDHM(), style: const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),) - // // ), - // // ], - // // ), - // // ), - // ], - // ) - // ),), ], ), ); - } ///设置定位参数 @@ -338,7 +252,8 @@ class _LockAddressGaoDePageState extends State with RouteA ///逆地理信息的语言类型 locationOption.geoLanguage = GeoLanguage.DEFAULT; - locationOption.desiredLocationAccuracyAuthorizationMode = AMapLocationAccuracyAuthorizationMode.ReduceAccuracy; + locationOption.desiredLocationAccuracyAuthorizationMode = + AMapLocationAccuracyAuthorizationMode.ReduceAccuracy; locationOption.fullAccuracyPurposeKey = "AMapLocationScene"; @@ -396,21 +311,18 @@ class _LockAddressGaoDePageState extends State with RouteA @override void didPush() { super.didPush(); - } /// 返回上一个界面 当前界面即将消失 @override void didPop() { super.didPop(); - } /// 从下级返回 当前界面即将出现 @override void didPopNext() { super.didPopNext(); - } /// 进入下级界面 当前界面即将消失 @@ -421,5 +333,4 @@ class _LockAddressGaoDePageState extends State with RouteA location.stopLocation(); location.destroy(); } - } diff --git a/star_lock/lib/permission/permission_dialog.dart b/star_lock/lib/permission/permission_dialog.dart index 246db99e..891ba9d3 100644 --- a/star_lock/lib/permission/permission_dialog.dart +++ b/star_lock/lib/permission/permission_dialog.dart @@ -12,6 +12,9 @@ class PermissionDialog { Permission.photos: '相册'.tr, Permission.storage: '读写'.tr, Permission.location: '定位'.tr, + Permission.bluetooth: '蓝牙'.tr, + Permission.bluetoothScan: '蓝牙'.tr, + Permission.bluetoothConnect: '蓝牙'.tr, }; static Map contents = { @@ -19,8 +22,67 @@ class PermissionDialog { Permission.photos: '需要访问相机权限才能使用相册图片上传文件上传头像'.tr, Permission.storage: '需要访问读写权限才能使用本地图片上传头像'.tr, Permission.location: '需要访问定位权限才能使用添加钥匙功能的位置信息'.tr, + Permission.bluetooth: '需要访问蓝牙权限才能使用添加钥匙功能的位置信息'.tr, + Permission.bluetoothScan: '需要访问蓝牙权限才能使用添加钥匙功能的位置信息'.tr, + Permission.bluetoothConnect: '需要访问蓝牙权限才能使用添加钥匙功能的位置信息'.tr, }; + static Future requestBluetooth() async { + if (Get.context == null) { + return false; + } + bool application = true; + Map statuses = await [ + Permission.bluetoothScan, + Permission.bluetoothConnect, + ].request(); + Permission permission = Permission.bluetoothScan; + dynamic cache = await Storage.getString(titles[permission]); + bool isGranted = statuses.values.every((element) => element.isGranted); + if (AppPlatform.isAndroid && !isGranted && cache is! String) { + application = await showCupertinoDialog( + context: Get.context!, + builder: (context) { + return PopScope( + canPop: false, + child: CupertinoAlertDialog( + title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'), + content: Text(contents[permission] ?? ''), + actions: [ + CupertinoDialogAction( + child: Text('不允许'.tr), + onPressed: () { + Get.back(result: false); + }, + ), + CupertinoDialogAction( + child: Text('允许'.tr), + onPressed: () { + Get.back(result: true); + }, + ), + ], + )); + }, + ); + + if (application) { + await Storage.setString(titles[permission], titles[permission]); + } + } else if (cache is String) { + bool isDenied = statuses.values.every((element) => element.isDenied); + if (isDenied) { + showSet(permission); + return false; + } + } + if (application) { + PermissionStatus status = await permission.request(); + return status.isGranted; + } + return false; + } + //显示权限判断申请框 static Future request(Permission permission) async { if (Get.context == null) {