From d7216a52ef26eb262bb47acb2a4b963643a2c3fa Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Fri, 16 Oct 2020 14:19:32 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E4=BC=98=E5=8C=96=202=E3=80=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C=E9=A1=B5=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E7=9A=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search_page/item/search_item_page.dart | 3 +- .../goods_detail_commend_creater.dart | 16 +++--- .../goods_detail_commend_widget.dart | 52 ++++++++++++------- .../models/home_goods_style_model.dart | 47 ++++++++++------- .../sort/search_result_sort_widget.dart | 2 + 5 files changed, 75 insertions(+), 45 deletions(-) diff --git a/lib/pages/search_page/item/search_item_page.dart b/lib/pages/search_page/item/search_item_page.dart index 683e487..659e39f 100644 --- a/lib/pages/search_page/item/search_item_page.dart +++ b/lib/pages/search_page/item/search_item_page.dart @@ -113,7 +113,8 @@ class _SearchItemPageContainerState extends State { } else { list.add(SliverToBoxAdapter( /// TODO 改成骨架图 - child: Container(child: Text('暂无数据~')), + // child: Container(child: Text('暂无数据~')), + child: Container(), )); } return list; diff --git a/lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart b/lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart index f0285c8..9198f34 100644 --- a/lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart +++ b/lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart @@ -15,15 +15,15 @@ class GoodsDetailCommendCreater extends WidgetCreater { @override List createWidgets(Map model) { - String d = model['data']; - Map json = convert.jsonDecode(d); - GoodsDetailRecommendModel style = GoodsDetailRecommendModel.fromJson(json); + // String d = model['data']; + // Map json = convert.jsonDecode(d); + // GoodsDetailRecommendModel style = GoodsDetailRecommendModel.fromJson(json); - print('创建商品列表'); - Widget _widget = BlocProvider( - bloc: HomeGoodsHeaderBloc(), - child: HomeGoodsHeader(model, _eventBus), - ); + // print('创建商品列表'); + // Widget _widget = BlocProvider( + // bloc: HomeGoodsHeaderBloc(), + // child: HomeGoodsHeader(model, _eventBus), + // ); return [ SliverToBoxAdapter( diff --git a/lib/widgets/goods_details/recommend/goods_detail_commend_widget.dart b/lib/widgets/goods_details/recommend/goods_detail_commend_widget.dart index 156c48d..a1b5135 100644 --- a/lib/widgets/goods_details/recommend/goods_detail_commend_widget.dart +++ b/lib/widgets/goods_details/recommend/goods_detail_commend_widget.dart @@ -3,37 +3,46 @@ import 'dart:convert' as convert; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:zhiying_base_widget/widgets/goods_details/recommend/models/goods_detail_recommend_model.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class GoodsDetailsRecommendWidget extends StatefulWidget { final Map data; - - const GoodsDetailsRecommendWidget(this.data, {Key key}) : super(key: key); + // Map style = {}; + HomeGoodsStyleModel styleModel; + + GoodsDetailsRecommendWidget(this.data, {Key key}) : super(key: key) { + try { + styleModel = HomeGoodsStyleModel.fromJson(convert.jsonDecode(data['data'])); + } catch (e, s) { + Logger.error(e, s); + } + } @override - _GoodsDetailsRecommendWidgetState createState() => - _GoodsDetailsRecommendWidgetState(); + _GoodsDetailsRecommendWidgetState createState() => _GoodsDetailsRecommendWidgetState(); } -class _GoodsDetailsRecommendWidgetState - extends State { - GoodsDetailRecommendModel _style; +class _GoodsDetailsRecommendWidgetState extends State { + // GoodsDetailRecommendModel _style; @override void initState() { - String d = widget.data['data']; - Map json = convert.jsonDecode(d); - _style = GoodsDetailRecommendModel.fromJson(json); + // String d = widget.data['data']; + // Map json = convert.jsonDecode(d); + // _style = GoodsDetailRecommendModel.fromJson(json); super.initState(); } @override Widget build(BuildContext context) { - return Column( - children: [ - _createTitle(), - ], + return Container( + child: Column( + children: [ + _createTitle(), + ], + ), ); } @@ -46,17 +55,24 @@ class _GoodsDetailsRecommendWidgetState mainAxisAlignment: MainAxisAlignment.center, children: [ CachedNetworkImage( - imageUrl: _style.recListIcon ?? '', + // imageUrl: _style.recListIcon ?? '', + // imageUrl: widget?.style['rec_icon'] ?? '', + imageUrl: widget?.styleModel?.recIcon ?? '', width: 15, height: 15, ), Padding( padding: const EdgeInsets.only(left: 2.5), child: Text( - _style.recListText, + // _style?.recListText ?? '', + // widget?.style['title'] ?? '', + widget?.styleModel?.title ?? '', style: TextStyle( - color: HexColor.fromHex(_style?.recListTextColor ?? 'FF4242'), - fontSize: 14), + // color: HexColor.fromHex(_style?.recListTextColor ?? 'FF4242'), + // color: HexColor.fromHex(widget?.style['title_color'] ?? ''), + color: HexColor.fromHex(widget?.styleModel?.titleColor ?? ''), + fontSize: 14, + ), ), ) ], diff --git a/lib/widgets/home/home_goods/models/home_goods_style_model.dart b/lib/widgets/home/home_goods/models/home_goods_style_model.dart index f44d74d..c789e83 100644 --- a/lib/widgets/home/home_goods/models/home_goods_style_model.dart +++ b/lib/widgets/home/home_goods/models/home_goods_style_model.dart @@ -15,19 +15,27 @@ class HomeGoodsStyleModel { String listColumn; HomeGoodsListStyleModel listStyle; - HomeGoodsStyleModel( - {this.topMargin, - this.leftRighMargin, - this.subtitle, - this.tilteTextColor, - this.subtitleTextColor, - this.tilteTextSelectedColor, - this.subtitleTextSelectedColor, - this.subtitleBgColor, - this.sourceType, - this.recommendList, - this.listColumn, - this.listStyle}); + String title; + String titleColor; + String recIcon; + + HomeGoodsStyleModel({ + this.topMargin, + this.leftRighMargin, + this.subtitle, + this.tilteTextColor, + this.subtitleTextColor, + this.tilteTextSelectedColor, + this.subtitleTextSelectedColor, + this.subtitleBgColor, + this.sourceType, + this.recommendList, + this.listColumn, + this.listStyle, + this.title, + this.titleColor, + this.recIcon, + }); HomeGoodsStyleModel.fromJson(Map json) { topMargin = json['top_margin']; @@ -46,9 +54,10 @@ class HomeGoodsStyleModel { }); } listColumn = json['list_column']; - listStyle = json['list_style'] != null - ? new HomeGoodsListStyleModel.fromJson(json['list_style']) - : null; + listStyle = json['list_style'] != null ? new HomeGoodsListStyleModel.fromJson(json['list_style']) : null; + title = json['title']; + titleColor = json['title_color']; + recIcon = json['rec_icon']; } Map toJson() { @@ -63,13 +72,15 @@ class HomeGoodsStyleModel { data['subtitle_bg_color'] = this.subtitleBgColor; data['source_type'] = this.sourceType; if (this.recommendList != null) { - data['recommend_list'] = - this.recommendList.map((v) => v.toJson()).toList(); + data['recommend_list'] = this.recommendList.map((v) => v.toJson()).toList(); } data['list_column'] = this.listColumn; if (this.listStyle != null) { data['list_style'] = this.listStyle.toJson(); } + data['title'] = this.title; + data['title_color'] = this.titleColor; + data['rec_icon'] = this.recIcon; return data; } } diff --git a/lib/widgets/search_result/sort/search_result_sort_widget.dart b/lib/widgets/search_result/sort/search_result_sort_widget.dart index 1b6d41a..c40c0bd 100644 --- a/lib/widgets/search_result/sort/search_result_sort_widget.dart +++ b/lib/widgets/search_result/sort/search_result_sort_widget.dart @@ -469,6 +469,8 @@ class _SearchResultSortWidgetState extends State { decoration: InputDecoration( filled: true, fillColor: Colors.transparent, + isDense: true, + contentPadding: EdgeInsets.zero, // contentPadding: const EdgeInsets.only(bottom: 6, left: ), border: InputBorder.none, focusedBorder: InputBorder.none,