Quellcode durchsuchen

1.变更授权弹窗样式

tags/0.0.13+6
“yanghuaxuan” vor 3 Jahren
Ursprung
Commit
38ed896fdd
4 geänderte Dateien mit 201 neuen und 16 gelöschten Zeilen
  1. +4
    -4
      example/android/app/build.gradle
  2. +7
    -3
      example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java
  3. +189
    -8
      lib/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart
  4. +1
    -1
      lib/pages/home_page/home_page.dart

+ 4
- 4
example/android/app/build.gradle Datei anzeigen

@@ -20,7 +20,7 @@ if (flutterVersionCode == null) {

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
flutterVersionName = '1.6.0'
}

// 获取当前时间(年月日)
@@ -45,15 +45,15 @@ android {
applicationId "cn.zhios.zhiying"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionCode 1618056485
versionName "10.6.0"
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
//选择要添加的对应cpu类型的.so库。
abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a'
//abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a'
// abiFilters 'armeabi-v7a','x86_64'
}
}


+ 7
- 3
example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java Datei anzeigen

@@ -158,9 +158,9 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN
public Map getSetting() {
Map map = new HashMap();
///测试
map.put("domain", "http://inapi.izhyin.cn/");//"http://120.76.175.204:8989");http://47.114.51.254:80 http://inapi.izhyin.cn/
map.put("master_id", "123456");
map.put("secret_key", "123456");
// map.put("domain", "http://inapi.izhyin.cn/");//"http://120.76.175.204:8989");http://47.114.51.254:80 http://inapi.izhyin.cn/
// map.put("master_id", "123456");
// map.put("secret_key", "123456");

///正式
// map.put("domain", "http://api.zhios.cn/");//45678910,api.zhios.cn84198689
@@ -173,6 +173,10 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN
// map.put("secret_key", "123456");

// map.put("token", "123465");

map.put("domain", "http://api.shengder.com/");//"http://120.76.175.204:8989");http://47.114.51.254:80 http://inapi.izhyin.cn/
map.put("master_id", "98130614");
map.put("secret_key", "123456");
return map;
}



+ 189
- 8
lib/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart Datei anzeigen

@@ -119,14 +119,7 @@ class NotificationSettingDialog extends StatelessWidget {
),
GestureDetector(
onTap: () async {
// 检查并请求权限
PermissionStatus status = await Permission.notification.request();
if (status == PermissionStatus.denied) {
await openAppSettings();
} else if (status != PermissionStatus.granted) {
status = await Permission.notification.request();
}
Navigator.pop(context);
Navigator.pop(context, true);
return true;
},
child: Container(
@@ -202,3 +195,191 @@ class NotificationSettingDialog extends StatelessWidget {
);
}
}

class NotificationSettingDialogNew extends StatelessWidget {
List<PermissModel> permissModels;

NotificationSettingDialogNew(this.permissModels, {Key key}) : super(key: key);

static Future show(BuildContext context, {List<PermissModel> permissModels}) async {
List<PermissModel> newPermissModels;
if (permissModels == null) {
newPermissModels = List();
if (!await Permission.storage.isGranted) {
newPermissModels.add(PermissModel(
permissType: PermissType.storage,
title: "存储权限",
subTitle: "用于缓存数据,保存图片到相册",
iconUrl: "https://alipic.lanhuapp.com/SketchPng7acf1ec3d1c3c98ba9b58d52a5d49ff3404a0b3f131100695dcd479c8dfa215b"));
}

if (!await Permission.notification.isGranted) {
newPermissModels.add(PermissModel(
permissType: PermissType.notification,
title: "通知权限",
subTitle: "用于及时告知优惠动态",
iconUrl: "https://alipic.lanhuapp.com/SketchPnga11a94a0c38949016e0fced74d683c08eaa1f58366cba616a40e51a9ebbe7146"));
}
} else {
newPermissModels = permissModels;
}
if (newPermissModels.length == 0) {
return;
}
await showCupertinoDialog(context: context, builder: (_) => NotificationSettingDialogNew(newPermissModels));
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Container(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 280,
padding: EdgeInsets.all(20),
// height: 382,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: Column(
children: <Widget>[
Text(
"申请获取权限",
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: HexColor.fromHex('#FF4242'),
),
),
SizedBox(
height: 10,
),
Text(
" \t\t\t\t\t为了保证您可以正常使用APP, 更好地为您提供服务, 我们需要向您申请获得如下权限",
style: TextStyle(fontSize: 13, color: HexColor.fromHex("#FF666666")),
),
SizedBox(
height: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: permissModels.map((e) => _createItem(e)).toList() ?? [],
),
SizedBox(
height: 20,
),
GestureDetector(
onTap: () async {
for (var item in permissModels) {
if (item.permissType == PermissType.notification) {
if (!await Permission.notification.isGranted) {
await Permission.notification.request();
if (await Permission.notification.isDenied) {
if (Platform.isAndroid) {
await NativeUtil.openAppSettings();
} else {
openAppSettings();
}
}
}
} else if (item.permissType == PermissType.storage) {
if (!await Permission.storage.isGranted) {
await Permission.storage.request();
}
if (await Permission.storage.isPermanentlyDenied) {
openAppSettings();
}
}
}
Navigator.pop(context, true);
},
child: Container(
margin: EdgeInsets.only(top: 10, bottom: 10),
height: 38,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
gradient:
LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [HexColor.fromHex("#FFFF5632"), HexColor.fromHex("#FFFF4242")])),
child: Center(
child: Text(
"确认授权",
style: TextStyle(color: Colors.white, fontSize: 13),
))),
)
],
),
),
GestureDetector(
onTap: () {
Navigator.pop(context, false);
},
child: Container(width: 30, height: 30, margin: EdgeInsets.only(top: 10), child: CloseButton(color: HexColor.fromHex("#FFFFFF"))))
],
),
),
);
}

Widget _createItem(PermissModel itemModel) {
return Container(
decoration: BoxDecoration(color: HexColor.fromHex("#FFFAFAFA"), borderRadius: BorderRadius.circular(8)),
margin: EdgeInsets.only(top: 8),
child: Padding(
padding: EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(right: 6, top: 2),
width: 27,
height: 27,
child: CachedNetworkImage(
imageUrl: itemModel?.iconUrl ?? '',
)),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
itemModel?.title ?? '',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: HexColor.fromHex('#333333'),
),
),
Text(
itemModel?.subTitle ?? '',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.normal,
color: HexColor.fromHex('#999999'),
),
),
],
),
)
],
),
),
);
}
}

class PermissModel {
String iconUrl;
String title;
String subTitle;
PermissType permissType;

PermissModel({this.iconUrl, this.title, this.subTitle, this.permissType});
}

enum PermissType { notification, storage }

+ 1
- 1
lib/pages/home_page/home_page.dart Datei anzeigen

@@ -366,7 +366,7 @@ class _HomePageState extends LifeState<HomePage> with WidgetsBindingObserver, Ti
// 通知弹窗

if (!await Permission.notification.isGranted || !await Permission.storage.isGranted) {
await NotificationSettingDialog.show(context);
await NotificationSettingDialogNew.show(context);
}

// 活动弹窗


Laden…
Abbrechen
Speichern