Bläddra i källkod

添加商品分享模板

tags/0.0.1
Weller 4 år sedan
förälder
incheckning
885ae63bbf
6 ändrade filer med 357 tillägg och 5 borttagningar
  1. +7
    -1
      .dart_tool/package_config.json
  2. +59
    -0
      lib/pages/favorite_page.dart
  3. +2
    -4
      lib/pages/launch_page/launch_page.dart
  4. +2
    -0
      lib/register.dart
  5. +286
    -0
      lib/template/goods_share_template/goods_share_template.dart
  6. +1
    -0
      pubspec.yaml

+ 7
- 1
.dart_tool/package_config.json Visa fil

@@ -235,6 +235,12 @@
"packageUri": "lib/",
"languageVersion": "1.20"
},
{
"name": "image_gallery_saver",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/image_gallery_saver-1.5.0",
"packageUri": "lib/",
"languageVersion": "2.1"
},
{
"name": "image_picker",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.7+11",
@@ -578,7 +584,7 @@
"languageVersion": "2.1"
}
],
"generated": "2020-09-27T08:39:36.051865Z",
"generated": "2020-09-27T11:21:02.505016Z",
"generator": "pub",
"generatorVersion": "2.7.2"
}

+ 59
- 0
lib/pages/favorite_page.dart Visa fil

@@ -0,0 +1,59 @@
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:zhiying_base_widget/template/goods_share_template/goods_share_template.dart';

import 'package:image_gallery_saver/image_gallery_saver.dart';

class FavoritePage extends StatefulWidget {
@override
_FavoritePageState createState() => _FavoritePageState();
}

class _FavoritePageState extends State<FavoritePage> {
GlobalKey globalKey = GlobalKey();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('收藏夹'),
),
body: Column(
children: <Widget>[
Container(
width: 100,
height: 200,
child: Transform.scale(
scale: 0.2, child: GoodsShareTemplate(key: globalKey)),
),
FlatButton(
child: Icon(Icons.add),
onPressed: () async {
BuildContext buildContext = globalKey.currentContext;

if (null != buildContext) {
RenderRepaintBoundary boundary =
buildContext.findRenderObject();
var image = await boundary.toImage();
ByteData byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
// final result = await ImageGallerySaver.saveImage(
// byteData.buffer.asUint8List());
// var response = await Dio().get(
// "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a62e824376d98d1069d40a31113eb807/838ba61ea8d3fd1fc9c7b6853a4e251f94ca5f46.jpg",
// options: Options(responseType: ResponseType.bytes));
// final result = await ImageGallerySaver.saveImage(
// Uint8List.fromList(image),
// quality: 60,
// name: "hello");
// print(result);
}
},
)
],
),
);
}
}

+ 2
- 4
lib/pages/launch_page/launch_page.dart Visa fil

@@ -1,8 +1,8 @@
import 'package:connectivity/connectivity.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/home_page/home_page.dart';
import 'package:zhiying_comm/util/application.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:connectivity/connectivity.dart';

// 启动页,页面初始化等操作~跟原生启动页保持一致,防止白屏问题
class LaunchPage extends StatefulWidget {
@@ -35,16 +35,14 @@ class _LaunchPageState extends State<LaunchPage> {
Logger.error(err);
});
} else {
Logger.debug('unknow');
Logger.error('未知网络,APP初始化失败');
print('unknow');
}
});


super.initState();
}


@override
Widget build(BuildContext context) {
return Scaffold(


+ 2
- 0
lib/register.dart Visa fil

@@ -1,3 +1,4 @@
import 'package:zhiying_base_widget/pages/favorite_page.dart';
import 'package:zhiying_base_widget/pages/goods_details_page/goods_details_page.dart';
import 'package:zhiying_base_widget/pages/invited_friends/invited_friends.dart';
import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart';
@@ -97,6 +98,7 @@ class BaseWidgetRegister {
// 邀请好友
PageFactory.regist(
'pub.flutter.invite_friends', (model) => InvitedFriendsPage(model));
PageFactory.regist('pub.flutter.fav', (model) => FavoritePage());
}

// 注册控件


+ 286
- 0
lib/template/goods_share_template/goods_share_template.dart Visa fil

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

// 商品详情分享,合成模板
class GoodsShareTemplate extends StatelessWidget {
const GoodsShareTemplate({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return OverflowBox(
maxHeight: double.infinity,
maxWidth: 375,
child: Container(
width: double.infinity,
padding: EdgeInsets.all(20),
color: Colors.white,
child: Column(
children: <Widget>[
_createHeader(),
_createImage(),
_createBottom(),
],
),
),
);
}

Widget _createHeader() {
return Row(
children: <Widget>[
Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color: Colors.redAccent, borderRadius: BorderRadius.circular(15)),
),
Expanded(
child: Container(
margin: EdgeInsets.only(left: 10, right: 10),
height: 30,
width: 80,
color: Colors.redAccent,
),
),
Container(
padding: EdgeInsets.only(left: 10, right: 10, top: 8, bottom: 8),
decoration: BoxDecoration(
color: Color(0xfff7f7f7),
borderRadius: BorderRadius.circular(30)),
child: Text(
'邀请码 SDWE45',
style: TextStyle(fontSize: 11, fontWeight: FontWeight.bold),
),
)
],
);
}

Widget _createImage() {
return AspectRatio(
aspectRatio: 1,
child: Container(
margin: EdgeInsets.only(top: 20, bottom: 20),
width: double.infinity,
color: Colors.redAccent,
),
);
}

Widget _createBottom() {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Container(
margin: EdgeInsets.only(right: 20),
height: 160,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_createTitle(),
Expanded(
child: Container(),
),
_createLeftBottom()
],
),
),
),
Column(
children: <Widget>[
Container(
margin: EdgeInsets.only(bottom: 12),
width: 124,
height: 124,
color: Colors.redAccent,
),
Container(
child: Row(
children: <Widget>[
Container(
width: 14,
height: 16,
color: Colors.redAccent,
margin: EdgeInsets.only(right: 4),
),
Text(
'长按识别领取优惠',
style: TextStyle(
fontSize: 11,
color: Color(0xffb3b3b3),
),
),
],
),
)
],
),
],
);
}

Widget _createTitle() {
List<InlineSpan> list = List();
list.add(WidgetSpan(
child: Container(
padding: EdgeInsets.only(left: 2, right: 2, top: 3, bottom: 3),
margin: EdgeInsets.only(right: 4),
child: Text(
'淘宝',
style: TextStyle(
fontSize: 9,
height: 1,
color: Colors.white,
),
),
decoration: BoxDecoration(
color: Colors.redAccent, borderRadius: BorderRadius.circular(2.5)),
),
));
list.add(TextSpan(
text: '小米10至尊纪念版5g手机120X变焦骁龙865小米官方旗舰店小米手机',
style: TextStyle(
fontSize: 14,
color: HexColor.fromHex('#333333'),
fontWeight: FontWeight.bold),
));
return RichText(
maxLines: 3,
overflow: TextOverflow.ellipsis,
text: TextSpan(children: list),
);
}

Widget _createLeftBottom() {
return Row(
children: <Widget>[
Column(
children: <Widget>[
Container(
margin: EdgeInsets.only(right: 5),
padding: EdgeInsets.only(left: 10, right: 10, top: 3, bottom: 3),
decoration: BoxDecoration(
color: Colors.redAccent,
borderRadius: BorderRadius.circular(2.5),
),
child: Text(
'到手价',
textAlign: TextAlign.center,
maxLines: 1,
style: TextStyle(
height: 1,
fontSize: 11,
color: HexColor.fromHex('#ffffff'),
),
),
),
_createPrice(),
],
),
Expanded(
child: Container(),
),
Column(
children: <Widget>[
Container(
margin: EdgeInsets.only(right: 5, bottom: 8),
padding: EdgeInsets.only(left: 10, right: 10, top: 3, bottom: 3),
decoration: BoxDecoration(
color: Colors.redAccent,
borderRadius: BorderRadius.circular(2.5),
),
child: Text(
'700元券',
textAlign: TextAlign.center,
maxLines: 1,
style: TextStyle(
height: 1,
fontSize: 11,
color: HexColor.fromHex('#ffffff'),
),
),
),
_createOriginPrice(),
],
),
],
);
}

Widget _createOriginPrice() {
return Padding(
padding: EdgeInsets.only(bottom: 2),
child: Text(
'¥5999',
style: TextStyle(
fontSize: 11,
height: 1,
color: HexColor.fromHex('#b3b3b3'),
fontWeight: FontWeight.normal,
fontFamily: 'Din',
package: 'zhiying_base_widget',
decoration: TextDecoration.lineThrough,
),
));
}

Widget _createPrice() {
return RichText(
maxLines: 1,
overflow: TextOverflow.ellipsis,
text: TextSpan(children: [
TextSpan(
text: '¥',
style: TextStyle(
fontSize: 10,
color: HexColor.fromHex('#ff4242'),
fontWeight: FontWeight.bold,
fontFamily: 'Din-Bold',
package: 'zhiying_base_widget',
),
),
TextSpan(
text: '5299',
style: TextStyle(
fontSize: 20,
color: HexColor.fromHex('#ff4242'),
fontWeight: FontWeight.bold,
fontFamily: 'Din-Bold',
package: 'zhiying_base_widget',
),
)
]),
);
}

Widget _createCupone() {
List<Widget> widgets = List();

widgets.add(Container(
margin: EdgeInsets.only(right: 5),
padding: EdgeInsets.only(left: 10, right: 10, top: 3, bottom: 3),
decoration: BoxDecoration(
color: HexColor.fromHex('#ff4242'),
borderRadius: BorderRadius.circular(2.5),
),
child: Text(
'到手价',
textAlign: TextAlign.center,
maxLines: 1,
style: TextStyle(
height: 1,
fontSize: 11,
color: HexColor.fromHex('#ffffff'),
),
),
));

return Container(
margin: EdgeInsets.only(top: 6),
child: Row(
children: widgets,
),
);
}
}

+ 1
- 0
pubspec.yaml Visa fil

@@ -19,6 +19,7 @@ dependencies:
image_picker: ^0.6.7+3
tab_indicator_styler: 1.0.0
connectivity: ^0.4.9+3
image_gallery_saver: ^1.5.0
image_cropper:
git:
url: 'http://192.168.0.138:3000/FnuoOS_Flutter_Components/Image_Cropper.git'


Laddar…
Avbryt
Spara