diff --git a/lib/widgets/goods_details/coupon/counpon_widget.dart b/lib/widgets/goods_details/coupon/counpon_widget.dart index a0e3da8..211cb8f 100644 --- a/lib/widgets/goods_details/coupon/counpon_widget.dart +++ b/lib/widgets/goods_details/coupon/counpon_widget.dart @@ -19,18 +19,28 @@ class CounponWidget extends StatelessWidget { Widget build(BuildContext context) { // return Container(); return BlocProvider( - 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 model; + + const CounponWidgetContainer(this.model, {Key key}) : super(key: key); + @override _CounponWidgetContainerState createState() => _CounponWidgetContainerState(); } class _CounponWidgetContainerState extends State { + @override + void initState() { + BlocProvider.of(context).add(CounponInitEvent(model: widget?.model)); + super.initState(); + } + /// 点击领取 void _onJump(CounponModel model) {} @@ -69,19 +79,18 @@ class _CounponWidgetContainerState extends State { 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: [ /// 价格 _getPriceWidget(model), const SizedBox(width: 7.5), + /// 有效期 _getTimeWidget(model) ], @@ -102,7 +111,8 @@ class _CounponWidgetContainerState extends State { 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 { crossAxisAlignment: CrossAxisAlignment.start, children: [ /// 标题 - 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'))) diff --git a/lib/widgets/goods_details/detail_img/goods_details_img.dart b/lib/widgets/goods_details/detail_img/goods_details_img.dart index 7dd395d..b597396 100644 --- a/lib/widgets/goods_details/detail_img/goods_details_img.dart +++ b/lib/widgets/goods_details/detail_img/goods_details_img.dart @@ -19,18 +19,29 @@ class GoodsDetailsImgWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - 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 model; + const GoodsDetailsImgWidgetContainer(this.model, {Key key}) : super(key: key); + @override _GoodsDetailsImgWidgetContainerState createState() => _GoodsDetailsImgWidgetContainerState(); } class _GoodsDetailsImgWidgetContainerState extends State { + + @override + void initState() { + BlocProvider.of(context).add(GoodsDetailsImgInitEvent(model: widget?.model)); + super.initState(); + } + @override Widget build(BuildContext context) { return BlocConsumer( diff --git a/lib/widgets/goods_details/footer/goods_details_footer_widget.dart b/lib/widgets/goods_details/footer/goods_details_footer_widget.dart index 508a525..3968c51 100644 --- a/lib/widgets/goods_details/footer/goods_details_footer_widget.dart +++ b/lib/widgets/goods_details/footer/goods_details_footer_widget.dart @@ -30,10 +30,12 @@ class GoodsDetailsFooterWidget extends StatelessWidget { visible: !EmptyUtil.isEmpty(model), replacement: GoodsDetailsFooterSkeleton(), child: BlocProvider( - 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 { +class _GooddsDetailsFooterContainerState extends State { + UserInfoModel _user; + @override + void initState() { + BlocProvider.of(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 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: [ 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: [ 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)) ], ); } diff --git a/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart b/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart index de9b966..0379973 100644 --- a/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart +++ b/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart @@ -19,8 +19,8 @@ class GoodsDetailsSlideBannerWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - 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(context).add(GoodsDetailsSlideBannerInitEvent(model: widget?.model)); + super.initState(); + } + @override Widget build(BuildContext context) { return BlocConsumer( diff --git a/lib/widgets/goods_details/store/store_widget.dart b/lib/widgets/goods_details/store/store_widget.dart index 393e5d7..60d05b8 100644 --- a/lib/widgets/goods_details/store/store_widget.dart +++ b/lib/widgets/goods_details/store/store_widget.dart @@ -20,18 +20,29 @@ class StoreWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - 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 model; + + const StoreContainer(this.model, {Key key}) : super(key: key); + @override _StoreContainerState createState() => _StoreContainerState(); } class _StoreContainerState extends State { + + @override + void initState() { + BlocProvider.of(context).add(StoreInitEvent(model: widget?.model)); + super.initState(); + } + /// 点击更多 void _onMoreClick() {} diff --git a/lib/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart b/lib/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart index 998fd95..43bf9f4 100644 --- a/lib/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart +++ b/lib/widgets/hot_ranking/hot_ranking_goods/hot_ranking_goods.dart @@ -5,6 +5,7 @@ import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/h import 'package:zhiying_base_widget/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_model.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:cached_network_image/cached_network_image.dart'; +import 'dart:ui' as ui show ParagraphBuilder, PlaceholderAlignment; import 'package:zhiying_comm/zhiying_comm.dart'; class HotRankingGoods extends StatelessWidget { @@ -26,8 +27,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: [ @@ -60,27 +60,27 @@ class HotRankingGoods extends StatelessWidget { children: [ Expanded( child: RichText( + textAlign: TextAlign.start, overflow: TextOverflow.ellipsis, maxLines: 2, text: TextSpan(children: [ WidgetSpan( + alignment: ui.PlaceholderAlignment.middle, child: Container( + padding: EdgeInsets.only( + left: 4.w, right: 4.w, top: 1, bottom: 1), decoration: BoxDecoration( color: HexColor.fromHex( providers.providerBgColor), borderRadius: - BorderRadius.circular(4)), - child: Padding( - padding: EdgeInsets.only( - left: 4.w, right: 4.w), - child: Text( - good.providerName ?? "", - style: TextStyle( - color: HexColor.fromHex( - providers.providerNameColor, - ), - fontSize: 18.sp), - ), + BorderRadius.circular(2.5)), + child: Text( + good.providerName ?? "", + style: TextStyle( + color: HexColor.fromHex( + providers.providerNameColor, + ), + fontSize: 18.sp), ), )), WidgetSpan( @@ -211,9 +211,10 @@ class HotRankingGoods extends StatelessWidget { children: [ Expanded( child: Container( + alignment: Alignment.centerLeft, height: 40.w, padding: EdgeInsets.only( - left: 64.w, + left: 40.w, ), margin: EdgeInsets.only(right: 20, left: 20.w), diff --git a/lib/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart b/lib/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart index 04b2de2..520b2b4 100644 --- a/lib/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart +++ b/lib/widgets/hot_ranking/hot_ranking_list/model/hot_ranking_list_data_model.dart @@ -36,19 +36,22 @@ class Good { String marketPrice; String currentPrice; String inorderCount; + Map 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 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 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; } } diff --git a/lib/widgets/mine/mine_header/mine_header_container.dart b/lib/widgets/mine/mine_header/mine_header_container.dart index 1e9513c..7c47b49 100644 --- a/lib/widgets/mine/mine_header/mine_header_container.dart +++ b/lib/widgets/mine/mine_header/mine_header_container.dart @@ -58,7 +58,7 @@ class _MineHeaderContainerState extends State { child: ClipRRect( borderRadius: BorderRadius.circular(28), child: CachedNetworkImage( - imageUrl: profile.avatar, + imageUrl: profile?.avatar ?? '', fit: BoxFit.cover, ), ),