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