diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json
index 8da4c5d..5b4396d 100644
--- a/.dart_tool/package_config.json
+++ b/.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"
}
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 242424a..6a0dba0 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/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">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -17,7 +17,7 @@
-
+
@@ -26,7 +26,7 @@
-
+
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index 2f807cd..c1a0a2a 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -54,6 +54,7 @@
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
9F04BF67255F882600C4594E /* JDSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = JDSDK.bundle; sourceTree = ""; };
9F2FEDAD2520C194002374CF /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
+ 9F5F7EA525626514009BD779 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; };
9FFCE2F7251ADE0600F4F353 /* yw_1222_baichuan.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = yw_1222_baichuan.jpg; sourceTree = ""; };
9FFCE2FB251ADE0600F4F353 /* 1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 1.png; sourceTree = ""; };
9FFCE2FC251ADE0600F4F353 /* 2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = 2.png; sourceTree = ""; };
@@ -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;
diff --git a/example/ios/Runner/Runner.entitlements b/example/ios/Runner/Runner.entitlements
new file mode 100644
index 0000000..903def2
--- /dev/null
+++ b/example/ios/Runner/Runner.entitlements
@@ -0,0 +1,8 @@
+
+
+
+
+ aps-environment
+ development
+
+
diff --git a/lib/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart b/lib/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart
index 0831fba..b817cc1 100644
--- a/lib/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart
+++ b/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: [
+ Container(
+ width: 280,
+ // height: 382,
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(10),
+ ),
+ child: Column(
+ children: [
+ 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: [
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: [
- 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);
- },
)
],
),
diff --git a/lib/dialog/global_dialog/policy_dialog/policy_confirm_dialog.dart b/lib/dialog/global_dialog/policy_dialog/policy_confirm_dialog.dart
new file mode 100644
index 0000000..1ddd707
--- /dev/null
+++ b/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 {
+ @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: [
+ Text(
+ '温馨提示',
+ style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
+ child: Text('若得不到您的同意,我们将无法继续为您服务哦,您要不要在想想?'),
+ ),
+ Row(
+ children: [
+ 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,
+ ),
+ ),
+ )
+ ],
+ )
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/dialog/global_dialog/policy_dialog/policy_dialog.dart b/lib/dialog/global_dialog/policy_dialog/policy_dialog.dart
new file mode 100644
index 0000000..c0ee5ba
--- /dev/null
+++ b/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 {
+ @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: [
+ 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: [
+ 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.未经您本人授权同意,我们不会从任何第三方处获取您的信息,也不会预期分享您的信息。',
+ ),
+ ]),
+ );
+ }
+}
diff --git a/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart b/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart
index a2ce587..891602c 100644
--- a/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart
+++ b/lib/pages/goods_share_page/goods_share_image/goods_share_image.dart
@@ -357,11 +357,15 @@ class _GoodsShareImageState extends State
return;
}
+ // ============= 复制文案 =================
+ Clipboard.setData(ClipboardData(text: _content));
+
showCupertinoModalPopup(
context: context,
builder: (context) => ShareAlert(
_shareModel,
'pub.flutter.share_icon',
+ isContentShow: true,
// child: GoodsShareAlertContent(),
),
);
diff --git a/lib/pages/home_page/home_page.dart b/lib/pages/home_page/home_page.dart
index 5359e6d..7fb0fad 100644
--- a/lib/pages/home_page/home_page.dart
+++ b/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 {
}
Future _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(context, listen: false)
diff --git a/lib/widgets/others/dotted_line/dotted_line.dart b/lib/widgets/others/dotted_line/dotted_line.dart
new file mode 100644
index 0000000..8a56caf
--- /dev/null
+++ b/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,
+ );
+ },
+ );
+ }
+}
diff --git a/lib/widgets/share/models/share_alert_model.dart b/lib/widgets/share/models/share_alert_model.dart
new file mode 100644
index 0000000..d64714c
--- /dev/null
+++ b/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 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 json) {
+ if (json['list'] != null) {
+ icons = new List();
+ 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 toJson() {
+ final Map data = new Map();
+ 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;
+ }
+}
diff --git a/lib/widgets/share/share_alert.dart b/lib/widgets/share/share_alert.dart
index 653f13c..505fe6a 100644
--- a/lib/widgets/share/share_alert.dart
+++ b/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 {
+ 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 data) {
+ List modList = data['mod_list'];
+ Map d = modList.first;
+ if (d != null) {
+ String dString = d['data'];
+ _iconModel = ShareAlertModel.fromJson(
+ Map.from(jsonDecode(dString)));
+
+ setState(() {});
+ }
+ }
+
@override
Widget build(BuildContext context) {
return GestureDetector(
@@ -34,9 +68,13 @@ class ShareAlert extends StatelessWidget {
child: Column(
children: [
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 _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 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.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() ??
+ [],
);
}
diff --git a/lib/widgets/share/share_alert_content.dart b/lib/widgets/share/share_alert_content.dart
new file mode 100644
index 0000000..6c64cc5
--- /dev/null
+++ b/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: [
+ 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: [
+ 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 ?? '',
+ ),
+ ),
+ ],
+ );
+ }
+}