更新
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/CommonVariables.dart';
|
||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/CustomCard.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/test/WebviewTestModel.dart';
|
||||
|
||||
@@ -91,6 +95,7 @@ class _HomeDeviceStausWidgetState extends State<HomeDeviceStausWidget> {
|
||||
webviewTestController.web.jsbridge?.dart.switchLanguage(
|
||||
mhLanguageController
|
||||
.selectLanguage.value!.language_code);
|
||||
await checkBlueToothPermissin();
|
||||
webviewTestController.web.jsbridge?.dart
|
||||
.pageActive(false);
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
@@ -128,3 +133,140 @@ class _HomeDeviceStausWidgetState extends State<HomeDeviceStausWidget> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Future<Map> checkBlueToothPermissin() async {
|
||||
// UserInfoController userInfoController = Get.find();
|
||||
// bool show = false;
|
||||
// Map data = {};
|
||||
// var bluetoothScanGranted;
|
||||
// var bluetoothConnectGranted;
|
||||
// var locationGranted;
|
||||
// try {
|
||||
// // 如果没初始化过,就检查并请求权限
|
||||
// if (userInfoController.initLocationpermission != 1) {
|
||||
// bluetoothScanGranted = await Permission.bluetoothScan.isGranted;
|
||||
// bluetoothConnectGranted = await Permission.bluetoothConnect.isGranted;
|
||||
// locationGranted = await Permission.location.isGranted;
|
||||
|
||||
// // 如果权限没全部授予
|
||||
// if (!bluetoothScanGranted ||
|
||||
// !bluetoothConnectGranted ||
|
||||
// !locationGranted) {
|
||||
// show = true;
|
||||
// // 同屏显示权限说明弹窗(阻塞等待用户点击确认)
|
||||
// showPermissionInfoDialog(
|
||||
// Get.context!,
|
||||
// CommonVariables().bluetoothpermissionInfo,
|
||||
// );
|
||||
|
||||
// // 再请求权限
|
||||
// await [
|
||||
// Permission.bluetoothScan,
|
||||
// Permission.bluetoothConnect,
|
||||
// Permission.location,
|
||||
// ].request();
|
||||
|
||||
// // 再次检查最新权限状态
|
||||
// bluetoothScanGranted = await Permission.bluetoothScan.isGranted;
|
||||
// bluetoothConnectGranted = await Permission.bluetoothConnect.isGranted;
|
||||
// locationGranted = await Permission.location.isGranted;
|
||||
// }
|
||||
// }
|
||||
// // 通知 web 端
|
||||
// data = {
|
||||
// 'bluetoothScanGranted': bluetoothScanGranted,
|
||||
// 'bluetoothConnectGranted': bluetoothConnectGranted,
|
||||
// 'locationGranted': locationGranted,
|
||||
// };
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 标记初始化完成
|
||||
// userInfoController.initLocationpermission = 1;
|
||||
// return data;
|
||||
// }
|
||||
|
||||
Future<Map> checkBlueToothPermissin() async {
|
||||
UserInfoController userInfoController = Get.find();
|
||||
bool show = false;
|
||||
Map data = {};
|
||||
var bluetoothScanGranted;
|
||||
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 (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,
|
||||
};
|
||||
|
||||
// 通知 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();
|
||||
}
|
||||
}
|
||||
|
||||
userInfoController.initLocationpermission = 1;
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user