更新
This commit is contained in:
@@ -7,12 +7,14 @@ import 'package:flutter_svg/svg.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/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/component/mht_bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/device/component/DeviceComponentWidget.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/device/controller/mht_bluetooth_controller.dart';
|
||||
@@ -72,12 +74,92 @@ class _MHTBlueteethDevicePageState extends State<MHTBlueteethDevicePage> {
|
||||
}
|
||||
}
|
||||
|
||||
// Future<void> _requestBluetoothPermission() async {
|
||||
// // showPermissionInfoDialog(Get.context!, CommonVariables().permissionInfo);
|
||||
// // Map<Permission, PermissionStatus> statuses = await [
|
||||
// // Permission.bluetoothScan,
|
||||
// // Permission.bluetoothConnect,
|
||||
// // Permission.location,
|
||||
// // ].request();
|
||||
// Map<Permission, PermissionStatus> statuses = {};
|
||||
// try {
|
||||
// // 1️⃣ 先显示自定义提示弹窗
|
||||
// showPermissionInfoDialog(Get.context!, CommonVariables().permissionInfo);
|
||||
|
||||
// // 2️⃣ 等待一小会,让 UI 有时间渲染提示弹窗
|
||||
// await Future.delayed(const Duration(milliseconds: 300));
|
||||
|
||||
// // 3️⃣ 再去申请权限(系统权限弹窗可能会弹出)
|
||||
// statuses = await [
|
||||
// Permission.bluetoothScan,
|
||||
// Permission.bluetoothConnect,
|
||||
// Permission.location,
|
||||
// ].request();
|
||||
|
||||
// // 这里你可以检查每个权限的状态
|
||||
// ef.log("权限状态: $statuses");
|
||||
// } catch (e) {
|
||||
// ef.log("申请权限出错: $e");
|
||||
// } finally {
|
||||
// // 4️⃣ 无论成功失败,最后关闭提示弹窗
|
||||
// if (Get.context != null) {
|
||||
// Navigator.of(Get.context!, rootNavigator: true).pop();
|
||||
// }
|
||||
// }
|
||||
|
||||
// bool allGranted = statuses[Permission.bluetoothScan]?.isGranted == true &&
|
||||
// statuses[Permission.bluetoothConnect]?.isGranted == true &&
|
||||
// statuses[Permission.location]?.isGranted == true;
|
||||
|
||||
// if (allGranted) {
|
||||
// _startScanning();
|
||||
// _startPeriodicScan();
|
||||
// } else {
|
||||
// _showPermissionDeniedDialog();
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<void> _requestBluetoothPermission() async {
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
Permission.bluetoothScan,
|
||||
Permission.bluetoothConnect,
|
||||
Permission.location,
|
||||
].request();
|
||||
Map<Permission, PermissionStatus> statuses = {};
|
||||
bool dialogShown = false; // 标记是否弹过权限提示弹窗
|
||||
|
||||
try {
|
||||
// 检查是否已授权
|
||||
bool alreadyGranted = await Permission.bluetoothScan.isGranted &&
|
||||
await Permission.bluetoothConnect.isGranted &&
|
||||
await Permission.location.isGranted;
|
||||
|
||||
if (!alreadyGranted) {
|
||||
// 弹出自定义提示
|
||||
showPermissionInfoDialog(
|
||||
Get.context!, CommonVariables().permissionInfo);
|
||||
dialogShown = true;
|
||||
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
|
||||
// 请求权限
|
||||
statuses = await [
|
||||
Permission.bluetoothScan,
|
||||
Permission.bluetoothConnect,
|
||||
Permission.location,
|
||||
].request();
|
||||
|
||||
ef.log("权限状态: $statuses");
|
||||
} else {
|
||||
statuses = {
|
||||
Permission.bluetoothScan: PermissionStatus.granted,
|
||||
Permission.bluetoothConnect: PermissionStatus.granted,
|
||||
Permission.location: PermissionStatus.granted,
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
ef.log("申请权限出错: $e");
|
||||
} finally {
|
||||
// 只有真的弹过提示才关闭
|
||||
if (dialogShown && Get.context != null) {
|
||||
Navigator.of(Get.context!, rootNavigator: true).pop();
|
||||
}
|
||||
}
|
||||
|
||||
bool allGranted = statuses[Permission.bluetoothScan]?.isGranted == true &&
|
||||
statuses[Permission.bluetoothConnect]?.isGranted == true &&
|
||||
|
||||
@@ -253,7 +253,7 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
}
|
||||
return Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0.rpx, 40.rpx, 30.rpx, 40.rpx),
|
||||
0.rpx, 10.rpx, 30.rpx, 0.rpx),
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
constraints: BoxConstraints(
|
||||
@@ -265,7 +265,7 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 16.rpx, 0.rpx, 25.rpx),
|
||||
20.rpx, 16.rpx, 0.rpx, 20.rpx),
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
child: Row(
|
||||
@@ -273,16 +273,6 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Text(
|
||||
// '健康报告'.tr,
|
||||
// style: TextStyle(
|
||||
// fontFamily: 'Readex Pro',
|
||||
// color:
|
||||
// themeController.currentColor.sc3,
|
||||
// letterSpacing: 0,
|
||||
// fontSize: 30.rpx,
|
||||
// ),
|
||||
// ),
|
||||
ScrollbarTheme(
|
||||
data: ScrollbarThemeData(
|
||||
thumbColor: MaterialStateProperty.all(
|
||||
@@ -379,8 +369,13 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
.updateAll();
|
||||
}
|
||||
},
|
||||
width: 300.rpx,
|
||||
height: 81.rpx,
|
||||
// width: 260.rpx,
|
||||
width:
|
||||
MediaQuery.of(context)
|
||||
.size
|
||||
.width *
|
||||
0.5,
|
||||
height: 53.rpx,
|
||||
maxHeight: 300.rpx,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 28.rpx,
|
||||
@@ -495,6 +490,9 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 30.rpx,
|
||||
),
|
||||
getTimeWidget(), // 始终显示
|
||||
isLoading.value
|
||||
? Padding(
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/model/WebSocketMessage.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/device/controller/mht_bluetooth_controller.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
|
||||
@@ -537,7 +538,9 @@ class WebviewTestView extends GetComponent<WebviewTestController> {
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Obx(() {
|
||||
return (controller.ready.value)
|
||||
int? aa = MainPageBBottomChange.getCurrentIndex();
|
||||
print(aa);
|
||||
return (controller.ready.value && (MainPageBBottomChange.getCurrentIndex() == 2))
|
||||
? controller.web.build()
|
||||
: Center(child: CircularProgressIndicator());
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user