diff --git a/lib/main.dart b/lib/main.dart index 47611a6..273457e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -548,7 +548,7 @@ class MyApp extends StatelessWidget { return GetMaterialApp( translations: AppLanguage(), debugShowCheckedModeBanner: false, - title: '', + title: '智慧眠花糖', theme: themeController.currentTheme, localizationsDelegates: const [ GlobalMaterialLocalizations.delegate, @@ -636,7 +636,7 @@ class MyApp extends StatelessWidget { const Locale('en', 'US'), // ⚠️ 添加你支持的语言 ], debugShowCheckedModeBanner: false, - title: '', + title: '太和e护', theme: themeController.currentTheme, // home: const MyHomePage(title: '智慧眠花糖 Home Page'), initialRoute: "/mianPageBottomChange", diff --git a/lib/pages/device/BodyDeviceWidget.dart b/lib/pages/device/BodyDeviceWidget.dart index a352c22..400c615 100644 --- a/lib/pages/device/BodyDeviceWidget.dart +++ b/lib/pages/device/BodyDeviceWidget.dart @@ -81,35 +81,36 @@ class _BodyDevicePageState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox(height: 11.rpx), - ClickableContainer( - padding: EdgeInsets.symmetric(vertical: 10.rpx), - backgroundColor: Colors.transparent, - highlightColor: - themeController.currentColor.sc16.withOpacity(0.1), - borderRadius: 0.rpx, - onTap: () { - print('点击扫一扫'); - _hidePopup(); - TopSlideNotification.show( - context, - text: "待开发.提示".tr, - textColor: themeController.currentColor.sc2, - ); - }, - child: Container( - width: double.infinity, - child: Center( - child: Text( - '扫一扫.标题'.tr, - style: TextStyle( - fontSize: AppConstants().normal_text_fontSize, - color: themeController.currentColor.sc3, - ), - ), - ), - ), - ), - SizedBox(height: 35.rpx), + // ClickableContainer( + // padding: EdgeInsets.symmetric(vertical: 10.rpx), + // backgroundColor: Colors.transparent, + // highlightColor: + // themeController.currentColor.sc16.withOpacity(0.1), + // borderRadius: 0.rpx, + // onTap: () { + // print('点击扫一扫'); + // _hidePopup(); + // TopSlideNotification.show( + // context, + // text: "待开发.提示".tr, + // textColor: themeController.currentColor.sc2, + // ); + // }, + // child: Container( + // width: double.infinity, + // child: Center( + // child: Text( + // '扫一扫.标题'.tr, + // style: TextStyle( + // fontSize: AppConstants().normal_text_fontSize, + // color: themeController.currentColor.sc3, + // ), + // ), + // ), + // ), + // ), + // SizedBox(height: 35.rpx), + ClickableContainer( padding: EdgeInsets.symmetric(vertical: 10.rpx), backgroundColor: Colors.transparent, diff --git a/lib/pages/main_bottom/component/main_page_b_bottom_change.dart b/lib/pages/main_bottom/component/main_page_b_bottom_change.dart index a3163dc..1dba1fd 100644 --- a/lib/pages/main_bottom/component/main_page_b_bottom_change.dart +++ b/lib/pages/main_bottom/component/main_page_b_bottom_change.dart @@ -1,27 +1,23 @@ import 'dart:convert'; import 'dart:io'; +import 'package:EasyDartModule/EasyDartModule.dart' as edm; import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get_storage/get_storage.dart'; -import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/util/CommonVariables.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; -import 'package:vbvs_app/component/NullDataComponentWidget.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/mh_controller/mh_language_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/WebSocketMessage.dart'; import 'package:vbvs_app/pages/common/bezier_bottom_navigation_bar.dart'; -import 'package:vbvs_app/pages/common/selectDialog.dart'; import 'package:vbvs_app/pages/mh_page/MattressControl.dart'; -import 'package:vbvs_app/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart'; import 'package:vbvs_app/pages/mh_page/homepage/mht_sleep_report_page.dart'; import 'package:vbvs_app/pages/mh_page/homepage/new_Home_page.dart'; import 'package:vbvs_app/pages/mh_page/new_mine_page.dart'; import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart'; -import 'package:EasyDartModule/EasyDartModule.dart' as edm; class MainPageBBottomChange extends StatefulWidget { // 全局 key,用于静态访问 _HomePageState diff --git a/lib/pages/main_bottom/home_page.dart b/lib/pages/main_bottom/home_page.dart index 96a144e..7302448 100644 --- a/lib/pages/main_bottom/home_page.dart +++ b/lib/pages/main_bottom/home_page.dart @@ -94,34 +94,35 @@ class _HomePageState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox(height: 11.rpx), - ClickableContainer( - padding: EdgeInsets.symmetric(vertical: 10.rpx), - backgroundColor: Colors.transparent, - highlightColor: - themeController.currentColor.sc16.withOpacity(0.1), - borderRadius: 0.rpx, - onTap: () { - _popupEntry?.remove(); - _popupEntry = null; - TopSlideNotification.show( - context, - text: "待开发功能".tr, - ); - }, - child: Container( - width: double.infinity, - child: Center( - child: Text( - '扫一扫.标题'.tr, - style: TextStyle( - fontSize: AppConstants().normal_text_fontSize, - color: themeController.currentColor.sc3, - ), - ), - ), - ), - ), - SizedBox(height: 35.rpx), + // ClickableContainer( + // padding: EdgeInsets.symmetric(vertical: 10.rpx), + // backgroundColor: Colors.transparent, + // highlightColor: + // themeController.currentColor.sc16.withOpacity(0.1), + // borderRadius: 0.rpx, + // onTap: () { + // _popupEntry?.remove(); + // _popupEntry = null; + // TopSlideNotification.show( + // context, + // text: "待开发功能".tr, + // ); + // }, + // child: Container( + // width: double.infinity, + // child: Center( + // child: Text( + // '扫一扫.标题'.tr, + // style: TextStyle( + // fontSize: AppConstants().normal_text_fontSize, + // color: themeController.currentColor.sc3, + // ), + // ), + // ), + // ), + // ), + // SizedBox(height: 35.rpx), + ClickableContainer( padding: EdgeInsets.symmetric(vertical: 10.rpx), backgroundColor: Colors.transparent, diff --git a/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart b/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart index 0388868..23fb9ee 100644 --- a/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart +++ b/lib/pages/mh_page/homepage/component/HomeDeviceStausWidget.dart @@ -1,5 +1,8 @@ +import 'dart:io'; + import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; @@ -201,69 +204,92 @@ Future checkBlueToothPermissin() async { var bluetoothConnectGranted; var locationGranted; - try { - // 先显示权限说明弹窗(同屏显示) - bool bluetoothScanPermanentlyDenied = - await Permission.bluetoothScan.isPermanentlyDenied; - bool bluetoothConnectPermanentlyDenied = - await Permission.bluetoothConnect.isPermanentlyDenied; - bool locationPermanentlyDenied = - await Permission.location.isPermanentlyDenied; - - if (bluetoothScanPermanentlyDenied || - bluetoothConnectPermanentlyDenied || - locationPermanentlyDenied) { - return data; // 直接返回,不再弹窗申请 + if (Platform.isIOS) { + PermissionStatus isBleGranted = await Permission.bluetooth.request(); + if (isBleGranted.isGranted) { + // startBluetoothScanning(); + await FlutterBluePlus.startScan(timeout: Duration(seconds: 10)); + data = { + 'bluetoothScanGranted': true, + 'bluetoothConnectGranted': true, + }; + } else { + try { + await FlutterBluePlus.startScan(timeout: Duration(seconds: 10)); + } catch (e) { + TopSlideNotification.show(Get.context!, + text: "蓝牙权限未开启,请在设置中开启蓝牙权限".tr, + textColor: themeController.currentColor.sc9); + } } - if (userInfoController.initLocationpermission == 1) { + return data; + } else { + try { + // 先显示权限说明弹窗(同屏显示) + bool bluetoothScanPermanentlyDenied = + await Permission.bluetoothScan.isPermanentlyDenied; + bool bluetoothConnectPermanentlyDenied = + await Permission.bluetoothConnect.isPermanentlyDenied; + bool locationPermanentlyDenied = + await Permission.location.isPermanentlyDenied; + + if (bluetoothScanPermanentlyDenied || + bluetoothConnectPermanentlyDenied || + locationPermanentlyDenied) { + return data; // 直接返回,不再弹窗申请 + } + if (userInfoController.initLocationpermission == 1) { + bluetoothScanGranted = await Permission.bluetoothScan.isGranted; + bluetoothConnectGranted = await Permission.bluetoothConnect.isGranted; + locationGranted = await Permission.location.isGranted; + data = { + 'bluetoothScanGranted': bluetoothScanGranted, + 'bluetoothConnectGranted': bluetoothConnectGranted, + 'locationGranted': locationGranted, + }; + return data; + } + showPermissionInfoDialog( + Get.context!, + CommonVariables().bluetoothpermissionInfo, + ); + show = true; + + // 检查并请求权限 bluetoothScanGranted = await Permission.bluetoothScan.isGranted; bluetoothConnectGranted = await Permission.bluetoothConnect.isGranted; locationGranted = await Permission.location.isGranted; + + if (!bluetoothScanGranted || + !bluetoothConnectGranted || + !locationGranted) { + await [ + Permission.bluetoothScan, + Permission.bluetoothConnect, + Permission.location, + ].request(); + + // 更新权限状态 + bluetoothScanGranted = await Permission.bluetoothScan.isGranted; + bluetoothConnectGranted = await Permission.bluetoothConnect.isGranted; + locationGranted = await Permission.location.isGranted; + } + data = { 'bluetoothScanGranted': bluetoothScanGranted, 'bluetoothConnectGranted': bluetoothConnectGranted, 'locationGranted': locationGranted, }; - return data; - } - showPermissionInfoDialog( - Get.context!, - CommonVariables().bluetoothpermissionInfo, - ); - show = true; - // 检查并请求权限 - bluetoothScanGranted = await Permission.bluetoothScan.isGranted; - bluetoothConnectGranted = await Permission.bluetoothConnect.isGranted; - locationGranted = await Permission.location.isGranted; - - if (!bluetoothScanGranted || !bluetoothConnectGranted || !locationGranted) { - await [ - Permission.bluetoothScan, - Permission.bluetoothConnect, - Permission.location, - ].request(); - - // 更新权限状态 - bluetoothScanGranted = await Permission.bluetoothScan.isGranted; - bluetoothConnectGranted = await Permission.bluetoothConnect.isGranted; - locationGranted = await Permission.location.isGranted; - } - - data = { - 'bluetoothScanGranted': bluetoothScanGranted, - 'bluetoothConnectGranted': bluetoothConnectGranted, - 'locationGranted': locationGranted, - }; - - // 通知 web 端 - WebviewTestController webviewTestController = Get.find(); - // webviewTestController.web.jsbridge?.dart.updatePermission(data); - } catch (e) { - ef.log("蓝牙权限:$e"); - } finally { - if (show) { - Navigator.of(Get.context!, rootNavigator: true).pop(); + // 通知 web 端 + WebviewTestController webviewTestController = Get.find(); + // webviewTestController.web.jsbridge?.dart.updatePermission(data); + } catch (e) { + ef.log("蓝牙权限:$e"); + } finally { + if (show) { + Navigator.of(Get.context!, rootNavigator: true).pop(); + } } } diff --git a/lib/pages/mh_page/test/WebviewTestModel.dart b/lib/pages/mh_page/test/WebviewTestModel.dart index c842aff..0f71465 100644 --- a/lib/pages/mh_page/test/WebviewTestModel.dart +++ b/lib/pages/mh_page/test/WebviewTestModel.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:io'; import 'package:EasyDartModule/EasyDartModule.dart' as edm; import 'package:easydevice/easydevice.dart'; @@ -63,7 +64,7 @@ class WebviewTestController extends GetControllerEx { web.jsbridge!.bind((bridge) { var minible = Minibleapp(bridge: bridge); // ef.kvroot.devicelist.listen((x) {}); - bridge.sdk.updateDeviceRoute((args) async { + bridge.sdk.updateDeviceRoute((args) async { ef.log('updateDeviceRoute: $args'); selectDevice['blueToothStatus'] = bluetooth; Get.toNamed("${args[0]}", arguments: selectDevice); @@ -236,11 +237,21 @@ class WebviewTestController extends GetControllerEx { if (data == null || data.isEmpty) { return false; } - if (!data['bluetoothScanGranted'] || - !data['bluetoothConnectGranted'] || - !data['locationGranted']) { + if (Platform.isIOS) { + if (!data['bluetoothScanGranted'] || + !data['bluetoothConnectGranted']) { + return false; + } + } else if (Platform.isAndroid) { + if (!data['bluetoothScanGranted'] || + !data['bluetoothConnectGranted'] || + !data['locationGranted']) { + return false; + } + } else { return false; } + return true; } catch (e) { ef.log("[网页加载失败]:$e"); @@ -565,12 +576,14 @@ class WebviewTestView extends GetComponent { // return (controller.ready.value && (MainPageBBottomChange.getCurrentIndex() == 2)) return (controller.ready.value) ? controller.web.build() - : Center(child:CircularProgressIndicator( - strokeWidth: 2, - valueColor: AlwaysStoppedAnimation( - themeController.currentColor.sc1, - ), - ),); + : Center( + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation( + themeController.currentColor.sc1, + ), + ), + ); }), ), ),