Bladeren bron

更新分享界面

tags/0.0.1
Weller 4 jaren geleden
bovenliggende
commit
676df15498
5 gewijzigde bestanden met toevoegingen van 238 en 79 verwijderingen
  1. +1
    -1
      .dart_tool/package_config.json
  2. +48
    -48
      lib/pages/goods_share_page/goods_share_image/goods_share_image.dart
  3. +154
    -27
      lib/pages/goods_share_page/goods_share_link/goods_share_link.dart
  4. +7
    -3
      lib/pages/goods_share_page/models/goods_share_style_model.dart
  5. +28
    -0
      lib/widgets/public/custom_button/custom_bottom.dart

+ 1
- 1
.dart_tool/package_config.json Bestand weergeven

@@ -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"
}

+ 48
- 48
lib/pages/goods_share_page/goods_share_image/goods_share_image.dart Bestand weergeven

@@ -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<GoodsShareImage> {
Fluttertoast.showToast(msg: '复制成功');
},
onEditorClick: () {
Fluttertoast.showToast(msg: '正在开发中');
return;
Navigator.push(context,
MaterialPageRoute(builder: (context) => GoodsShareEditor()));
},
@@ -116,62 +120,58 @@ class _GoodsShareImageState extends State<GoodsShareImage> {
}

Widget _createBottom() {
Map<String, dynamic> shareImages = _style.cssList.shareImage;
if (shareImages == null) {
return Container();
}
CustomButtonModel btnCopy = CustomButtonModel.fromJson(
Map<String, dynamic>.from(shareImages['copy_btn']));
CustomButtonModel btnSave = CustomButtonModel.fromJson(
Map<String, dynamic>.from(shareImages['save_btn']));
CustomButtonModel btnShare = CustomButtonModel.fromJson(
Map<String, dynamic>.from(shareImages['share_btn']));
return SafeArea(
child: Container(
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4),
child: Row(
children: <Widget>[
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();
},
),
),
],
),
),


+ 154
- 27
lib/pages/goods_share_page/goods_share_link/goods_share_link.dart Bestand weergeven

@@ -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<String, dynamic> model;
@@ -14,39 +25,155 @@ class GoodsShareLink extends StatefulWidget {
}

class _GoodsShareLinkState extends State<GoodsShareLink> {
GoodsShareImageModel _style;
Map<int, String> _images = Map();
List<Widget> widgets = List();

// 分享数据
final ShareDataModel _shareModel = ShareDataModel();

@override
void initState() {
String data = widget.model['data'];
var d = convert.jsonDecode(data);
_style = GoodsShareImageModel.fromJson(Map<String, dynamic>.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: <Widget>[
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: <Widget>[
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<String, dynamic> shareImages = _style.cssList.shareLink;
if (shareImages == null) {
return Container();
}
CustomButtonModel btnCopy = CustomButtonModel.fromJson(
Map<String, dynamic>.from(shareImages['copy_btn']));
CustomButtonModel btnShare = CustomButtonModel.fromJson(
Map<String, dynamic>.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: <Widget>[
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<String> 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(),
),
);
}
}

+ 7
- 3
lib/pages/goods_share_page/models/goods_share_style_model.dart Bestand weergeven

@@ -9,6 +9,8 @@ class GoodsShareStyleModel {
String rewardImage;
String rewardText;
Map<String, dynamic> shareImage;
Map<String, dynamic> shareLink;
Map<String, dynamic> 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<String, dynamic>.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();
}


+ 28
- 0
lib/widgets/public/custom_button/custom_bottom.dart Bestand weergeven

@@ -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: <Widget>[
Text(
style.name,
style: TextStyle(
color: HexColor.fromHex(style.textColor ?? ''),
fontSize: 14,
),
)
],
),
),
),
onTap: onClick,
);


Laden…
Annuleren
Opslaan