diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index ebfda1c..aa553e6 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -596,7 +596,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-09-29T07:01:40.444026Z", + "generated": "2020-09-29T08:01:12.048733Z", "generator": "pub", "generatorVersion": "2.7.2" } 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 d7863de..db128b0 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 @@ -10,6 +10,8 @@ import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_a import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_edit.dart'; import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_image.dart'; import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_item.dart'; +import 'package:zhiying_base_widget/widgets/public/custom_button/custom_bottom.dart'; +import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_model.dart'; import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart'; import 'package:zhiying_base_widget/widgets/share/share_alert.dart'; @@ -51,6 +53,8 @@ class _GoodsShareImageState extends State { Fluttertoast.showToast(msg: '复制成功'); }, onEditorClick: () { + Fluttertoast.showToast(msg: '正在开发中'); + return; Navigator.push(context, MaterialPageRoute(builder: (context) => GoodsShareEditor())); }, @@ -116,62 +120,58 @@ class _GoodsShareImageState extends State { } Widget _createBottom() { + Map shareImages = _style.cssList.shareImage; + if (shareImages == null) { + return Container(); + } + CustomButtonModel btnCopy = CustomButtonModel.fromJson( + Map.from(shareImages['copy_btn'])); + CustomButtonModel btnSave = CustomButtonModel.fromJson( + Map.from(shareImages['save_btn'])); + CustomButtonModel btnShare = CustomButtonModel.fromJson( + Map.from(shareImages['share_btn'])); return SafeArea( child: Container( margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), child: Row( children: [ - Container( - width: 95, - height: 36, - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(18), - ), - child: Center( - child: Text( - '仅复制口令', - style: TextStyle(color: Colors.white), - ), - ), - ), - Container( - margin: EdgeInsets.only(left: 5), - width: 95, - height: 36, - decoration: BoxDecoration( - color: Colors.orangeAccent, - borderRadius: BorderRadius.circular(18), - ), - child: Center( - child: Text( - '保存选图', - style: TextStyle(color: Colors.white), - ), - ), - ), - Expanded( - child: GestureDetector( - child: Container( - margin: EdgeInsets.only(left: 5), - // width: 95, - height: 36, - decoration: BoxDecoration( - color: Colors.amber, - borderRadius: BorderRadius.circular(18), + btnCopy == null + ? Container() + : Container( + width: 95, + height: 36, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + ), + child: CustomButton(btnCopy)), + btnSave == null + ? Container() + : Container( + margin: EdgeInsets.only(left: 5), + width: 95, + height: 36, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + ), + child: CustomButton(btnSave), ), - child: Center( - child: Text( - '分享选中素材', - style: TextStyle(color: Colors.white), + btnShare == null + ? Container() + : Expanded( + child: GestureDetector( + child: Container( + margin: EdgeInsets.only(left: 5), + // width: 95, + height: 36, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + ), + child: CustomButton(btnShare)), + onTap: () { + _showShare(); + }, ), ), - ), - onTap: () { - _showShare(); - }, - ), - ), ], ), ), diff --git a/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart b/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart index 400f9a5..043e994 100644 --- a/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart +++ b/lib/pages/goods_share_page/goods_share_link/goods_share_link.dart @@ -1,8 +1,19 @@ +import 'dart:convert' as convert; + +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:zhiying_base_widget/pages/goods_share_page/goods_share_editor/goods_share_editor.dart'; +import 'package:zhiying_base_widget/pages/goods_share_page/goods_share_image/goods_share_image_model.dart'; import 'package:zhiying_base_widget/pages/goods_share_page/widgets/good_share_msg.dart'; +import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_alert_content.dart'; import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_edit.dart'; import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_item.dart'; import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_link_widget.dart'; +import 'package:zhiying_base_widget/widgets/public/custom_button/custom_bottom.dart'; +import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_model.dart'; +import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart'; +import 'package:zhiying_base_widget/widgets/share/share_alert.dart'; class GoodsShareLink extends StatefulWidget { final Map model; @@ -14,39 +25,155 @@ class GoodsShareLink extends StatefulWidget { } class _GoodsShareLinkState extends State { + GoodsShareImageModel _style; + Map _images = Map(); + List widgets = List(); + + // 分享数据 + final ShareDataModel _shareModel = ShareDataModel(); + + @override + void initState() { + String data = widget.model['data']; + var d = convert.jsonDecode(data); + _style = GoodsShareImageModel.fromJson(Map.from(d)); + super.initState(); + } + @override Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.only(bottom: 4), - padding: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - GoodsShareItem( - child: GoodsShareLinkWidget( - title: '小米10至尊纪念版5g手机120X变焦骁龙865小米官方旗舰店小米手机', - desc: '【原价】3999元【券后3989元【用嗨如意再省】19.74元復製(FRH51Lu9hYF', - imgGoods: '', - icon: '', - name: '智莺生活', - ), - ), - GoodsShareItem( - child: GoodsShareEdit( - '至高减600【24期免息】xiaomi/小米10Pro 5G手机骁龙865智能游戏拍照手机官方旗舰店小米10青春正品k305g现货\n\n原价】3999元\n券后价】3989元\n【用智莺生活再省】19.74元\n-------------\n復製(FRH51Lu9hYF),\n用【Tao·寳】下单\n-------------\n商品链接】\nhttp://hsrj3.cn/ps/FRH51Lu9hYF.html)\n'), - ), - GoodsShareItem( - child: GoodsShareMessage('点击编辑模板可以自定义分享文案哦😄😄'), + widgets.clear(); + widgets.add(GoodsShareItem( + imgHeader: _style.cssList.headerImage, + imgCheck: _style.cssList.unChooseImage, + imgCheckSelected: _style.cssList.chooseImage, + enabled: false, + child: GoodsShareLinkWidget( + title: '小米10至尊纪念版5g手机120X变焦骁龙865小米官方旗舰店小米手机', + desc: '【原价】3999元【券后3989元【用嗨如意再省】19.74元復製(FRH51Lu9hYF', + imgGoods: '', + icon: '', + name: '智莺生活', + ), + )); + widgets.add(GoodsShareItem( + imgHeader: _style.cssList.headerImage, + imgCheck: _style.cssList.unChooseImage, + imgCheckSelected: _style.cssList.chooseImage, + enabled: false, + child: GoodsShareEdit( + _style.content, + onCopyClick: () { + Fluttertoast.showToast(msg: '复制成功'); + }, + onEditorClick: () { + Fluttertoast.showToast(msg: '正在开发中'); + return; + Navigator.push(context, + MaterialPageRoute(builder: (context) => GoodsShareEditor())); + }, + ), + onSelected: (isSelected) { + _shareModel.content = isSelected ? '' : _style.content; + }, + )); + for (String message in _style.customContent) { + widgets.add( + GoodsShareItem( + imgHeader: _style.cssList.headerImage, + imgCheck: _style.cssList.unChooseImage, + imgCheckSelected: _style.cssList.chooseImage, + enabled: false, + child: GoodsShareMessage(message), + ), + ); + } + + return Column( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(bottom: 4), + padding: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(8), + bottomRight: Radius.circular(8))), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: widgets), ), + ), + ), + _createBottom(), + ], + ); + } + + Widget _createBottom() { + Map shareImages = _style.cssList.shareLink; + if (shareImages == null) { + return Container(); + } + CustomButtonModel btnCopy = CustomButtonModel.fromJson( + Map.from(shareImages['copy_btn'])); + CustomButtonModel btnShare = CustomButtonModel.fromJson( + Map.from(shareImages['share_btn'])); + return SafeArea( + child: Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + btnCopy == null + ? Container() + : Container( + width: 110, + height: 36, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + ), + child: CustomButton(btnCopy)), + btnShare == null + ? Container() + : GestureDetector( + child: Container( + margin: EdgeInsets.only(left: 5), + width: 110, + height: 36, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + ), + child: CustomButton(btnShare)), + onTap: () { + _showShare(); + }, + ), ], ), ), ); } + + void _showShare() async { + List images = List(); + for (int index = 0; index < _style.customImage.length; index++) { + if (_images.containsKey(index)) { + images.add(_images[index]); + } + } + if (images.length >= 0) { + _shareModel.image = images; + } + showCupertinoModalPopup( + context: context, + builder: (context) => ShareAlert( + _shareModel, + child: GoodsShareAlertContent(), + ), + ); + } } diff --git a/lib/pages/goods_share_page/models/goods_share_style_model.dart b/lib/pages/goods_share_page/models/goods_share_style_model.dart index 7d409ae..5d078cd 100644 --- a/lib/pages/goods_share_page/models/goods_share_style_model.dart +++ b/lib/pages/goods_share_page/models/goods_share_style_model.dart @@ -9,6 +9,8 @@ class GoodsShareStyleModel { String rewardImage; String rewardText; Map shareImage; + Map shareLink; + Map shareMini; GoodsShareTempEditorModel editTemplate; GoodsShareStyleModel( @@ -31,6 +33,8 @@ class GoodsShareStyleModel { rewardImage = json['reward_image']; rewardText = json['reward_text']; shareImage = json['share_image']; + shareLink = json['share_link']; + shareMini = json['share_mini']; editTemplate = GoodsShareTempEditorModel.fromJson( Map.from(json['edit_template'])); } @@ -44,9 +48,9 @@ class GoodsShareStyleModel { data['un_choose_image'] = this.unChooseImage; data['reward_image'] = this.rewardImage; data['reward_text'] = this.rewardText; - if (this.shareImage != null) { - data['share_image'] = this.shareImage; - } + data['share_image'] = this.shareImage; + data['share_link'] = this.shareLink; + data['share_mini'] = this.shareMini; if (this.editTemplate != null) { data['edit_template'] = this.editTemplate.toJson(); } diff --git a/lib/widgets/public/custom_button/custom_bottom.dart b/lib/widgets/public/custom_button/custom_bottom.dart index b7d8836..d20146c 100644 --- a/lib/widgets/public/custom_button/custom_bottom.dart +++ b/lib/widgets/public/custom_button/custom_bottom.dart @@ -1,5 +1,7 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_model.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; class CustomButton extends StatelessWidget { final CustomButtonModel style; @@ -9,10 +11,36 @@ class CustomButton extends StatelessWidget { @override Widget build(BuildContext context) { + var decoration = BoxDecoration( + color: HexColor.fromHex(style.bgColor ?? ''), + borderRadius: BorderRadius.circular(50)); + if (style.bgType == 'image') { + decoration = BoxDecoration( + image: DecorationImage( + image: CachedNetworkImageProvider(style.bgImage ?? ''), + fit: BoxFit.cover), + borderRadius: BorderRadius.circular(50)); + } return GestureDetector( child: Container( width: double.infinity, height: double.infinity, + decoration: decoration, + child: Center( + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + style.name, + style: TextStyle( + color: HexColor.fromHex(style.textColor ?? ''), + fontSize: 14, + ), + ) + ], + ), + ), ), onTap: onClick, );