diff --git a/lib/appRouters.dart b/lib/appRouters.dart index b7666944..214f0ad1 100755 --- a/lib/appRouters.dart +++ b/lib/appRouters.dart @@ -41,6 +41,7 @@ import 'package:star_lock/main/lockDetail/palm/palmList/palmList_page.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart'; import 'package:star_lock/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart'; import 'package:star_lock/mine/about/webviewShow_page.dart'; +import 'package:star_lock/mine/addLock/lockAddFaq/lockAddFaq_page.dart'; import 'package:star_lock/mine/addLock/lockResetConfirm/lockResetConfirm_page.dart'; import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart'; @@ -516,6 +517,7 @@ abstract class Routers { static const String starChartTalkView = '/starChartTalkView'; //星图对讲页面 static const String h264WebView = '/h264WebView'; //星图对讲页面 static const String lockResetConfirmPage = '/LockResetConfirmPage'; // 重置锁确认页面 + static const String lockAddFaqPage = '/LockAddFaqPage'; } abstract class AppRouters { @@ -1191,5 +1193,9 @@ abstract class AppRouters { name: Routers.lockResetConfirmPage, page: () => const LockResetConfirmPage(), ), + GetPage( + name: Routers.lockAddFaqPage, + page: () => const LockAddFaqPage(), + ), ]; } diff --git a/lib/mine/addLock/lockAddFaq/lockAddFaq_logic.dart b/lib/mine/addLock/lockAddFaq/lockAddFaq_logic.dart new file mode 100644 index 00000000..d401256f --- /dev/null +++ b/lib/mine/addLock/lockAddFaq/lockAddFaq_logic.dart @@ -0,0 +1,23 @@ +import 'dart:io'; +import 'package:get/get.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:star_lock/mine/addLock/nearbyLock/nearbyLock_logic.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/widget/permission/permission_dialog.dart'; + +class LockAddFaqLogic extends BaseGetXController { + // 开始OTA升级 + void startOtaUpgrade() async { + // 检查存储权限 + if (!Platform.isIOS) { + final bool storageRequest = await PermissionDialog.requestStorage(); + if (!storageRequest) { + return; + } + } + + // 创建升级逻辑实例并开始升级 + final NearbyLockLogic upgradeLogic = NearbyLockLogic(); + upgradeLogic.otaUpdate(); + } +} diff --git a/lib/mine/addLock/lockAddFaq/lockAddFaq_page.dart b/lib/mine/addLock/lockAddFaq/lockAddFaq_page.dart new file mode 100644 index 00000000..8146dae2 --- /dev/null +++ b/lib/mine/addLock/lockAddFaq/lockAddFaq_page.dart @@ -0,0 +1,248 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/mine/addLock/lockAddFaq/lockAddFaq_logic.dart'; + +import '../../../app_settings/app_colors.dart'; +import '../../../tools/titleAppBar.dart'; + +class LockAddFaqPage extends StatefulWidget { + const LockAddFaqPage({Key? key}) : super(key: key); + + @override + State createState() => _LockAddFaqPageState(); +} + +class _LockAddFaqPageState extends State { + final LockAddFaqLogic logic = Get.put(LockAddFaqLogic()); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: TitleAppBar( + barTitle: '常见问题'.tr, + haveBack: true, + backgroundColor: AppColors.mainColor, + ), + body: ListView( + padding: EdgeInsets.all(20.w), + children: [ + // 问题1:蓝牙未开启或未授权 + _buildFaqItem( + icon: Icons.bluetooth, + title: '蓝牙未开启或未授权'.tr, + description: '请确保手机蓝牙已开启,并授权App使用蓝牙权限。'.tr, + solution: '检查手机设置中的蓝牙权限,确保已授权给App。'.tr, + ), + + SizedBox(height: 20.h), + + // 问题2:未重置锁 + _buildFaqItem( + icon: Icons.refresh, + title: '未重置锁'.tr, + description: '请先将锁重置为出厂状态,重置方法详见上一步指引。'.tr, + solution: '找到锁上的重置按钮,长按直到听到"滴"声或看到指示灯闪烁。'.tr, + ), + + SizedBox(height: 20.h), + + // 问题3:锁电量过低 + _buildFaqItem( + icon: Icons.battery_alert, + title: '锁电量过低'.tr, + description: '锁电量过低可能导致无法正常连接和添加。'.tr, + solution: '请更换电池后重试。'.tr, + ), + + SizedBox(height: 20.h), + + // 问题4:距离过远 + _buildFaqItem( + icon: Icons.signal_wifi_off, + title: '距离过远'.tr, + description: '请确保手机与锁的距离在有效范围内。'.tr, + solution: '将手机靠近锁,距离保持在1米以内。'.tr, + ), + + SizedBox(height: 20.h), + + // 问题5:锁已被其他用户添加 + _buildFaqItem( + icon: Icons.person_off, + title: '锁已被其他用户添加'.tr, + description: '如果锁已被其他用户添加,需要先解除绑定。'.tr, + solution: '请联系锁的管理员解除绑定,或使用管理员权限重置锁。'.tr, + ), + + SizedBox(height: 30.h), + + // 尝试升级按钮 + Container( + width: double.infinity, + padding: EdgeInsets.symmetric(horizontal: 20.w), + child: ElevatedButton.icon( + onPressed: logic.startOtaUpgrade, + icon: const Icon(Icons.system_update_alt, color: Colors.white), + label: Text( + '尝试升级固件'.tr, + style: TextStyle( + color: Colors.white, + fontSize: 20.sp, + fontWeight: FontWeight.w500, + ), + ), + style: ElevatedButton.styleFrom( + backgroundColor: AppColors.mainColor, + padding: EdgeInsets.symmetric(vertical: 15.h), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(25.w), + ), + elevation: 2, + ), + ), + ), + + SizedBox(height: 20.h), + + // 升级说明 + Container( + padding: EdgeInsets.all(16.w), + decoration: BoxDecoration( + color: Colors.orange[50], + borderRadius: BorderRadius.circular(12.w), + border: Border.all(color: Colors.orange[200]!), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon(Icons.info_outline, + color: Colors.orange[700], size: 20.w), + SizedBox(width: 8.w), + Text( + '升级说明'.tr, + style: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.w600, + color: Colors.orange[700], + ), + ), + ], + ), + SizedBox(height: 8.h), + Text( + '如果以上方法都无法解决问题,可以尝试升级锁的固件。升级前请确保:'.tr, + style: TextStyle( + fontSize: 14.sp, + color: Colors.orange[800], + ), + ), + SizedBox(height: 8.h), + Text( + '• 锁电量充足\n• 已获取正确的固件文件\n• 升级过程中不要断开连接'.tr, + style: TextStyle( + fontSize: 14.sp, + color: Colors.orange[800], + height: 1.4, + ), + ), + ], + ), + ), + ], + ), + ); + } + + Widget _buildFaqItem({ + required IconData icon, + required String title, + required String description, + required String solution, + }) { + return Container( + padding: EdgeInsets.all(16.w), + decoration: BoxDecoration( + color: Colors.grey[50], + borderRadius: BorderRadius.circular(12.w), + border: Border.all(color: Colors.grey[200]!), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: 40.w, + height: 40.w, + decoration: BoxDecoration( + color: AppColors.mainColor.withOpacity(0.1), + borderRadius: BorderRadius.circular(20.w), + ), + child: Icon( + icon, + color: AppColors.mainColor, + size: 26.w, + ), + ), + SizedBox(width: 12.w), + Expanded( + child: Text( + title, + style: TextStyle( + fontSize: 20.sp, + fontWeight: FontWeight.w600, + color: Colors.black87, + ), + ), + ), + ], + ), + SizedBox(height: 12.h), + Text( + description, + style: TextStyle( + fontSize: 16.sp, + color: Colors.black54, + height: 1.4, + ), + ), + SizedBox(height: 8.h), + Container( + padding: EdgeInsets.all(12.w), + decoration: BoxDecoration( + color: AppColors.mainColor.withOpacity(0.05), + borderRadius: BorderRadius.circular(8.w), + border: Border.all(color: AppColors.mainColor.withOpacity(0.2)), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon( + Icons.lightbulb_outline, + color: AppColors.mainColor, + size: 18.w, + ), + SizedBox(width: 8.w), + Expanded( + child: Text( + solution, + style: TextStyle( + fontSize: 14.sp, + color: AppColors.mainColor, + fontWeight: FontWeight.w500, + height: 1.4, + ), + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index 0b0952f5..2aa7ee82 100755 --- a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -337,17 +337,15 @@ class NearbyLockLogic extends BaseGetXController { // 'featureSettingValue': state.featureSettingValue, // 'featureSettingParams': state.featureSettingParams, // }); - Get.toNamed(Routers.saveLockPage, - arguments: { - 'addressInfo': {}, - 'pwdTimestamp': state.timestampValue * 1000, - 'lockInfo': state.lockInfo, - 'featureValue': state.featureValue, - 'featureSettingValue': state.featureSettingValue, - 'featureSettingParams': state.featureSettingParams, - 'isFromMap': 0, - }); - + Get.toNamed(Routers.saveLockPage, arguments: { + 'addressInfo': {}, + 'pwdTimestamp': state.timestampValue * 1000, + 'lockInfo': state.lockInfo, + 'featureValue': state.featureValue, + 'featureSettingValue': state.featureSettingValue, + 'featureSettingParams': state.featureSettingParams, + 'isFromMap': 0, + }); break; case 0x06: @@ -575,12 +573,12 @@ class NearbyLockLogic extends BaseGetXController { void startOTAData() { state.otaUpdateIng.value = true; state.oTAProgressDialog = true; - Get.dialog( - OTAProgressDialog( - logic: this, - ), - barrierDismissible: false) - .then((dynamic value) => state.oTAProgressDialog = false); + // Get.dialog( + // OTAProgressDialog( + // logic: this, + // ), + // barrierDismissible: false) + // .then((dynamic value) => state.oTAProgressDialog = false); } //清楚 ata 安装文件 diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_page.dart b/lib/mine/addLock/nearbyLock/nearbyLock_page.dart index a06d469a..a5e5e0c9 100755 --- a/lib/mine/addLock/nearbyLock/nearbyLock_page.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_page.dart @@ -4,6 +4,7 @@ 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/appRouters.dart'; import 'package:star_lock/flavors.dart'; import 'package:star_lock/mine/addLock/nearbyLock/nearbyLock_state.dart'; import '../../../app_settings/app_colors.dart'; @@ -52,7 +53,49 @@ class _NearbyLockPageState extends State with RouteAware { SizedBox(width: 30.w) ]), ), - body: Obx(listView), + body: Stack( + children: [ + Obx(listView), + Positioned( + left: 16.w, + bottom: 64.h, + child: GestureDetector( + onTap: () { + Get.toNamed(Routers.lockAddFaqPage); + }, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.w), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20.w), + boxShadow: const [ + BoxShadow( + color: Colors.black12, + blurRadius: 8, + offset: Offset(0, 2), + ), + ], + ), + child: Row( + children: [ + Icon(Icons.help_outline, + color: AppColors.mainColor, size: 20.w), + SizedBox(width: 6.w), + Text( + '找不到锁?点此查看。'.tr, + style: TextStyle( + color: AppColors.mainColor, + fontSize: 20.sp, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + ), + ], + ), ); } @@ -81,24 +124,7 @@ class _NearbyLockPageState extends State with RouteAware { }, ), ), - Padding( - padding: EdgeInsets.only(left: 15.w, bottom: 10.h), - child: TextButton( - onPressed: () async { - bool skip = false; - if (!state.otaState.value) { - skip = await Get.dialog( - const _TipDialog(), - ); - } - state.otaState.value = skip; - }, - child: Text( - state.otaState.value ? '点击返回设备配对'.tr : '无法连接?尝试升级'.tr, - style: TextStyle(fontSize: 22.sp), - ), - ), - ), + // 移除了原有的"无法连接?尝试升级"按钮 ], ); } @@ -164,9 +190,7 @@ class _NearbyLockPageState extends State with RouteAware { ), Expanded(child: SizedBox(width: 20.w)), Image.asset( - state.otaState.value - ? 'images/ota_upgrade_icon.png' - : 'images/main/icon_main_addLock.png', + 'images/main/icon_main_addLock.png', width: 36.w, height: 36.w, color: AppColors.mainColor, @@ -205,7 +229,6 @@ class _NearbyLockPageState extends State with RouteAware { @override void didPop() { super.didPop(); - EasyLoading.isShow ? EasyLoading.dismiss() : null; state.ifCurrentScreen.value = false; logic.cancelBlueConnetctToastTimer(); @@ -216,7 +239,6 @@ class _NearbyLockPageState extends State with RouteAware { @override void didPopNext() { super.didPopNext(); - state.ifCurrentScreen.value = true; logic.startScanBlueList(); } @@ -225,97 +247,8 @@ class _NearbyLockPageState extends State with RouteAware { @override void didPushNext() { super.didPushNext(); - if (!logic.state.otaState.value) { - state.ifCurrentScreen.value = false; - logic.cancelBlueConnetctToastTimer(); - logic.stopScanBlueList(); - } - } -} - -class _TipDialog extends StatelessWidget { - const _TipDialog({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return CupertinoAlertDialog( - title: Text( - '固件升级提示'.tr, - ), - content: Text('请先获取固件文件到手机本地,再选择升级'.tr), - actions: [ - TextButton( - onPressed: Get.back, - child: Text( - '取消'.tr, - style: TextStyle(fontSize: 22.sp, color: AppColors.blackColor), - ), - ), - TextButton( - onPressed: () async { - Get.back(result: true); - }, - child: Text( - '确定'.tr, - style: TextStyle(fontSize: 22.sp, color: AppColors.blackColor), - ), - ), - ], - ); - } -} - -class OTAProgressDialog extends StatelessWidget { - NearbyLockLogic logic; - - OTAProgressDialog({required this.logic, Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Obx(() { - return CupertinoAlertDialog( - title: Text( - '固件升级中'.tr, - ), - content: Column( - children: [ - Padding( - padding: EdgeInsets.only(top: 20.h, bottom: 10.h), - child: Text( - '传输期间请勿离开当前页面'.tr, - style: TextStyle(fontSize: 20.sp, color: AppColors.blackColor), - ), - ), - Row( - children: [ - Text( - '传输中'.tr, - style: TextStyle(fontSize: 18.sp, color: AppColors.mainColor), - ), - SizedBox( - width: 15.w, - ), - Expanded( - child: LinearProgressIndicator( - value: logic.state.otaProgress.value, - color: AppColors.mainColor, - )), - ], - ), - ], - ), - actions: [ - TextButton( - onPressed: () { - logic.closeOTADAta(); - }, - child: Text( - '取消升级'.tr, - style: TextStyle(fontSize: 22.sp, color: AppColors.blackColor), - ), - ), - ], - ); - }); + state.ifCurrentScreen.value = false; + logic.cancelBlueConnetctToastTimer(); + logic.stopScanBlueList(); } }