@@ -19,18 +19,28 @@ class CounponWidget extends StatelessWidget { | |||
Widget build(BuildContext context) { | |||
// return Container(); | |||
return BlocProvider<CounponBloc>( | |||
create: (_) => CounponBloc(repository: CounponRepository())..add(CounponInitEvent(model: model)), | |||
child: CounponWidgetContainer(), | |||
create: (_) => CounponBloc(repository: CounponRepository()), //..add(CounponInitEvent(model: model)), | |||
child: CounponWidgetContainer(model, key: UniqueKey(),), | |||
); | |||
} | |||
} | |||
class CounponWidgetContainer extends StatefulWidget { | |||
final Map<String, dynamic> model; | |||
const CounponWidgetContainer(this.model, {Key key}) : super(key: key); | |||
@override | |||
_CounponWidgetContainerState createState() => _CounponWidgetContainerState(); | |||
} | |||
class _CounponWidgetContainerState extends State<CounponWidgetContainer> { | |||
@override | |||
void initState() { | |||
BlocProvider.of<CounponBloc>(context).add(CounponInitEvent(model: widget?.model)); | |||
super.initState(); | |||
} | |||
/// 点击领取 | |||
void _onJump(CounponModel model) {} | |||
@@ -69,19 +79,18 @@ class _CounponWidgetContainerState extends State<CounponWidgetContainer> { | |||
width: double.infinity, | |||
padding: const EdgeInsets.only(left: 18.5, top: 12, bottom: 14), | |||
decoration: BoxDecoration( | |||
image: DecorationImage( | |||
image: CachedNetworkImageProvider( | |||
model?.bg_img ??'', | |||
), | |||
fit: BoxFit.fill | |||
) | |||
), | |||
image: DecorationImage( | |||
image: CachedNetworkImageProvider( | |||
model?.bg_img ?? '', | |||
), | |||
fit: BoxFit.fill)), | |||
alignment: Alignment.centerLeft, | |||
child: Row( | |||
children: <Widget>[ | |||
/// 价格 | |||
_getPriceWidget(model), | |||
const SizedBox(width: 7.5), | |||
/// 有效期 | |||
_getTimeWidget(model) | |||
], | |||
@@ -102,7 +111,8 @@ class _CounponWidgetContainerState extends State<CounponWidgetContainer> { | |||
Text(model?.price_type ?? '¥ ', style: TextStyle(fontSize: 15, color: HexColor.fromHex(model?.price_type_color ?? '#FFFFFF'))), | |||
/// 价格 | |||
Text(model?.coupon_price ??'100', style: TextStyle(fontSize: 30, color: HexColor.fromHex(model?.coupon_price_color ?? '#FFFFFF'), fontFamily: 'Din', package: 'zhiying_base_widget')), | |||
Text(model?.coupon_price ?? '100', | |||
style: TextStyle(fontSize: 30, color: HexColor.fromHex(model?.coupon_price_color ?? '#FFFFFF'), fontFamily: 'Din', package: 'zhiying_base_widget')), | |||
], | |||
); | |||
} | |||
@@ -113,7 +123,7 @@ class _CounponWidgetContainerState extends State<CounponWidgetContainer> { | |||
crossAxisAlignment: CrossAxisAlignment.start, | |||
children: <Widget>[ | |||
/// 标题 | |||
Text(model?.coupon_title ?? '优惠券', style: TextStyle(fontSize: 17, color: HexColor.fromHex( model?.coupon_title_color ?? '#FFFFFF'))), | |||
Text(model?.coupon_title ?? '优惠券', style: TextStyle(fontSize: 17, color: HexColor.fromHex(model?.coupon_title_color ?? '#FFFFFF'))), | |||
/// 到期时间 | |||
Text(model?.coupon_endtime ?? '有效期至2020-10-01', style: TextStyle(fontSize: 10, color: HexColor.fromHex(model?.coupon_time_color ?? '#FFFFFF'))) | |||
@@ -19,18 +19,29 @@ class GoodsDetailsImgWidget extends StatelessWidget { | |||
@override | |||
Widget build(BuildContext context) { | |||
return BlocProvider<GoodsDetailsImgBloc>( | |||
create: (_) => GoodsDetailsImgBloc(repository: GoodsDetailsImgRepository())..add(GoodsDetailsImgInitEvent(model: model)), | |||
child: GoodsDetailsImgWidgetContainer(), | |||
create: (_) => GoodsDetailsImgBloc(repository: GoodsDetailsImgRepository()),//..add(GoodsDetailsImgInitEvent(model: model)), | |||
child: GoodsDetailsImgWidgetContainer(model, key: UniqueKey(),), | |||
); | |||
} | |||
} | |||
class GoodsDetailsImgWidgetContainer extends StatefulWidget { | |||
final Map<String, dynamic> model; | |||
const GoodsDetailsImgWidgetContainer(this.model, {Key key}) : super(key: key); | |||
@override | |||
_GoodsDetailsImgWidgetContainerState createState() => _GoodsDetailsImgWidgetContainerState(); | |||
} | |||
class _GoodsDetailsImgWidgetContainerState extends State<GoodsDetailsImgWidgetContainer> { | |||
@override | |||
void initState() { | |||
BlocProvider.of<GoodsDetailsImgBloc>(context).add(GoodsDetailsImgInitEvent(model: widget?.model)); | |||
super.initState(); | |||
} | |||
@override | |||
Widget build(BuildContext context) { | |||
return BlocConsumer<GoodsDetailsImgBloc, GoodsDetailsImgState>( | |||
@@ -30,10 +30,12 @@ class GoodsDetailsFooterWidget extends StatelessWidget { | |||
visible: !EmptyUtil.isEmpty(model), | |||
replacement: GoodsDetailsFooterSkeleton(), | |||
child: BlocProvider<GoodsDetailsFooterBloc>( | |||
create: (_) => | |||
GoodsDetailsFooterBloc(repository: GoodsDetailsFooterRepository()) | |||
..add(GoodsDetailsFooterInitEvent(model: model)), | |||
child: GooddsDetailsFooterContainer(model), | |||
create: (_) => GoodsDetailsFooterBloc(repository: GoodsDetailsFooterRepository()), | |||
//..add(GoodsDetailsFooterInitEvent(model: model)), | |||
child: GooddsDetailsFooterContainer( | |||
model, | |||
key: UniqueKey(), | |||
), | |||
), | |||
); | |||
} | |||
@@ -45,21 +47,24 @@ class GooddsDetailsFooterContainer extends StatefulWidget { | |||
const GooddsDetailsFooterContainer(this.model, {Key key}) : super(key: key); | |||
@override | |||
_GooddsDetailsFooterContainerState createState() => | |||
_GooddsDetailsFooterContainerState(); | |||
_GooddsDetailsFooterContainerState createState() => _GooddsDetailsFooterContainerState(); | |||
} | |||
class _GooddsDetailsFooterContainerState | |||
extends State<GooddsDetailsFooterContainer> { | |||
class _GooddsDetailsFooterContainerState extends State<GooddsDetailsFooterContainer> { | |||
UserInfoModel _user; | |||
@override | |||
void initState() { | |||
BlocProvider.of<GoodsDetailsFooterBloc>(context).add(GoodsDetailsFooterInitEvent(model: widget?.model)); | |||
super.initState(); | |||
} | |||
/// 打开首页 | |||
void _openHome() { | |||
Navigator.pushAndRemoveUntil( | |||
context, | |||
CupertinoPageRoute( | |||
builder: (BuildContext context) => | |||
PageFactory.create('homePage', null)), | |||
CupertinoPageRoute(builder: (BuildContext context) => PageFactory.create('homePage', null)), | |||
(Route<dynamic> route) => false, | |||
); | |||
} | |||
@@ -95,8 +100,7 @@ class _GooddsDetailsFooterContainerState | |||
return; | |||
} | |||
} | |||
Navigator.of(context).push(CupertinoPageRoute( | |||
builder: (context) => GoodsSharePage(widget.model))); | |||
Navigator.of(context).push(CupertinoPageRoute(builder: (context) => GoodsSharePage(widget.model))); | |||
} | |||
} | |||
@@ -166,8 +170,7 @@ class _GooddsDetailsFooterContainerState | |||
return SafeArea( | |||
child: Container( | |||
width: double.infinity, | |||
padding: EdgeInsets.only( | |||
bottom: (height > 10 ? 0 : 8), top: 8, left: 21, right: 12.5), | |||
padding: EdgeInsets.only(bottom: (height > 10 ? 0 : 8), top: 8, left: 21, right: 12.5), | |||
decoration: BoxDecoration( | |||
// boxShadow: [ | |||
// BoxShadow(color: Colors.grey[300], offset: Offset(0.0, 0.0), blurRadius: 5.0, spreadRadius: 2.0), | |||
@@ -206,18 +209,12 @@ class _GooddsDetailsFooterContainerState | |||
onTap: () => _openHome(), | |||
child: Padding( | |||
padding: const EdgeInsets.only(right: 35), | |||
child: _getCustomWidget(model?.home ?? '首页', | |||
model?.home_color ?? '999999', model?.home_icon ?? ''), | |||
child: _getCustomWidget(model?.home ?? '首页', model?.home_color ?? '999999', model?.home_icon ?? ''), | |||
)), | |||
GestureDetector( | |||
behavior: HitTestBehavior.opaque, | |||
onTap: () => _collectOnClick(), | |||
child: Padding( | |||
padding: const EdgeInsets.only(right: 0), | |||
child: _getCustomWidget( | |||
model?.collect ?? '收藏', | |||
model?.collect_color ?? '999999', | |||
model?.collect_icon ?? ''))) | |||
child: Padding(padding: const EdgeInsets.only(right: 0), child: _getCustomWidget(model?.collect ?? '收藏', model?.collect_color ?? '999999', model?.collect_icon ?? ''))) | |||
], | |||
); | |||
} | |||
@@ -244,40 +241,30 @@ class _GooddsDetailsFooterContainerState | |||
width: 110, | |||
// padding: const EdgeInsets.only(left: 30, right: 30, top: 5, bottom: 5), | |||
decoration: BoxDecoration( | |||
gradient: LinearGradient(colors: [ | |||
HexColor.fromHex(model?.share_earn_bg1_color ?? '#FFCA66'), | |||
HexColor.fromHex(model?.share_earn_bg2_color ?? '#FFD961') | |||
], begin: Alignment.centerLeft, end: Alignment.centerRight), | |||
borderRadius: BorderRadius.only( | |||
bottomLeft: Radius.circular(25), topLeft: Radius.circular(25))), | |||
gradient: LinearGradient( | |||
colors: [HexColor.fromHex(model?.share_earn_bg1_color ?? '#FFCA66'), HexColor.fromHex(model?.share_earn_bg2_color ?? '#FFD961')], | |||
begin: Alignment.centerLeft, | |||
end: Alignment.centerRight), | |||
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(25), topLeft: Radius.circular(25))), | |||
child: Column( | |||
crossAxisAlignment: CrossAxisAlignment.center, | |||
mainAxisAlignment: MainAxisAlignment.center, | |||
children: <Widget>[ | |||
RichText( | |||
text: TextSpan( | |||
text: '¥ ', | |||
style: TextStyle( | |||
fontSize: 12, | |||
color: HexColor.fromHex( | |||
model?.share_earn_val_color ?? 'FFFFFF')), | |||
children: [ | |||
TextSpan( | |||
text: model?.share_value ?? '0.0', | |||
style: TextStyle( | |||
fontSize: 15, | |||
fontWeight: FontWeight.bold, | |||
color: HexColor.fromHex( | |||
model?.share_earn_color ?? '#FFFFFF'), | |||
fontFamily: 'Din', | |||
package: 'zhiying_base_widget')), | |||
]), | |||
text: TextSpan(text: '¥ ', style: TextStyle(fontSize: 12, color: HexColor.fromHex(model?.share_earn_val_color ?? 'FFFFFF')), children: [ | |||
TextSpan( | |||
text: model?.share_value ?? '0.0', | |||
style: TextStyle( | |||
fontSize: 15, | |||
fontWeight: FontWeight.bold, | |||
color: HexColor.fromHex(model?.share_earn_color ?? '#FFFFFF'), | |||
fontFamily: 'Din', | |||
package: 'zhiying_base_widget')), | |||
]), | |||
), | |||
Text( | |||
model?.share_earn ?? '分享赚', | |||
style: TextStyle( | |||
color: HexColor.fromHex(model?.share_earn_color ?? '#FFFFFF'), | |||
fontSize: 12), | |||
style: TextStyle(color: HexColor.fromHex(model?.share_earn_color ?? '#FFFFFF'), fontSize: 12), | |||
), | |||
], | |||
), | |||
@@ -296,42 +283,29 @@ class _GooddsDetailsFooterContainerState | |||
height: 44, | |||
width: 110, | |||
decoration: BoxDecoration( | |||
gradient: LinearGradient(colors: [ | |||
HexColor.fromHex(model?.save_earn_bg1_color ?? '#FF6969'), | |||
HexColor.fromHex(model?.save_earn_bg2_color ?? '#FF4646') | |||
], begin: Alignment.centerLeft, end: Alignment.centerRight), | |||
borderRadius: BorderRadius.only( | |||
bottomRight: Radius.circular(25), | |||
topRight: Radius.circular(25))), | |||
gradient: LinearGradient( | |||
colors: [HexColor.fromHex(model?.save_earn_bg1_color ?? '#FF6969'), HexColor.fromHex(model?.save_earn_bg2_color ?? '#FF4646')], | |||
begin: Alignment.centerLeft, | |||
end: Alignment.centerRight), | |||
borderRadius: BorderRadius.only(bottomRight: Radius.circular(25), topRight: Radius.circular(25))), | |||
child: Column( | |||
crossAxisAlignment: CrossAxisAlignment.center, | |||
mainAxisAlignment: MainAxisAlignment.center, | |||
children: <Widget>[ | |||
RichText( | |||
text: TextSpan( | |||
text: '¥ ', | |||
style: TextStyle( | |||
fontSize: 12, | |||
color: HexColor.fromHex( | |||
model?.save_earn_val_color ?? 'FFFFFF')), | |||
children: [ | |||
TextSpan( | |||
text: model?.slef_buy_value ?? '0.0', | |||
style: TextStyle( | |||
fontSize: 15, | |||
fontWeight: FontWeight.bold, | |||
color: HexColor.fromHex( | |||
model?.save_earn_val_color ?? '#FFFFFF'), | |||
fontFamily: 'Din', | |||
package: 'zhiying_base_widget', | |||
)), | |||
]), | |||
text: TextSpan(text: '¥ ', style: TextStyle(fontSize: 12, color: HexColor.fromHex(model?.save_earn_val_color ?? 'FFFFFF')), children: [ | |||
TextSpan( | |||
text: model?.slef_buy_value ?? '0.0', | |||
style: TextStyle( | |||
fontSize: 15, | |||
fontWeight: FontWeight.bold, | |||
color: HexColor.fromHex(model?.save_earn_val_color ?? '#FFFFFF'), | |||
fontFamily: 'Din', | |||
package: 'zhiying_base_widget', | |||
)), | |||
]), | |||
), | |||
Text(model?.save_earn ?? '自购省', | |||
style: TextStyle( | |||
color: | |||
HexColor.fromHex(model?.save_earn_color ?? '#FFFFFF'), | |||
fontSize: 12)) | |||
Text(model?.save_earn ?? '自购省', style: TextStyle(color: HexColor.fromHex(model?.save_earn_color ?? '#FFFFFF'), fontSize: 12)) | |||
], | |||
), | |||
), | |||
@@ -354,8 +328,7 @@ class _GooddsDetailsFooterContainerState | |||
const SizedBox(height: 5), | |||
/// 图片 | |||
Text(text, | |||
style: TextStyle(color: HexColor.fromHex(textColor), fontSize: 11)) | |||
Text(text, style: TextStyle(color: HexColor.fromHex(textColor), fontSize: 11)) | |||
], | |||
); | |||
} | |||
@@ -19,8 +19,8 @@ class GoodsDetailsSlideBannerWidget extends StatelessWidget { | |||
@override | |||
Widget build(BuildContext context) { | |||
return BlocProvider<GoodsDetailsSlideBannerBloc>( | |||
create: (_) => GoodsDetailsSlideBannerBloc(repository: GoodsDetailsSlideBannerRepository())..add(GoodsDetailsSlideBannerInitEvent(model: model)), | |||
child: GoodsDetailsSlideBannerContainer(model), | |||
create: (_) => GoodsDetailsSlideBannerBloc(repository: GoodsDetailsSlideBannerRepository()),//..add(GoodsDetailsSlideBannerInitEvent(model: model)), | |||
child: GoodsDetailsSlideBannerContainer(model, key: UniqueKey(),), | |||
); | |||
} | |||
} | |||
@@ -40,6 +40,12 @@ class _GoodsDetailsSlideBannerContainerState extends State<GoodsDetailsSlideBann | |||
print('点击了 $model'); | |||
} | |||
@override | |||
void initState() { | |||
BlocProvider.of<GoodsDetailsSlideBannerBloc>(context).add(GoodsDetailsSlideBannerInitEvent(model: widget?.model)); | |||
super.initState(); | |||
} | |||
@override | |||
Widget build(BuildContext context) { | |||
return BlocConsumer<GoodsDetailsSlideBannerBloc, GoodsDetailsSlideBannerState>( | |||
@@ -20,18 +20,29 @@ class StoreWidget extends StatelessWidget { | |||
@override | |||
Widget build(BuildContext context) { | |||
return BlocProvider<StoreBloc>( | |||
create: (_) => StoreBloc(repository: StoreRepository())..add(StoreInitEvent(model: model)), | |||
child: StoreContainer(), | |||
create: (_) => StoreBloc(repository: StoreRepository()),//..add(StoreInitEvent(model: model)), | |||
child: StoreContainer(model, key: UniqueKey(),), | |||
); | |||
} | |||
} | |||
class StoreContainer extends StatefulWidget { | |||
final Map<String, dynamic> model; | |||
const StoreContainer(this.model, {Key key}) : super(key: key); | |||
@override | |||
_StoreContainerState createState() => _StoreContainerState(); | |||
} | |||
class _StoreContainerState extends State<StoreContainer> { | |||
@override | |||
void initState() { | |||
BlocProvider.of<StoreBloc>(context).add(StoreInitEvent(model: widget?.model)); | |||
super.initState(); | |||
} | |||
/// 点击更多 | |||
void _onMoreClick() {} | |||
@@ -26,8 +26,7 @@ class HotRankingGoods extends StatelessWidget { | |||
Providers providers = getProvider(good.provider); | |||
return GestureDetector( | |||
onTap: () { | |||
RouterUtil.route(SkipModel(skipIdentifier: "goods_details"), | |||
{"provider": good.provider, "good_id": good.goodId}, context); | |||
RouterUtil.route(SkipModel(skipIdentifier: "goods_details"), good?.toJson(), context); | |||
}, | |||
child: Stack( | |||
children: <Widget>[ | |||
@@ -36,19 +36,22 @@ class Good { | |||
String marketPrice; | |||
String currentPrice; | |||
String inorderCount; | |||
Map<String, dynamic> detailData; | |||
Good( | |||
{this.provider, | |||
this.providerName, | |||
this.goodId, | |||
this.goodImage, | |||
this.goodTitle, | |||
this.shopName, | |||
this.coupon, | |||
this.commission, | |||
this.marketPrice, | |||
this.currentPrice, | |||
this.inorderCount}); | |||
Good({ | |||
this.provider, | |||
this.providerName, | |||
this.goodId, | |||
this.goodImage, | |||
this.goodTitle, | |||
this.shopName, | |||
this.coupon, | |||
this.commission, | |||
this.marketPrice, | |||
this.currentPrice, | |||
this.inorderCount, | |||
this.detailData, | |||
}); | |||
Good.fromJson(Map<String, dynamic> json) { | |||
provider = json['provider']; | |||
@@ -62,6 +65,7 @@ class Good { | |||
marketPrice = json['market_price']; | |||
currentPrice = json['current_price']; | |||
inorderCount = json['inorder_count']; | |||
detailData = json['detail_data']; | |||
} | |||
Map<String, dynamic> toJson() { | |||
@@ -77,6 +81,7 @@ class Good { | |||
data['market_price'] = this.marketPrice; | |||
data['current_price'] = this.currentPrice; | |||
data['inorder_count'] = this.inorderCount; | |||
data['detail_data'] = this.detailData; | |||
return data; | |||
} | |||
} |
@@ -58,7 +58,7 @@ class _MineHeaderContainerState extends State<MineHeaderContainer> { | |||
child: ClipRRect( | |||
borderRadius: BorderRadius.circular(28), | |||
child: CachedNetworkImage( | |||
imageUrl: profile.avatar, | |||
imageUrl: profile?.avatar ?? '', | |||
fit: BoxFit.cover, | |||
), | |||
), | |||