Browse Source

[fix]添加相机权限判断

Destiny 1 year ago
parent
commit
da0c19eaf6

+ 0 - 1
lib/data/repositories/user_repository.dart

@@ -26,7 +26,6 @@ class UserRepository {
   // 检测是否为会员
   bool isVip() {
     // 检查用户信息和会员信息是否存在
-    return true;
     if (userInfo.value?.memberInfo == null) {
       return false;
     }

+ 12 - 7
lib/module/analysis/analysis_controller.dart

@@ -267,18 +267,23 @@ class AnalysisController extends BaseController {
         // print(exifInfo);
       }
     } else {
-      ToastUtil.show("请先开启权限");
+      ToastUtil.show("Please enable the album permission first.");
     }
   }
 
   // 开启相机
   Future<void> openCamera() async {
-    final entity = await CameraPicker.pickFromCamera(
-      Get.context!,
-      pickerConfig: const CameraPickerConfig(),
-    );
-    if (entity != null) {
-      await saveAndRefreshAssets([entity]);
+    var status = await Permission.camera.status;
+    if (status == PermissionStatus.granted) {
+      final entity = await CameraPicker.pickFromCamera(
+        Get.context!,
+        pickerConfig: const CameraPickerConfig(),
+      );
+      if (entity != null) {
+        await saveAndRefreshAssets([entity]);
+      }
+    } else {
+      ToastUtil.show("Please enable the camera permission first.");
     }
   }
 }

+ 12 - 7
lib/module/privacy/privacy_controller.dart

@@ -413,18 +413,23 @@ class PrivacyController extends BaseController {
         await saveAndRefreshAssets(pickList);
       }
     } else {
-      ToastUtil.show("请先开启权限");
+      ToastUtil.show("Please enable the album permission first.");
     }
   }
 
 // 开启相机
   Future<void> openCamera() async {
-    final entity = await CameraPicker.pickFromCamera(
-      Get.context!,
-      pickerConfig: const CameraPickerConfig(),
-    );
-    if (entity != null) {
-      await saveAndRefreshAssets([entity]);
+    var status = await Permission.camera.status;
+    if (status == PermissionStatus.granted) {
+      final entity = await CameraPicker.pickFromCamera(
+        Get.context!,
+        pickerConfig: const CameraPickerConfig(),
+      );
+      if (entity != null) {
+        await saveAndRefreshAssets([entity]);
+      }
+    } else {
+      ToastUtil.show("Please enable the camera permission first.");
     }
   }
 }

+ 1 - 1
pubspec.yaml

@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 # In Windows, build-name is used as the major, minor, and patch parts
 # of the product and file versions while build-number is used as the build suffix.
-version: 1.1.0+16
+version: 1.1.0+17
 
 environment:
   sdk: ^3.6.0