Przeglądaj źródła

分享

tags/0.0.1
Weller 4 lat temu
rodzic
commit
015f1f3424
19 zmienionych plików z 775 dodań i 157 usunięć
  1. +7
    -1
      .dart_tool/package_config.json
  2. +6
    -0
      example/ios/Podfile.lock
  3. +41
    -0
      lib/pages/goods_share_page/goods_share_bloc.dart
  4. +174
    -20
      lib/pages/goods_share_page/goods_share_image/goods_share_image.dart
  5. +134
    -0
      lib/pages/goods_share_page/goods_share_image/goods_share_image_model.dart
  6. +10
    -1
      lib/pages/goods_share_page/goods_share_link/goods_share_link.dart
  7. +10
    -1
      lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart
  8. +67
    -103
      lib/pages/goods_share_page/goods_share_page.dart
  9. +55
    -0
      lib/pages/goods_share_page/models/goods_share_style_model.dart
  10. +54
    -0
      lib/pages/goods_share_page/models/goods_share_temp_editor_model.dart
  11. +21
    -0
      lib/pages/goods_share_page/models/goods_share_temp_model.dart
  12. +29
    -0
      lib/pages/goods_share_page/widgets/goods_share_image.dart
  13. +70
    -25
      lib/pages/goods_share_page/widgets/goods_share_item.dart
  14. +9
    -0
      lib/utils/goods_share_temp_util/goods_share_temp_util.dart
  15. +4
    -4
      lib/widgets/goods_details/footer/goods_details_footer_widget.dart
  16. +20
    -0
      lib/widgets/public/custom_button/custom_bottom.dart
  17. +40
    -0
      lib/widgets/public/custom_button/custom_button_model.dart
  18. +22
    -2
      lib/widgets/share/share_alert.dart
  19. +2
    -0
      pubspec.yaml

+ 7
- 1
.dart_tool/package_config.json Wyświetl plik

@@ -379,6 +379,12 @@
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "share_extend",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/share_extend-1.1.9",
"packageUri": "lib/",
"languageVersion": "2.0"
},
{
"name": "shared_preferences",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12",
@@ -590,7 +596,7 @@
"languageVersion": "2.1"
}
],
"generated": "2020-09-28T02:48:13.803350Z",
"generated": "2020-09-29T06:14:15.252464Z",
"generator": "pub",
"generatorVersion": "2.7.2"
}

+ 6
- 0
example/ios/Podfile.lock Wyświetl plik

@@ -103,6 +103,8 @@ PODS:
- save_image (0.0.1):
- Flutter
- securityGuard (5.4.191)
- share_extend (0.0.1):
- Flutter
- shared_preferences (0.0.1):
- Flutter
- shared_preferences_linux (0.0.1):
@@ -184,6 +186,7 @@ DEPENDENCIES:
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
- path_provider_windows (from `.symlinks/plugins/path_provider_windows/ios`)
- save_image (from `.symlinks/plugins/save_image/ios`)
- share_extend (from `.symlinks/plugins/share_extend/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_linux (from `.symlinks/plugins/shared_preferences_linux/ios`)
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
@@ -255,6 +258,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_windows/ios"
save_image:
:path: ".symlinks/plugins/save_image/ios"
share_extend:
:path: ".symlinks/plugins/share_extend/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
shared_preferences_linux:
@@ -315,6 +320,7 @@ SPEC CHECKSUMS:
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
save_image: 1d4bdcb69832f573215c0e2971fe9e572dfc1c84
securityGuard: 9c04c44a3b663f36e15064042abfc107fa07133c
share_extend: b6748dc53695587891126a89533b862b92548c7b
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087


+ 41
- 0
lib/pages/goods_share_page/goods_share_bloc.dart Wyświetl plik

@@ -0,0 +1,41 @@
import 'dart:async';

import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class GoodsShareBloc extends BlocBase {
List<Map<String, dynamic>> _tabs;

StreamController<List<Map<String, dynamic>>> _tabController =
StreamController<List<Map<String, dynamic>>>();

Stream<List<Map<String, dynamic>>> get outData => _tabController.stream;

@override
void dispose() {
_tabController.close();
_tabController = null;
}

void loadData(String shopType) async {
NetUtil.request(
'/api/v1/mod/pub.flutter.share?share_type=${shopType.toString()}',
method: NetMethod.GET, onCache: (data) {
_loadData(data);
}, onSuccess: (data) {
_loadData(data);
});
}

void _loadData(dynamic data) {
try {
List list = Map<String, dynamic>.from(data)['mod_list'];
_tabs = list.map((item) {
return Map<String, dynamic>.from(item);
}).toList();
_tabController.add(_tabs);
} catch (err) {
Logger.error(err);
}
}
}

+ 174
- 20
lib/pages/goods_share_page/goods_share_image/goods_share_image.dart Wyświetl plik

@@ -1,45 +1,199 @@
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_image.dart';
import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_item.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart';
import 'package:zhiying_base_widget/widgets/share/share_alert.dart';

class GoodsShareImage extends StatefulWidget {
final Map<String, dynamic> model;

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

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

class _GoodsShareImageState extends State<GoodsShareImage> {
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(top: 10),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
widgets.clear();
widgets.add(GoodsShareItem(
imgHeader: _style.cssList.headerImage,
imgCheck: _style.cssList.unChooseImage,
imgCheckSelected: _style.cssList.chooseImage,
child: GoodsShareEdit(
_style.content,
onCopyClick: () {
Fluttertoast.showToast(msg: '复制成功');
},
onEditorClick: () {
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),
),
);
}
for (int index = 0; index < _style.customImage.length; index++) {
String image = _style.customImage[index];
// 分享图片
widgets.add(
GoodsShareItem(
imgHeader: _style.cssList.headerImage,
imgCheck: _style.cssList.unChooseImage,
imgCheckSelected: _style.cssList.chooseImage,
enabled: true,
child: GoodsShareImageWidget(image),
onSelected: (isSelected) {
if (_images.containsKey(index)) {
_images.remove(index);
} else {
_images[index] = image;
}
},
),
);
}

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() {
return SafeArea(
child: Container(
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4),
child: Row(
children: <Widget>[
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',
onCopyClick: () {
Fluttertoast.showToast(msg: '复制成功');
},
onEditorClick: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GoodsShareEditor()));
},
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),
),
),
),
GoodsShareItem(
child: GoodsShareMessage('点击编辑模板可以自定义分享文案哦😄😄'),
Expanded(
child: GestureDetector(
child: Container(
margin: EdgeInsets.only(left: 5),
// width: 95,
height: 36,
decoration: BoxDecoration(
color: Colors.amber,
borderRadius: BorderRadius.circular(18),
),
child: Center(
child: Text(
'分享选中素材',
style: TextStyle(color: Colors.white),
),
),
),
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(),
),
);
}
}

+ 134
- 0
lib/pages/goods_share_page/goods_share_image/goods_share_image_model.dart Wyświetl plik

@@ -0,0 +1,134 @@
import 'package:zhiying_base_widget/pages/goods_share_page/models/goods_share_style_model.dart';
import 'package:zhiying_base_widget/pages/goods_share_page/models/goods_share_temp_model.dart';

class GoodsShareImageModel {
String content;
String format;
String templateId;
List<GoodsShareTempModel> showFunList;
String isEditTemplate;
List<String> customContent;
List<String> customImage;
GoodsShareStyleModel cssList;

GoodsShareImageModel(
{this.content,
this.format,
this.templateId,
this.showFunList,
this.isEditTemplate,
this.customContent,
this.customImage,
this.cssList});

GoodsShareImageModel.fromJson(Map<String, dynamic> json) {
content = json['content'];
format = json['format'];
templateId = json['template_id'];
if (json['show_fun_list'] != null) {
showFunList = new List<GoodsShareTempModel>();
json['show_fun_list'].forEach((v) {
showFunList.add(
new GoodsShareTempModel.fromJson(Map<String, dynamic>.from(v)));
});
}
isEditTemplate = json['is_edit_template'];
customContent = json['custom_content'].cast<String>();
customImage = json['custom_image'].cast<String>();
cssList = json['css_list'] != null
? new GoodsShareStyleModel.fromJson(json['css_list'])
: null;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['content'] = this.content;
data['format'] = this.format;
data['template_id'] = this.templateId;
if (this.showFunList != null) {
data['show_fun_list'] = this.showFunList.map((v) => v.toJson()).toList();
}
data['is_edit_template'] = this.isEditTemplate;
data['custom_content'] = this.customContent;
data['custom_image'] = this.customImage;
if (this.cssList != null) {
data['css_list'] = this.cssList.toJson();
}
return data;
}
}

class ShareImage {
CopyBtn copyBtn;
CopyBtn saveBtn;
CopyBtn shareBtn;

ShareImage({this.copyBtn, this.saveBtn, this.shareBtn});

ShareImage.fromJson(Map<String, dynamic> json) {
copyBtn = json['copy_btn'] != null
? new CopyBtn.fromJson(json['copy_btn'])
: null;
saveBtn = json['save_btn'] != null
? new CopyBtn.fromJson(json['save_btn'])
: null;
shareBtn = json['share_btn'] != null
? new CopyBtn.fromJson(json['share_btn'])
: null;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.copyBtn != null) {
data['copy_btn'] = this.copyBtn.toJson();
}
if (this.saveBtn != null) {
data['save_btn'] = this.saveBtn.toJson();
}
if (this.shareBtn != null) {
data['share_btn'] = this.shareBtn.toJson();
}
return data;
}
}

class CopyBtn {
String name;
String modName;
String bgType;
String bgColor;
String bgImage;
String textColor;
String smallIcon;

CopyBtn(
{this.name,
this.modName,
this.bgType,
this.bgColor,
this.bgImage,
this.textColor,
this.smallIcon});

CopyBtn.fromJson(Map<String, dynamic> json) {
name = json['name'];
modName = json['mod_name'];
bgType = json['bg_type'];
bgColor = json['bg_color'];
bgImage = json['bg_image'];
textColor = json['text_color'];
smallIcon = json['small_icon'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['name'] = this.name;
data['mod_name'] = this.modName;
data['bg_type'] = this.bgType;
data['bg_color'] = this.bgColor;
data['bg_image'] = this.bgImage;
data['text_color'] = this.textColor;
data['small_icon'] = this.smallIcon;
return data;
}
}

+ 10
- 1
lib/pages/goods_share_page/goods_share_link/goods_share_link.dart Wyświetl plik

@@ -5,6 +5,10 @@ import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_i
import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_link_widget.dart';

class GoodsShareLink extends StatefulWidget {
final Map<String, dynamic> model;

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

@override
_GoodsShareLinkState createState() => _GoodsShareLinkState();
}
@@ -13,7 +17,12 @@ class _GoodsShareLinkState extends State<GoodsShareLink> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 10),
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,


+ 10
- 1
lib/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart Wyświetl plik

@@ -3,6 +3,10 @@ import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_i
import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_miniprogram_widget.dart';

class GoodsShareMiniprogram extends StatefulWidget {
final Map<String, dynamic> model;

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

@override
_GoodsShareMiniprogramState createState() => _GoodsShareMiniprogramState();
}
@@ -11,7 +15,12 @@ class _GoodsShareMiniprogramState extends State<GoodsShareMiniprogram> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 10),
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,


+ 67
- 103
lib/pages/goods_share_page/goods_share_page.dart Wyświetl plik

@@ -1,37 +1,51 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/goods_share_page/goods_share_bloc.dart';
import 'package:zhiying_base_widget/pages/goods_share_page/goods_share_image/goods_share_image.dart';
import 'package:zhiying_base_widget/pages/goods_share_page/goods_share_link/goods_share_link.dart';
import 'package:zhiying_base_widget/pages/goods_share_page/goods_share_miniprogram/goods_share_miniprogram.dart';
import 'package:zhiying_base_widget/pages/goods_share_page/widgets/goods_share_alert_content.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart';
import 'package:zhiying_base_widget/widgets/share/share_alert.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class GoodsSharePage extends StatefulWidget {
final Map<String, dynamic> model;

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

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

class _GoodsSharePageState extends State<GoodsSharePage>
class _GoodsSharePageState extends State<GoodsSharePage> {
@override
Widget build(BuildContext context) {
return BlocProvider<GoodsShareBloc>(
bloc: GoodsShareBloc(),
child: _GoodsShareContainer(widget.model),
);
}
}

class _GoodsShareContainer extends StatefulWidget {
final Map<String, dynamic> model;

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

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

class _GoodsShareContainerState extends State<_GoodsShareContainer>
with TickerProviderStateMixin {
GoodsShareBloc _bloc;
TabController _tabController;
List<Widget> _tabs;
List<Widget> _contents;
List<Widget> _tabs = [];
List<Widget> _contents = [];

@override
void initState() {
_tabController = TabController(length: 3, vsync: this);
_tabs = [
_createTabItem('分享图文'),
_createTabItem('分享链接'),
_createTabItem('分享小程序'),
];
_contents = [
GoodsShareImage(),
GoodsShareLink(),
GoodsShareMiniprogram(),
];
_bloc = BlocProvider.of<GoodsShareBloc>(context);
_bloc.loadData('taobao');
super.initState();
}

@@ -40,12 +54,36 @@ class _GoodsSharePageState extends State<GoodsSharePage>
return Scaffold(
backgroundColor: Color(0xfff8f8f8),
appBar: _createNav(),
body: Column(
children: <Widget>[
_createCommission(),
Expanded(child: _createContent()),
_createBottom(),
],
body: StreamBuilder<List<Map<String, dynamic>>>(
stream: _bloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) {
List<Map<String, dynamic>> list = snapshot.data;
if (list == null || list.length == 0) {
return Container();
}

_tabController = TabController(length: list.length, vsync: this);
_tabs.clear();
_contents.clear();
list.forEach((item) {
_tabs.add(_createTabItem(item['title']));
String mod_name = item['mod_name'];
if (mod_name == 'share_goods_image.taobao') {
_contents.add(GoodsShareImage(item));
} else if (mod_name == 'share_goods_link.taobao') {
_contents.add(GoodsShareLink(item));
} else if (mod_name == 'share_goods_mini.taobao') {
_contents.add(GoodsShareMiniprogram(item));
}
});

return Column(
children: <Widget>[
_createCommission(),
Expanded(child: SafeArea(child: _createContent())),
],
);
},
),
);
}
@@ -122,12 +160,16 @@ class _GoodsSharePageState extends State<GoodsSharePage>
margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4),
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
color: Colors.white, borderRadius: BorderRadius.circular(8)),
// decoration: BoxDecoration(
// color: Colors.white, borderRadius: BorderRadius.circular(8)),
child: Column(
children: <Widget>[
Container(
height: 40,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8), topRight: Radius.circular(8))),
width: double.infinity,
child: TabBar(
controller: _tabController,
@@ -147,69 +189,6 @@ class _GoodsSharePageState extends State<GoodsSharePage>
);
}

Widget _createBottom() {
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),
),
child: Center(
child: Text(
'分享选中素材',
style: TextStyle(color: Colors.white),
),
),
),
onTap: () {
_showShare();
},
),
),
],
),
),
);
}

Widget _createTabItem(String title, {bool isSelected = false}) {
return Text(
title,
@@ -220,19 +199,4 @@ class _GoodsSharePageState extends State<GoodsSharePage>
),
);
}

void _showShare() async {
showCupertinoModalPopup(
context: context,
builder: (context) => ShareAlert(
ShareDataModel(
title: 'title',
content: 'content',
image:
'https://img.alicdn.com/bao/uploaded/i1/2200818126974/O1CN01HvqWcg21O8mq9EPwf_!!0-item_pic.jpg_250x250.jpg',
url: 'http://www.hairuyi.com'),
child: GoodsShareAlertContent(),
),
);
}
}

+ 55
- 0
lib/pages/goods_share_page/models/goods_share_style_model.dart Wyświetl plik

@@ -0,0 +1,55 @@
import 'package:zhiying_base_widget/pages/goods_share_page/models/goods_share_temp_editor_model.dart';

class GoodsShareStyleModel {
String unChooseColor;
String chooseColor;
String headerImage;
String chooseImage;
String unChooseImage;
String rewardImage;
String rewardText;
Map<String, dynamic> shareImage;
GoodsShareTempEditorModel editTemplate;

GoodsShareStyleModel(
{this.unChooseColor,
this.chooseColor,
this.headerImage,
this.chooseImage,
this.unChooseImage,
this.rewardImage,
this.rewardText,
this.shareImage,
this.editTemplate});

GoodsShareStyleModel.fromJson(Map<String, dynamic> json) {
unChooseColor = json['un_choose_color'];
chooseColor = json['choose_color'];
headerImage = json['header_image'];
chooseImage = json['choose_image'];
unChooseImage = json['un_choose_image'];
rewardImage = json['reward_image'];
rewardText = json['reward_text'];
shareImage = json['share_image'];
editTemplate = GoodsShareTempEditorModel.fromJson(
Map<String, dynamic>.from(json['edit_template']));
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['un_choose_color'] = this.unChooseColor;
data['choose_color'] = this.chooseColor;
data['header_image'] = this.headerImage;
data['choose_image'] = this.chooseImage;
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;
}
if (this.editTemplate != null) {
data['edit_template'] = this.editTemplate.toJson();
}
return data;
}
}

+ 54
- 0
lib/pages/goods_share_page/models/goods_share_temp_editor_model.dart Wyświetl plik

@@ -0,0 +1,54 @@
import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_model.dart';

class GoodsShareTempEditorModel {
CustomButtonModel regainDefault;
CustomButtonModel saveTemplate1;
CustomButtonModel previewTemplate;
CustomButtonModel backEdit;
CustomButtonModel saveTemplate2;

GoodsShareTempEditorModel(
{this.regainDefault,
this.saveTemplate1,
this.previewTemplate,
this.backEdit,
this.saveTemplate2});

GoodsShareTempEditorModel.fromJson(Map<String, dynamic> json) {
regainDefault = json['regain_default'] != null
? new CustomButtonModel.fromJson(json['regain_default'])
: null;
saveTemplate1 = json['save_template1'] != null
? new CustomButtonModel.fromJson(json['save_template1'])
: null;
previewTemplate = json['preview_template'] != null
? new CustomButtonModel.fromJson(json['preview_template'])
: null;
backEdit = json['back_edit'] != null
? new CustomButtonModel.fromJson(json['back_edit'])
: null;
saveTemplate2 = json['save_template2'] != null
? new CustomButtonModel.fromJson(json['save_template2'])
: null;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.regainDefault != null) {
data['regain_default'] = this.regainDefault.toJson();
}
if (this.saveTemplate1 != null) {
data['save_template1'] = this.saveTemplate1.toJson();
}
if (this.previewTemplate != null) {
data['preview_template'] = this.previewTemplate.toJson();
}
if (this.backEdit != null) {
data['back_edit'] = this.backEdit.toJson();
}
if (this.saveTemplate2 != null) {
data['save_template2'] = this.saveTemplate2.toJson();
}
return data;
}
}

+ 21
- 0
lib/pages/goods_share_page/models/goods_share_temp_model.dart Wyświetl plik

@@ -0,0 +1,21 @@
class GoodsShareTempModel {
String name;
String val;
String temp;

GoodsShareTempModel({this.name, this.val, this.temp});

GoodsShareTempModel.fromJson(Map<String, dynamic> json) {
name = json['name'];
val = json['val'];
temp = json['temp'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['name'] = this.name;
data['val'] = this.val;
data['temp'] = this.temp;
return data;
}
}

+ 29
- 0
lib/pages/goods_share_page/widgets/goods_share_image.dart Wyświetl plik

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

class GoodsShareImageWidget extends StatelessWidget {
final String imageUrl;

const GoodsShareImageWidget(this.imageUrl, {Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 10, right: 10),
padding: EdgeInsets.only(left: 16, top: 0, right: 16, bottom: 10),
// decoration: BoxDecoration(
// color: Color(0xfff8f8f8), borderRadius: BorderRadius.circular(10)),
width: double.infinity,
child: Align(
alignment: Alignment.topLeft,
child: Container(
width: 95,
child: CachedNetworkImage(
imageUrl: imageUrl ?? '',
fit: BoxFit.fitWidth,
),
),
),
);
}
}

+ 70
- 25
lib/pages/goods_share_page/widgets/goods_share_item.dart Wyświetl plik

@@ -1,37 +1,82 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

class GoodsShareItem extends StatelessWidget {
class GoodsShareItem extends StatefulWidget {
final Widget child;
final String imgHeader;
final String imgCheck;
final String imgCheckSelected;
final bool isSelected;
final bool enabled;
final ValueChanged<bool> onSelected;

const GoodsShareItem({Key key, this.child}) : super(key: key);
const GoodsShareItem({
Key key,
this.imgHeader = '',
this.imgCheck = '',
this.imgCheckSelected = '',
this.isSelected = false,
this.enabled = true,
this.onSelected,
this.child,
}) : super(key: key);

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

class _GoodsShareItemState extends State<GoodsShareItem> {
bool _isSelected;

@override
void initState() {
_isSelected = widget.isSelected;
super.initState();
}

@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(18),
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {
_isSelected = !_isSelected;
});
if (widget.onSelected != null) {
widget.onSelected(_isSelected);
}
},
child: Container(
margin: EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: 36,
height: 36,
child: ClipRRect(
child: CachedNetworkImage(
imageUrl: widget.imgHeader,
),
borderRadius: BorderRadius.circular(18),
),
),
Expanded(
child: widget.child ?? Container(),
),
),
Expanded(
child: child ?? Container(),
),
Container(
width: 18,
height: 18,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(9),
Container(
width: 18,
height: 18,
child: Visibility(
visible: widget.enabled,
child: CachedNetworkImage(
imageUrl:
_isSelected ? widget.imgCheckSelected : widget.imgCheck,
),
),
),
),
],
],
),
),
);
}


+ 9
- 0
lib/utils/goods_share_temp_util/goods_share_temp_util.dart Wyświetl plik

@@ -0,0 +1,9 @@
class GoodsShareTempUtil {
String parseTemp(String temp, Map<String, String> values) {
values.forEach((key, value) {
temp.replaceAll(key, value);
});

return temp;
}
}

+ 4
- 4
lib/widgets/goods_details/footer/goods_details_footer_widget.dart Wyświetl plik

@@ -46,9 +46,9 @@ class _GooddsDetailsFooterContainerState
void _collectOnClick() {}

/// 分享
void _shareOnClick() {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => GoodsSharePage()));
void _shareOnClick(GoodsDetailsFooterModel model) {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => GoodsSharePage(model.toJson())));
}

/// 自购省
@@ -150,7 +150,7 @@ class _GooddsDetailsFooterContainerState
/// 分享赚,
Widget _getFxzButton(GoodsDetailsFooterModel model) {
return GestureDetector(
onTap: () => _shareOnClick(),
onTap: () => _shareOnClick(model),
child: Container(
alignment: Alignment.center,
height: 44,


+ 20
- 0
lib/widgets/public/custom_button/custom_bottom.dart Wyświetl plik

@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/public/custom_button/custom_button_model.dart';

class CustomButton extends StatelessWidget {
final CustomButtonModel style;
final VoidCallback onClick;

const CustomButton(this.style, {Key key, this.onClick}) : super(key: key);

@override
Widget build(BuildContext context) {
return GestureDetector(
child: Container(
width: double.infinity,
height: double.infinity,
),
onTap: onClick,
);
}
}

+ 40
- 0
lib/widgets/public/custom_button/custom_button_model.dart Wyświetl plik

@@ -0,0 +1,40 @@
class CustomButtonModel {
String name;
String modName;
String bgType;
String bgColor;
String bgImage;
String textColor;
String smallIcon;

CustomButtonModel(
{this.name,
this.modName,
this.bgType,
this.bgColor,
this.bgImage,
this.textColor,
this.smallIcon});

CustomButtonModel.fromJson(Map<String, dynamic> json) {
name = json['name'];
modName = json['mod_name'];
bgType = json['bg_type'];
bgColor = json['bg_color'];
bgImage = json['bg_image'];
textColor = json['text_color'];
smallIcon = json['small_icon'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['name'] = this.name;
data['mod_name'] = this.modName;
data['bg_type'] = this.bgType;
data['bg_color'] = this.bgColor;
data['bg_image'] = this.bgImage;
data['text_color'] = this.textColor;
data['small_icon'] = this.smallIcon;
return data;
}
}

+ 22
- 2
lib/widgets/share/share_alert.dart Wyświetl plik

@@ -5,6 +5,7 @@ import 'package:sharesdk_plugin/sharesdk_plugin.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_data_model.dart';
import 'package:zhiying_base_widget/widgets/share/models/share_plateform.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:share_extend/share_extend.dart';

class ShareAlert extends StatelessWidget {
final Widget child;
@@ -77,7 +78,7 @@ class _ShareAlertContent extends StatelessWidget {
),
Container(
margin:
EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
child: _createIcons(),
),
GestureDetector(
@@ -164,7 +165,7 @@ class _ShareAlertContent extends StatelessWidget {
null,
null,
null,
SSDKContentTypes.audio,
SSDKContentTypes.auto,
);
ShareSDKPlatform p = ShareSDKPlatforms.wechatSession;
switch (plateform) {
@@ -184,10 +185,29 @@ class _ShareAlertContent extends StatelessWidget {
p = ShareSDKPlatforms.sina;
break;
}
if (model.image is List && (model.image as List).length > 1) {
// p = ShareSDKPlatforms.sina;
// Share.shareFiles(model.image);
ShareExtend.share(
"share text", "text");
return;
}

SharesdkPlugin.share(p, params, (SSDKResponseState state, Map userdata,
Map contentEntity, SSDKError error) {
Logger.debug('${state}, ${error.rawData}');
});
}

// 多图分享
_shareMultipleImages() async {
// List<Asset> assetList = await MultiImagePicker.pickImages(maxImages: 5);
// var imageList = List<String>();
// for (var asset in assetList) {
// String path =
// await _writeByteToImageFile(await asset.getByteData(quality: 30));
// imageList.add(path);
// }
// ShareExtend.shareMultiple(imageList, "image", subject: "share muti image");
}
}

+ 2
- 0
pubspec.yaml Wyświetl plik

@@ -26,6 +26,8 @@ dependencies:
ref: '1.2.3+1'
# mob 分享sdk
sharesdk_plugin: ^1.2.8
# 系统分享
share_extend: ^1.1.9

dev_dependencies:
flutter_test:


Ładowanie…
Anuluj
Zapisz