diff --git a/assets/image/2x/icon_storage_permission_tips.webp b/assets/image/2x/icon_storage_permission_tips.webp index dbc53731..8ee37e69 100644 Binary files a/assets/image/2x/icon_storage_permission_tips.webp and b/assets/image/2x/icon_storage_permission_tips.webp differ diff --git a/assets/image/3x/icon_storage_permission_tips.webp b/assets/image/3x/icon_storage_permission_tips.webp index 34da5deb..c3fa529d 100644 Binary files a/assets/image/3x/icon_storage_permission_tips.webp and b/assets/image/3x/icon_storage_permission_tips.webp differ diff --git a/assets/image/icon_storage_permission_tips.webp b/assets/image/icon_storage_permission_tips.webp index e513e773..0c86cca2 100644 Binary files a/assets/image/icon_storage_permission_tips.webp and b/assets/image/icon_storage_permission_tips.webp differ diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 6e0ae61a..5370bcd5 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -642,7 +642,7 @@ class MessageLookup extends MessageLookupByLibrary { "weikaiqi" : MessageLookupByLibrary.simpleMessage("未开启"), "weilegeiningenghaodefuwu" : MessageLookupByLibrary.simpleMessage("为了给您提供更好的服务,以及享受更加精彩的信息内容,请您在使用期间,进行登录"), "weilejishishoudaohuodongxiaoxi" : MessageLookupByLibrary.simpleMessage("为了您可以及时收到我们的活动信息,请您开启消息通知权限"), - "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,请您开启相机使用权限"), + "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,扫码,请您开启相机使用权限"), "weilexiangnintuijianfujindemendianxinxi" : MessageLookupByLibrary.simpleMessage("为了向您推荐附近的门店信息,推荐您在使用期间让我们使用位置信息"), "weilexuanzhezhaopianhuancun" : MessageLookupByLibrary.simpleMessage("为了获得照片使用,缓存等功能,推荐您在使用期间打开存储权限"), "weiwancheng" : MessageLookupByLibrary.simpleMessage(" 未完成 "), diff --git a/lib/generated/intl/messages_zh_CN.dart b/lib/generated/intl/messages_zh_CN.dart index 71a00094..898bfe49 100644 --- a/lib/generated/intl/messages_zh_CN.dart +++ b/lib/generated/intl/messages_zh_CN.dart @@ -642,7 +642,7 @@ class MessageLookup extends MessageLookupByLibrary { "weikaiqi" : MessageLookupByLibrary.simpleMessage("未开启"), "weilegeiningenghaodefuwu" : MessageLookupByLibrary.simpleMessage("为了给您提供更好的服务,以及享受更加精彩的信息内容,请您在使用期间,进行登录"), "weilejishishoudaohuodongxiaoxi" : MessageLookupByLibrary.simpleMessage("为了您可以及时收到我们的活动信息,请您开启消息通知权限"), - "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,请您开启相机使用权限"), + "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,扫码,请您开启相机使用权限"), "weilexiangnintuijianfujindemendianxinxi" : MessageLookupByLibrary.simpleMessage("为了向您推荐附近的门店信息,推荐您在使用期间让我们使用位置信息"), "weilexuanzhezhaopianhuancun" : MessageLookupByLibrary.simpleMessage("为了获得照片使用,缓存等功能,推荐您在使用期间打开存储权限"), "weiwancheng" : MessageLookupByLibrary.simpleMessage(" 未完成 "), diff --git a/lib/generated/intl/messages_zh_Hans_CN.dart b/lib/generated/intl/messages_zh_Hans_CN.dart index 208dc7c2..b1b542ca 100644 --- a/lib/generated/intl/messages_zh_Hans_CN.dart +++ b/lib/generated/intl/messages_zh_Hans_CN.dart @@ -642,7 +642,7 @@ class MessageLookup extends MessageLookupByLibrary { "weikaiqi" : MessageLookupByLibrary.simpleMessage("未开启"), "weilegeiningenghaodefuwu" : MessageLookupByLibrary.simpleMessage("为了给您提供更好的服务,以及享受更加精彩的信息内容,请您在使用期间,进行登录"), "weilejishishoudaohuodongxiaoxi" : MessageLookupByLibrary.simpleMessage("为了您可以及时收到我们的活动信息,请您开启消息通知权限"), - "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,请您开启相机使用权限"), + "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,扫码,请您开启相机使用权限"), "weilexiangnintuijianfujindemendianxinxi" : MessageLookupByLibrary.simpleMessage("为了向您推荐附近的门店信息,推荐您在使用期间让我们使用位置信息"), "weilexuanzhezhaopianhuancun" : MessageLookupByLibrary.simpleMessage("为了获得照片使用,缓存等功能,推荐您在使用期间打开存储权限"), "weiwancheng" : MessageLookupByLibrary.simpleMessage(" 未完成 "), diff --git a/lib/generated/intl/messages_zh_Hant_CN.dart b/lib/generated/intl/messages_zh_Hant_CN.dart index 7f77e96b..72062448 100644 --- a/lib/generated/intl/messages_zh_Hant_CN.dart +++ b/lib/generated/intl/messages_zh_Hant_CN.dart @@ -636,7 +636,7 @@ class MessageLookup extends MessageLookupByLibrary { "weikaiqi" : MessageLookupByLibrary.simpleMessage("未開啓"), "weilegeiningenghaodefuwu" : MessageLookupByLibrary.simpleMessage("為了給您提供更好的服務,以及享受更加精彩的信息內容,請在使用使用期間登錄"), "weilejishishoudaohuodongxiaoxi" : MessageLookupByLibrary.simpleMessage("为了您可以及时收到我们的活动信息,请您开启消息通知权限"), - "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,请您开启相机使用权限"), + "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,扫码,请您开启相机使用权限"), "weilexiangnintuijianfujindemendianxinxi" : MessageLookupByLibrary.simpleMessage("為了向您推薦附近的門店信息,推薦您在使用期間讓我們使用位置信息"), "weilexuanzhezhaopianhuancun" : MessageLookupByLibrary.simpleMessage("为了获得照片使用,缓存等功能,推荐您在使用期间打开存储权限"), "weiwancheng" : MessageLookupByLibrary.simpleMessage(" 未完成 "), diff --git a/lib/generated/intl/messages_zh_TW.dart b/lib/generated/intl/messages_zh_TW.dart index 7aa43e49..97ac1375 100644 --- a/lib/generated/intl/messages_zh_TW.dart +++ b/lib/generated/intl/messages_zh_TW.dart @@ -639,7 +639,7 @@ class MessageLookup extends MessageLookupByLibrary { "weikaiqi" : MessageLookupByLibrary.simpleMessage("未開啓"), "weilegeiningenghaodefuwu" : MessageLookupByLibrary.simpleMessage("為了給您提供更好的服務,以及享受更加精彩的信息內容,請在使用使用期間登錄"), "weilejishishoudaohuodongxiaoxi" : MessageLookupByLibrary.simpleMessage("为了您可以及时收到我们的活动信息,请您开启消息通知权限"), - "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,请您开启相机使用权限"), + "weilekaipaizhaoxuanzhetouxiang" : MessageLookupByLibrary.simpleMessage("为了您可以在使用过程中更换头像,扫码,请您开启相机使用权限"), "weilexiangnintuijianfujindemendianxinxi" : MessageLookupByLibrary.simpleMessage("為了向您推薦附近的門店信息,推薦您在使用期間讓我們使用位置信息"), "weilexuanzhezhaopianhuancun" : MessageLookupByLibrary.simpleMessage("为了获得照片使用,缓存等功能,推荐您在使用期间打开存储权限"), "weiwancheng" : MessageLookupByLibrary.simpleMessage(" 未完成 "), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index ee13d043..c1d96b18 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -3548,7 +3548,7 @@ class S { /// `为了您可以在使用过程中更换头像,请您开启相机使用权限` String get weilekaipaizhaoxuanzhetouxiang { return Intl.message( - '为了您可以在使用过程中更换头像,请您开启相机使用权限', + '为了您可以在使用过程中更换头像,扫码,请您开启相机使用权限', name: 'weilekaipaizhaoxuanzhetouxiang', desc: '', args: [], diff --git a/lib/mine/mine_view/mine_view.dart b/lib/mine/mine_view/mine_view.dart index 92f153ac..59dacba7 100644 --- a/lib/mine/mine_view/mine_view.dart +++ b/lib/mine/mine_view/mine_view.dart @@ -230,10 +230,79 @@ class _MineView extends State { ); } } else { - await Permission.camera.request(); + showScanTipsAlertDialog(context); } } + ///扫码权限说明 + showScanTipsAlertDialog(context) async { + //显示对话框 + showDialog( + context: context, + barrierDismissible: false, + barrierColor: null, + builder: (BuildContext context) { + return Column( + children: [ + Container( + width: double.infinity, + padding: EdgeInsets.all(15), + margin: EdgeInsets.all(15), + decoration: new BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding(padding:EdgeInsets.only(right: 10.w,), + child: Icon( + Icons.add_a_photo, + color: Colors.black, + size: 22, + )), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "相机权限使用说明", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + SizedBox( + height: 3.h, + ), + Text( + "实现您扫码、拍摄等功能。", + style: TextStyle( + fontSize: 13.sp, + height: 1.2, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ], + ), + ), + ], + ), + ) + ], + mainAxisSize: MainAxisSize.min, + ); + }, + ); + await Permission.camera.request(); + Navigator.of(context).pop(); + if(await Permission.camera.isGranted) + toScan(); + } + activityShowAlertDialog(String result) { //显示对话框 showDialog( diff --git a/lib/mine/user_info_page.dart b/lib/mine/user_info_page.dart index 9909161f..b28c7498 100644 --- a/lib/mine/user_info_page.dart +++ b/lib/mine/user_info_page.dart @@ -20,6 +20,8 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import '../view_widget/request_permission.dart'; + class UserInfoPage extends StatefulWidget { @override State createState() { @@ -391,22 +393,62 @@ class _UserInfoPage extends State { ///拍照 openCamera() async { - if (await Permission.camera.isGranted) { - Media medias = await ImagePickers.openCamera( - cameraMimeType: CameraMimeType.photo, - cropConfig: CropConfig( - enableCrop: true, - width: 200, - height: 200, - ), - compressSize: 500, - ); - if (medias == null) return; - filePath = medias.path; - fileUpload(); + if (await Permission.camera.isPermanentlyDenied) { + showCupertinoDialog( + context: context, + builder: (context) { + return RequestPermission( + "assets/image/icon_camera_permission_tips.webp", + S.of(context).ninxiangjiquanxianweikaiqi, + S.of(context).weilekaipaizhaoxuanzhetouxiang, + S.of(context).kaiqiquanxian, + (result) async { + if (result) { + await openAppSettings(); + } + }, + heightRatioWithWidth: 0.82, + ); + }); + }else if (await Permission.camera.isGranted) { + if (await Permission.storage.isPermanentlyDenied) { + showCupertinoDialog( + context: context, + builder: (context) { + return RequestPermission( + "assets/image/icon_storage_permission_tips.webp", + "您未开启存储权限,请点击开启", + "为了您可以在使用过程中访问您设备上的照片、媒体内容和文件,请您开启存储使用权限", + S.of(context).kaiqiquanxian, + (result) async { + if (result) { + await openAppSettings(); + } + }, + heightRatioWithWidth: 0.82, + ); + });}else if(await Permission.storage.isGranted){ + Media medias = await ImagePickers.openCamera( + cameraMimeType: CameraMimeType.photo, + cropConfig: CropConfig( + enableCrop: true, + width: 200, + height: 200, + ), + compressSize: 500, + ); + if (medias == null) return; + filePath = medias.path; + fileUpload(); + }else{ + showStorageTipsAlertDialog(context,1); + return false; + } } else { - await Permission.camera.request(); - openCamera(); + showCameraTipsAlertDialog(context); + return false; + // await Permission.camera.request(); + // openCamera(); } } @@ -414,7 +456,24 @@ class _UserInfoPage extends State { ///打开相册 openStorage() async { - if (await Permission.storage.isGranted) { + if (await Permission.storage.isPermanentlyDenied) { + showCupertinoDialog( + context: context, + builder: (context) { + return RequestPermission( + "assets/image/icon_storage_permission_tips.webp", + "您未开启存储权限,请点击开启", + "为了您可以在使用过程中访问您设备上的照片、媒体内容和文件,请您开启存储使用权限", + S.of(context).kaiqiquanxian, + (result) async { + if (result) { + await openAppSettings(); + } + }, + heightRatioWithWidth: 0.82, + ); + }); + }else if (await Permission.storage.isGranted) { List medias = await ImagePickers.pickerPaths( galleryMode: GalleryMode.image, selectCount: 1, @@ -435,8 +494,154 @@ class _UserInfoPage extends State { setState(() {}); fileUpload(); } else { - await Permission.storage.request(); - openStorage(); + showStorageTipsAlertDialog(context,0); + return false; + // await Permission.storage.request(); + // openStorage(); + } + } + + ///相册权限说明 + showStorageTipsAlertDialog(context,type) async { + //显示对话框 + showDialog( + context: context, + barrierDismissible: false, + barrierColor: null, + builder: (BuildContext context) { + return Column( + children: [ + Container( + width: double.infinity, + padding: EdgeInsets.all(15), + margin: EdgeInsets.all(15), + decoration: new BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding(padding:EdgeInsets.only(right: 10.w,), + child: Icon( + Icons.add_photo_alternate_outlined, + color: Colors.black, + size: 22, + )), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "存储权限使用说明", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + SizedBox( + height: 3.h, + ), + Text( + "为了帮您实现分享照片、保存照片等功能。", + style: TextStyle( + fontSize: 13.sp, + height: 1.2, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ], + ), + ), + ], + ), + ) + ], + mainAxisSize: MainAxisSize.min, + ); + }, + ); + await Permission.storage.request(); + Navigator.of(context).pop(); + if(await Permission.storage.isGranted){ + if(type == 1){ + openCamera(); + }else{ + openStorage(); + } + } + } + + ///拍照权限说明 + showCameraTipsAlertDialog(context) async { + //显示对话框 + showDialog( + context: context, + barrierDismissible: false, + barrierColor: null, + builder: (BuildContext context) { + return Column( + children: [ + Container( + width: double.infinity, + padding: EdgeInsets.all(15), + margin: EdgeInsets.all(15), + decoration: new BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding(padding:EdgeInsets.only(right: 10.w,), + child: Icon( + Icons.add_photo_alternate_outlined, + color: Colors.black, + size: 22, + )), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "相机权限使用说明", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + SizedBox( + height: 3.h, + ), + Text( + "实现您扫码、拍摄等功能。", + style: TextStyle( + fontSize: 13.sp, + height: 1.2, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ], + ), + ), + ], + ), + ) + ], + mainAxisSize: MainAxisSize.min, + ); + }, + ); + await Permission.camera.request(); + Navigator.of(context).pop(); + if(await Permission.camera.isGranted){ + openCamera(); } } diff --git a/lib/utils/location.dart b/lib/utils/location.dart index af53e6f0..4281f0df 100644 --- a/lib/utils/location.dart +++ b/lib/utils/location.dart @@ -31,7 +31,9 @@ class LocationInstance { context, Function(Position locationData) locationCallback) async { LocationPermission permissionStatus = await Geolocator.checkPermission(); if (permissionStatus == LocationPermission.denied) { - permissionStatus = await Geolocator.requestPermission(); + // permissionStatus = await Geolocator.requestPermission(); + showTipsAlertDialog(context); + return false; } if (permissionStatus == LocationPermission.denied) { showTipsAlertDialog(context); @@ -162,6 +164,7 @@ class LocationInstance { "为了向您推荐附近的门店信息,推荐您在使用期间让我们使用位置信息", style: TextStyle( fontSize: 13.sp, + height: 1.2, fontWeight: MyFontWeight.regular, color: Colors.black, ), @@ -177,7 +180,7 @@ class LocationInstance { ); }, ); - Geolocator.requestPermission(); + await Geolocator.requestPermission(); Navigator.of(context).pop(); } diff --git a/lib/view_widget/request_permission.dart b/lib/view_widget/request_permission.dart index e02beb4d..36fab958 100644 --- a/lib/view_widget/request_permission.dart +++ b/lib/view_widget/request_permission.dart @@ -74,6 +74,7 @@ class _RequestPermission extends State { widget.subText, style: TextStyle( fontSize: 12.sp, + height: 1.2, color: Color(0xFF727272), ), ),