瀏覽代碼

添加协议弹窗逻辑

更新商品分享
tags/0.0.2+7
Weller 4 年之前
父節點
當前提交
5c6e7f54e7
共有 14 個檔案被更改,包括 673 行新增81 行删除
  1. +1
    -1
      .dart_tool/package_config.json
  2. +21
    -0
      example/android/app/src/main/AndroidManifest.xml
  3. +4
    -4
      example/android/tmpmob/ShareSDK/assets/ShareSDK.xml
  4. +5
    -0
      example/ios/Runner.xcodeproj/project.pbxproj
  5. +8
    -0
      example/ios/Runner/Runner.entitlements
  6. +135
    -38
      lib/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart
  7. +81
    -0
      lib/dialog/global_dialog/policy_dialog/policy_confirm_dialog.dart
  8. +128
    -0
      lib/dialog/global_dialog/policy_dialog/policy_dialog.dart
  9. +4
    -0
      lib/pages/goods_share_page/goods_share_image/goods_share_image.dart
  10. +26
    -2
      lib/pages/home_page/home_page.dart
  11. +43
    -0
      lib/widgets/others/dotted_line/dotted_line.dart
  12. +57
    -0
      lib/widgets/share/models/share_alert_model.dart
  13. +50
    -36
      lib/widgets/share/share_alert.dart
  14. +110
    -0
      lib/widgets/share/share_alert_content.dart

+ 1
- 1
.dart_tool/package_config.json 查看文件

@@ -650,7 +650,7 @@
"languageVersion": "2.8"
}
],
"generated": "2020-11-16T05:49:00.255241Z",
"generated": "2020-11-16T07:14:17.614805Z",
"generator": "pub",
"generatorVersion": "2.8.2"
}

+ 21
- 0
example/android/app/src/main/AndroidManifest.xml 查看文件

@@ -3,6 +3,27 @@
xmlns:tools="http://schemas.android.com/tools"
package="cn.zhios.zhiying_base_widget_example">

<!-- 网络 状态变化等信息 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- IMEI等基础信息 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.Manifest.permission.READ_PHONE_STATE" />

<!-- 授权 发现jd app -->
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />

<!-- 静态化资源 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.CAMERA" />
<!-- 相机 -->
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

<application
android:name="io.flutter.app.FlutterApplication"
android:icon="@mipmap/ic_launcher"


+ 4
- 4
example/android/tmpmob/ShareSDK/assets/ShareSDK.xml 查看文件

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<DevInfor>
<SinaWeibo Enable="false" />
<SinaWeibo Enable="true" />
<TencentWeibo Enable="false" />
<Douban Enable="false" />
<QZone Enable="false" />
<QZone Enable="true" />
<Renren Enable="false" />
<KaiXin Enable="false" />
<Facebook Enable="false" />
@@ -17,7 +17,7 @@
<Email Enable="false" />
<ShortMessage Enable="false" />
<Wechat Enable="false" />
<WechatMoments Enable="false" />
<WechatMoments Enable="true" />
<QQ AppId="1111030588" AppKey="XoHKlrBybXy7ORBt" ShareByAppClient="true" BypassApproval="false" Enable="true" />
<Instapaper Enable="false" />
<Pocket Enable="false" />
@@ -26,7 +26,7 @@
<Flickr Enable="false" />
<Dropbox Enable="false" />
<VKontakte Enable="false" />
<WechatFavorite Enable="false" />
<WechatFavorite Enable="true" />
<Yixin Enable="false" />
<YixinMoments Enable="false" />
<Mingdao Enable="false" />


+ 5
- 0
example/ios/Runner.xcodeproj/project.pbxproj 查看文件

@@ -54,6 +54,7 @@
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9F04BF67255F882600C4594E /* JDSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = JDSDK.bundle; sourceTree = "<group>"; };
9F2FEDAD2520C194002374CF /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
9F5F7EA525626514009BD779 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
9FFCE2F7251ADE0600F4F353 /* yw_1222_baichuan.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = yw_1222_baichuan.jpg; sourceTree = "<group>"; };
9FFCE2FB251ADE0600F4F353 /* 1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 1.png; sourceTree = "<group>"; };
9FFCE2FC251ADE0600F4F353 /* 2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 2.png; sourceTree = "<group>"; };
@@ -120,6 +121,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
9F5F7EA525626514009BD779 /* Runner.entitlements */,
9FFCE2F3251ADE0600F4F353 /* 项目资源 */,
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
@@ -442,6 +444,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 3EC5G67BTK;
@@ -581,6 +584,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 3EC5G67BTK;
@@ -614,6 +618,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 3EC5G67BTK;


+ 8
- 0
example/ios/Runner/Runner.entitlements 查看文件

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>

+ 135
- 38
lib/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart 查看文件

@@ -1,6 +1,8 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class NotificationSettingDialog extends StatefulWidget {
@override
@@ -27,52 +29,147 @@ class _NotificationSettingDialogContainerState
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
body: Container(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 280,
// height: 382,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: Column(
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10)),
child: CachedNetworkImage(
imageUrl:
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1456601714,1347673110&fm=26&gp=0.jpg',
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'开启推送通知',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: HexColor.fromHex('#F94400'),
),
),
),
Padding(
padding:
const EdgeInsets.only(left: 8.0, right: 8.0, bottom: 4),
child: Text(
'接收服务提醒',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.normal,
color: HexColor.fromHex('#F94400'),
),
),
),
_createItem(),
_createItem(),
_createItem(),
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();
}
// if (status == PermissionStatus.denied) {
// Fluttertoast.showToast(msg: '暂无权限');
// return null;
// }
Navigator.pop(context);
return true;
},
child: Container(
margin: EdgeInsets.only(top: 10, bottom: 20),
width: 120,
height: 30,
decoration: BoxDecoration(
color: Colors.redAccent,
borderRadius: BorderRadius.circular(15),
),
),
)
],
),
),
GestureDetector(
child: Container(
width: 30,
height: 30,
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
color: Color(0x70606060),
borderRadius: BorderRadius.circular(15),
),
child: Center(
child: Icon(
Icons.close,
color: Colors.white,
),
),
),
onTap: () {
Navigator.pop(context);
},
)
],
),
),
);
}

Widget _createItem() {
return Padding(
padding: EdgeInsets.only(left: 30, right: 30, top: 4, bottom: 4),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: 280,
// height: 382,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
margin: EdgeInsets.only(right: 6, top: 2),
width: 20,
height: 20,
color: Colors.redAccent,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10)),
child: CachedNetworkImage(
imageUrl:
'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1456601714,1347673110&fm=26&gp=0.jpg',
Text(
'补贴到账通知',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: HexColor.fromHex('#333333'),
),
),
Text('开启推送通知'),
],
),
),
GestureDetector(
child: Container(
width: 30,
height: 30,
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
color: Color(0x70606060),
borderRadius: BorderRadius.circular(15),
),
child: Center(
child: Icon(
Icons.close,
color: Colors.white,
Text(
'定时为您推荐热门内容, 不再错过好货',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.normal,
color: HexColor.fromHex('#999999'),
),
),
),
],
),
onTap: () {
Navigator.pop(context);
},
)
],
),


+ 81
- 0
lib/dialog/global_dialog/policy_dialog/policy_confirm_dialog.dart 查看文件

@@ -0,0 +1,81 @@
import 'package:flutter/material.dart';

class PolicyConfirmDialog extends StatefulWidget {
@override
_PolicyConfirmDialogState createState() => _PolicyConfirmDialogState();
}

class _PolicyConfirmDialogState extends State<PolicyConfirmDialog> {
@override
Widget build(BuildContext context) {
return _PolicyConfirmDialogContainer();
}
}

class _PolicyConfirmDialogContainer extends StatefulWidget {
@override
_PolicyConfirmDialogContainerState createState() =>
_PolicyConfirmDialogContainerState();
}

class _PolicyConfirmDialogContainerState
extends State<_PolicyConfirmDialogContainer> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: UnconstrainedBox(
child: Container(
padding: EdgeInsets.all(15),
width: 290,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(13), color: Colors.white),
child: Column(
children: <Widget>[
Text(
'温馨提示',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Text('若得不到您的同意,我们将无法继续为您服务哦,您要不要在想想?'),
),
Row(
children: <Widget>[
Expanded(
child: GestureDetector(
onTap: () {
Navigator.pop(context, false);
},
child: Container(
height: 36,
color: Colors.redAccent,
child: Text('仍不同意'),
),
),
),
Container(
width: 30,
),
Expanded(
child: GestureDetector(
onTap: () {
Navigator.pop(context, true);
},
child: Container(
height: 36,
color: Colors.redAccent,
),
),
)
],
)
],
),
),
),
),
);
}
}

+ 128
- 0
lib/dialog/global_dialog/policy_dialog/policy_dialog.dart 查看文件

@@ -0,0 +1,128 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class PolicyDialog extends StatefulWidget {
@override
_PolicyDialogState createState() => _PolicyDialogState();
}

class _PolicyDialogState extends State<PolicyDialog> {
@override
Widget build(BuildContext context) {
return _PolicyDialogContainer();
}
}

class _PolicyDialogContainer extends StatefulWidget {
@override
_PolicyDialogContainerState createState() => _PolicyDialogContainerState();
}

class _PolicyDialogContainerState extends State<_PolicyDialogContainer> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Center(
child: Container(
padding: EdgeInsets.all(15),
width: 290,
height: 360,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(13), color: Colors.white),
child: Column(
children: <Widget>[
Text(
'温馨提示',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: SingleChildScrollView(
child: _createText(),
),
),
),
Row(
children: <Widget>[
Expanded(
child: GestureDetector(
onTap: () {
Navigator.pop(context, false);
},
child: Container(
height: 36,
color: Colors.redAccent,
),
),
),
Container(
width: 30,
),
Expanded(
child: GestureDetector(
onTap: () {
Navigator.pop(context, true);
},
child: Container(
height: 36,
color: Colors.redAccent,
),
),
)
],
)
],
),
),
),
);
}

Widget _createText() {
return RichText(
textAlign: TextAlign.left,
text: TextSpan(
text: '',
style: TextStyle(
height: 1.2,
fontSize: 12,
color: HexColor.fromHex('#555555'),
),
children: [
TextSpan(
text: '亲爱的用户,感谢您对智莺生活的信任!\n\n我们根据最新的监管政策要求,我们更新了',
),
TextSpan(
text: '《用户协议》',
recognizer: TapGestureRecognizer()
..onTap = () {
NativeUtil.openUrl(context, 'http://www.baidu.com');
},
style: TextStyle(
color: HexColor.fromHex('#FF4242'),
),
),
TextSpan(
text: '和',
),
TextSpan(
text: '《隐私权政策》',
style: TextStyle(
color: HexColor.fromHex('#FF4242'),
),
recognizer: TapGestureRecognizer()
..onTap = () {
NativeUtil.openUrl(context, 'http://www.baidu.com');
},
),
TextSpan(
text:
',请您在点击「同意」之前仔细阅读并充分理解。\n\n为了提供更好的服务,我们在特此说明:\n\n1.在您授权通过的情况下,我们将获取您的设备、位置等信息。您有权拒绝或取消授权;\n\n2.系统的安全保障措施,会严密的保护您的个人信息;\n\n3.未经您本人授权同意,我们不会从任何第三方处获取您的信息,也不会预期分享您的信息。',
),
]),
);
}
}

+ 4
- 0
lib/pages/goods_share_page/goods_share_image/goods_share_image.dart 查看文件

@@ -357,11 +357,15 @@ class _GoodsShareImageState extends State<GoodsShareImage>
return;
}

// ============= 复制文案 =================
Clipboard.setData(ClipboardData(text: _content));

showCupertinoModalPopup(
context: context,
builder: (context) => ShareAlert(
_shareModel,
'pub.flutter.share_icon',
isContentShow: true,
// child: GoodsShareAlertContent(),
),
);


+ 26
- 2
lib/pages/home_page/home_page.dart 查看文件

@@ -1,10 +1,14 @@
import 'dart:convert' as convert;
import 'dart:io';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_confirm_dialog.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_comm/models/base/base_tab_model.dart';
import 'package:zhiying_comm/util/image_util.dart';
@@ -130,8 +134,28 @@ class _HomePageState extends State<HomePage> {
}

Future<bool> _checkLimit(BaseTabModel model) async {
showCupertinoDialog(
context: context, builder: (_) => NotificationSettingDialog());
// bool agree = null;
// while (agree == null) {
// agree = await showCupertinoDialog(
// context: context, builder: (_) => PolicyDialog());
// }
// if (!agree) {
// bool accept = null;
// while (accept == null) {
// accept = await showCupertinoDialog(
// context: context, builder: (_) => PolicyConfirmDialog());
// }
// if (!accept) {
// exit(0);
// }
// }
//
// PermissionStatus status = await Permission.notification.status;
// if (status != PermissionStatus.granted) {
// await showCupertinoDialog(
// context: context, builder: (_) => NotificationSettingDialog());
// }

if (model.requiredLogin == '1') {
UserInfoModel user =
await Provider.of<UserInfoNotifier>(context, listen: false)


+ 43
- 0
lib/widgets/others/dotted_line/dotted_line.dart 查看文件

@@ -0,0 +1,43 @@
import 'package:flutter/material.dart';

/// 虚线绘制
class DottedLine extends StatelessWidget {
final double height;
final double width;
final Color color;
final Axis direction;

const DottedLine({
this.height = 1,
this.width = 10,
this.color = Colors.black,
this.direction = Axis.horizontal,
});

@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
final boxWidth = direction == Axis.horizontal
? constraints.constrainWidth()
: constraints.constrainHeight();
final dashWidth = width;
final dashHeight = height;
final dashCount = (boxWidth / (2 * dashWidth)).floor();
return Flex(
children: List.generate(dashCount, (_) {
return SizedBox(
width: direction == Axis.horizontal ? dashWidth : dashHeight,
height: direction == Axis.horizontal ? dashHeight : dashWidth,
child: DecoratedBox(
decoration: BoxDecoration(color: color),
),
);
}),
mainAxisAlignment: MainAxisAlignment.spaceBetween,
direction: direction,
);
},
);
}
}

+ 57
- 0
lib/widgets/share/models/share_alert_model.dart 查看文件

@@ -0,0 +1,57 @@
import 'package:zhiying_base_widget/widgets/share/models/share_icon_model.dart';

class ShareAlertModel {
List<ShareIconModel> icons;
String selectIcon;
String selectImg;
String selectTextImg;
String successImg;
String sucText;
String sucTips;
String selectText1;
String selectText2;

ShareAlertModel(
{this.icons,
this.selectIcon,
this.selectImg,
this.selectTextImg,
this.successImg,
this.sucText,
this.sucTips,
this.selectText1,
this.selectText2});

ShareAlertModel.fromJson(Map<String, dynamic> json) {
if (json['list'] != null) {
icons = new List<ShareIconModel>();
json['list'].forEach((v) {
icons.add(new ShareIconModel.fromJson(v));
});
}
selectIcon = json['select_icon'];
selectImg = json['select_img'];
selectTextImg = json['select_text_img'];
successImg = json['success_img'];
sucText = json['suc_text'];
sucTips = json['suc_tips'];
selectText1 = json['select_text1'];
selectText2 = json['select_text2'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.icons != null) {
data['list'] = this.icons.map((v) => v.toJson()).toList();
}
data['select_icon'] = this.selectIcon;
data['select_img'] = this.selectImg;
data['select_text_img'] = this.selectTextImg;
data['success_img'] = this.successImg;
data['suc_text'] = this.sucText;
data['suc_tips'] = this.sucTips;
data['select_text1'] = this.selectText1;
data['select_text2'] = this.selectText2;
return data;
}
}

+ 50
- 36
lib/widgets/share/share_alert.dart 查看文件

@@ -11,18 +11,52 @@ import 'package:share_extend/share_extend.dart';
import 'package:sharesdk_plugin/sharesdk_plugin.dart';
import 'package:zhiying_base_widget/dialog/loading/loading.dart';
import 'package:zhiying_base_widget/utils/image_download_util/image_download_util.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_alert_model.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_icon_model.dart';
import 'package:zhiying_base_widget/widgets/share/share_alert_content.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class ShareAlert extends StatelessWidget {
class ShareAlert extends StatefulWidget {
final String skipIdentifier;
final Widget child;
final bool isContentShow;
final ShareDataModel model;

const ShareAlert(this.model, this.skipIdentifier, {Key key, this.child})
const ShareAlert(this.model, this.skipIdentifier,
{Key key, this.isContentShow = false})
: super(key: key); // 中间视图

@override
_ShareAlertState createState() => _ShareAlertState();
}

class _ShareAlertState extends State<ShareAlert> {
ShareAlertModel _iconModel;

@override
void initState() {
NetUtil.request('/api/v1/mod/${widget.skipIdentifier}',
method: NetMethod.GET, onCache: (data) {
_parseData(data);
}, onSuccess: (data) {
_parseData(data);
}, onError: (err) {});

super.initState();
}

void _parseData(Map<String, dynamic> data) {
List modList = data['mod_list'];
Map d = modList.first;
if (d != null) {
String dString = d['data'];
_iconModel = ShareAlertModel.fromJson(
Map<String, dynamic>.from(jsonDecode(dString)));

setState(() {});
}
}

@override
Widget build(BuildContext context) {
return GestureDetector(
@@ -34,9 +68,13 @@ class ShareAlert extends StatelessWidget {
child: Column(
children: <Widget>[
Expanded(
child: Center(child: child ?? Container()),
child: Center(
child: widget.isContentShow
? ShareAlertContent(_iconModel)
: Container()),
),
_ShareAlertContent(this.model, this.skipIdentifier),
_ShareAlertContent(
widget.model, widget.skipIdentifier, _iconModel),
],
),
), // 模糊化
@@ -52,8 +90,10 @@ class ShareAlert extends StatelessWidget {
class _ShareAlertContent extends StatefulWidget {
final ShareDataModel model;
final String skipIdentifier;
final ShareAlertModel iconModel;

const _ShareAlertContent(this.model, this.skipIdentifier, {Key key})
const _ShareAlertContent(this.model, this.skipIdentifier, this.iconModel,
{Key key})
: super(key: key);

@override
@@ -61,33 +101,6 @@ class _ShareAlertContent extends StatefulWidget {
}

class _ShareAlertContentState extends State<_ShareAlertContent> {
List<ShareIconModel> _icons = [];

@override
void initState() {
NetUtil.request('/api/v1/mod/${widget.skipIdentifier}',
method: NetMethod.GET, onCache: (data) {
_parseData(data);
}, onSuccess: (data) {
_parseData(data);
}, onError: (err) {});

super.initState();
}

void _parseData(Map<String, dynamic> data) {
List modList = data['mod_list'];
Map d = modList.first;
if (d != null) {
String dString = d['data'];
List list = jsonDecode(dString)['list'];
_icons = list.map((item) {
return ShareIconModel.fromJson(Map<String, dynamic>.from(item));
}).toList();
setState(() {});
}
}

@override
Widget build(BuildContext context) {
return GestureDetector(
@@ -157,9 +170,10 @@ class _ShareAlertContentState extends State<_ShareAlertContent> {
return Wrap(
spacing: 10,
runSpacing: 10,
children: _icons.map((item) {
return _createIcon(item);
}).toList(),
children: widget.iconModel?.icons?.map((item) {
return _createIcon(item);
})?.toList() ??
[],
);
}



+ 110
- 0
lib/widgets/share/share_alert_content.dart 查看文件

@@ -0,0 +1,110 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/others/dotted_line/dotted_line.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_alert_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class ShareAlertContent extends StatelessWidget {
final ShareAlertModel model;

const ShareAlertContent(this.model, {Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return SafeArea(
child: Center(
child: UnconstrainedBox(
child: Container(
padding: EdgeInsets.all(14),
width: 220,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: Column(
children: <Widget>[
Container(
width: 92,
height: 92,
margin: EdgeInsets.only(top: 10),
child: CachedNetworkImage(
imageUrl: model?.successImg ?? '',
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
model?.sucText ?? '',
style: TextStyle(
color: HexColor.fromHex('#333333'),
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.only(top: 4, left: 30, right: 30),
child: Text(
model?.sucTips ?? '',
textAlign: TextAlign.center,
style: TextStyle(
color: HexColor.fromHex('#999999'),
fontSize: 11,
fontWeight: FontWeight.normal,
),
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: _createLine(
model?.selectImg ?? '', model?.selectText1 ?? ''),
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: _createLine(
model?.selectTextImg ?? '', model?.selectText2 ?? ''),
),
],
),
),
),
),
);
}

Widget _createLine(String imgUrl, String text) {
return Row(
children: <Widget>[
Container(
width: 12,
height: 12,
// color: Colors.redAccent,
child: CachedNetworkImage(
imageUrl: imgUrl ?? '',
),
),
Padding(
padding: const EdgeInsets.only(left: 4, right: 4),
child: Text(
text ?? '',
style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')),
),
),
Expanded(
child: DottedLine(
width: 2,
height: 0.5,
color: HexColor.fromHex('#a8a8a8'),
)),
Container(
margin: EdgeInsets.only(left: 6),
width: 15,
height: 15,
child: CachedNetworkImage(
imageUrl: model?.selectIcon ?? '',
),
),
],
);
}
}

Loading…
取消
儲存