修复添加锁时从所有锁进入引起的权限问题

This commit is contained in:
魏少阳 2024-08-10 14:10:43 +08:00
parent a527b4337f
commit 85d7401ed2
3 changed files with 32 additions and 12 deletions

View File

@ -663,17 +663,17 @@ class NearbyLockLogic extends BaseGetXController {
Future<void> getNearByLimits() async {
if (!Platform.isIOS) {
bool bluetoothRequest = false;
try {
bluetoothRequest = await PermissionDialog.requestBluetooth();
AppLog.log('bluetoothRequest:$bluetoothRequest');
if (!bluetoothRequest) {
return;
}
} catch (e) {
AppLog.log('bluetoothRequest:$e');
}
// bool bluetoothRequest = false;
// try {
// bluetoothRequest = await PermissionDialog.requestBluetooth();
// AppLog.log('bluetoothRequest:$bluetoothRequest');
// if (!bluetoothRequest) {
// return;
// }
// } catch (e) {
// AppLog.log('bluetoothRequest:$e');
// }
final bool bluetoothRequest = await PermissionDialog.requestBluetooth();
final bool locationRequest = await PermissionDialog.request(Permission.location);
AppLog.log('locationRequest:$locationRequest');
if (!bluetoothRequest || !locationRequest) {

View File

@ -1,7 +1,13 @@
import 'dart:io';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/commonDataManage.dart';
import '../../../appRouters.dart';
import '../../../network/api_repository.dart';
import '../../../widget/permission/permission_dialog.dart';
import 'selectLockType_state.dart';
class SelectLockTypeLogic extends BaseGetXController {
@ -13,6 +19,19 @@ class SelectLockTypeLogic extends BaseGetXController {
}
}
//
Future<void> getNearByLimits() async {
if (!Platform.isIOS) {
final bool locationRequest = await PermissionDialog.request(Permission.location);
final bool bluetoothRequest = await PermissionDialog.requestBluetooth();
if (!bluetoothRequest || !locationRequest) {
return;
}
}
Get.toNamed(Routers.nearbyLockPage);
}
@override
void onInit() {
super.onInit();

View File

@ -190,7 +190,8 @@ class _SelectLockTypePageState extends State<SelectLockTypePage> with BaseWidget
return GestureDetector(
onTap: () {
CommonDataManage().seletLockType = 0;
Get.toNamed(Routers.nearbyLockPage);
logic.getNearByLimits();
// Get.toNamed(Routers.nearbyLockPage);
},
child: view,
);