Browse Source

[fit]修改权限跳转,修改无图片时展示逻辑

云天逵 9 months ago
parent
commit
a4a2f87a42

assets/anim/anim_no_photo.json → assets/anim/anim_loading_photo.json


+ 20 - 2
lib/module/analysis/analysis_controller.dart

@@ -271,8 +271,18 @@ class AnalysisController extends BaseController {
         // final exifInfo = await ClassifyPhoto().getPhotoExif(file!.path);
         // print(exifInfo);
       }
+    } else if (status == PermissionStatus.denied) {
+      var result = await Permission.photos.request();
+      if (result.isGranted) {
+        openGallery();
+      } else if (result.isPermanentlyDenied) {
+        ToastUtil.show("Please enable the photo permission first.");
+        openAppSettings();
+      } else {
+        ToastUtil.show("Please enable the photo permission first.");
+      }
     } else {
-      ToastUtil.show("Please enable the album permission first.");
+      openAppSettings();
     }
   }
 
@@ -288,7 +298,15 @@ class AnalysisController extends BaseController {
         await saveAndRefreshAssets([entity]);
       }
     } else {
-      ToastUtil.show("Please enable the camera permission first.");
+      var result = await Permission.camera.request();
+      if (result.isGranted) {
+        openCamera();
+      } else if (result.isPermanentlyDenied) {
+        ToastUtil.show("Please enable the camera permission first.");
+        openAppSettings();
+      } else{
+        ToastUtil.show("Please enable the camera permission first.");
+      }
     }
   }
 }

+ 14 - 3
lib/module/privacy/privacy_controller.dart

@@ -415,8 +415,16 @@ class PrivacyController extends BaseController {
       if (pickList != null && pickList.isNotEmpty) {
         await saveAndRefreshAssets(pickList);
       }
-    } else {
-      ToastUtil.show("Please enable the album permission first.");
+    }  else {
+      var result = await Permission.photos.request();
+      if (result.isGranted) {
+        openGallery();
+      } else if (result.isPermanentlyDenied) {
+        ToastUtil.show("Please enable the camera permission first.");
+        openAppSettings();
+      } else{
+        ToastUtil.show("Please enable the camera permission first.");
+      }
     }
   }
 
@@ -431,7 +439,10 @@ class PrivacyController extends BaseController {
       if (entity != null) {
         await saveAndRefreshAssets([entity]);
       }
-    } else {
+    } else if (status.isPermanentlyDenied) {
+      ToastUtil.show("Please enable the camera permission first.");
+      openAppSettings();
+    } else{
       ToastUtil.show("Please enable the camera permission first.");
     }
   }

+ 2 - 2
lib/utils/styles.dart

@@ -24,7 +24,7 @@ class Styles {
               : Center(
                   child: Opacity(
                   opacity: opacity ?? 0.22,
-                  child: Lottie.asset(Assets.anim.animNoPhoto,
+                  child: Lottie.asset(Assets.anim.animLoadingPhoto,
                       width: width ?? 140.w,
                       height: height ?? 140.w,
                       repeat: repeat ?? true),
@@ -49,7 +49,7 @@ class Styles {
               : Center(
                   child: Opacity(
                       opacity: opacity ?? 0.22,
-                      child: Lottie.asset(Assets.anim.animNoPhoto,
+                      child: Lottie.asset(Assets.anim.animLoadingPhoto,
                           width: width ?? 140.w,
                           height: height ?? 140.w,
                           repeat: repeat ?? true))));

+ 1 - 2
pubspec.yaml

@@ -64,8 +64,7 @@ dependencies:
     sdk: flutter
   # 图片保存
   image_gallery_saver: ^2.0.3
-  # 圆形进度条
-  syncfusion_flutter_charts: ^28.1.38
+
   # 卡片滑动
   flutter_card_swiper: ^7.0.2
   #权限申请