Browse Source

1、商品列表添加占位图

2、搜索结果页两列修改不能加载更多的bug
3、搜索结果请求参数去掉size,根据返回列表长度判断是否加载完毕
tags/0.0.14+4
PH2 4 years ago
parent
commit
dc6288e674
4 changed files with 45 additions and 13 deletions
  1. +20
    -7
      lib/widgets/home/home_goods/home_goods_item.dart
  2. +19
    -0
      lib/widgets/home/home_goods/home_goods_item_single.dart
  3. +4
    -4
      lib/widgets/search_result/goods_list/bloc/search_result_goods_list_bloc.dart
  4. +2
    -2
      lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart

+ 20
- 7
lib/widgets/home/home_goods/home_goods_item.dart View File

@@ -46,13 +46,14 @@ class HomeGoodsItem extends StatelessWidget {
Container( Container(
width: double.infinity, width: double.infinity,
margin: EdgeInsets.only(right: 0), margin: EdgeInsets.only(right: 0),
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(7.5),
topRight: Radius.circular(7.5)),
child: CachedNetworkImage(
imageUrl: goods?.goodImage ?? '',
fit: BoxFit.fitWidth,
child: ClipRRect(borderRadius: BorderRadius.only(topLeft: Radius.circular(7.5), topRight: Radius.circular(7.5)),
child: CachedNetworkImage(imageUrl: goods?.goodImage ?? '', fit: BoxFit.fitWidth,
placeholder: (context, url) {
return _createShimmerWidget(width: double.infinity);
},
errorWidget: (context, url, error,) {
return _createShimmerWidget(width: double.infinity);
},
), ),
), ),
), ),
@@ -352,4 +353,16 @@ class HomeGoodsItem extends StatelessWidget {
style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')), style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')),
); );
} }

/// 商品占位骨架视图
Widget _createShimmerWidget({double width, double height}) {
//修改后返回默认图片
return Image.asset(
'assets/images/occupation_map/occupation_map.png',
package: 'zhiying_base_widget',
width: width,
height: height,
fit: BoxFit.fill,
);
}
} }

+ 19
- 0
lib/widgets/home/home_goods/home_goods_item_single.dart View File

@@ -59,6 +59,12 @@ class HomeGoodsItemSingle extends StatelessWidget {
child: CachedNetworkImage( child: CachedNetworkImage(
imageUrl: goods.goodImage, imageUrl: goods.goodImage,
fit: BoxFit.fitHeight, fit: BoxFit.fitHeight,
placeholder: (context, url) {
return _createShimmerWidget(width: double.infinity, height: double.infinity);
},
errorWidget: (BuildContext context, String url, dynamic error) {
return _createShimmerWidget(width: double.infinity, height: double.infinity);
},
), ),
), ),
), ),
@@ -427,4 +433,17 @@ class HomeGoodsItemSingle extends StatelessWidget {
], ],
); );
} }

/// 商品占位骨架视图
Widget _createShimmerWidget({double width, double height}) {
//修改后返回默认图片
return Image.asset(
'assets/images/occupation_map/occupation_map.png',
package: 'zhiying_base_widget',
width: width,
height: height,
fit: BoxFit.fill,
);
}

} }

+ 4
- 4
lib/widgets/search_result/goods_list/bloc/search_result_goods_list_bloc.dart View File

@@ -35,8 +35,8 @@ class SearchResultGoodsListBloc extends Bloc<SearchResultGoodsListEvent, SearchR
} }


/// 上拉更多 /// 上拉更多
if (event is SearchResultGoodsListOnLoadEvent && state is SearchResultGoodsListLoadedState) {
yield* _mapOnLoadToState(event, state);
if (event is SearchResultGoodsListOnLoadEvent && (state is SearchResultGoodsListLoadedState || state is SearchResultGoodsListChangeStyleState)) {
yield* _mapOnLoadToState(event);
} }


/// 修改样式 /// 修改样式
@@ -77,7 +77,7 @@ class SearchResultGoodsListBloc extends Bloc<SearchResultGoodsListEvent, SearchR
} }


/// 上拉更多 /// 上拉更多
Stream<SearchResultGoodsListState> _mapOnLoadToState(SearchResultGoodsListOnLoadEvent event, SearchResultGoodsListLoadedState state) async* {
Stream<SearchResultGoodsListState> _mapOnLoadToState(SearchResultGoodsListOnLoadEvent event) async* {
var result = await repository.fetchLoadData(); var result = await repository.fetchLoadData();
if (!EmptyUtil.isEmpty(result)) { if (!EmptyUtil.isEmpty(result)) {
yield SearchResultGoodsListLoadSuccessState(); yield SearchResultGoodsListLoadSuccessState();
@@ -93,7 +93,7 @@ class SearchResultGoodsListBloc extends Bloc<SearchResultGoodsListEvent, SearchR
if (!EmptyUtil.isEmpty(result)) { if (!EmptyUtil.isEmpty(result)) {
yield SearchResultGoodsListChangeStyleState(result['style'], result['datas']); yield SearchResultGoodsListChangeStyleState(result['style'], result['datas']);
} else { } else {
// yield SearchResultGoodsListNoMoreDataState();
yield SearchResultGoodsListErrorState();
} }
} }




+ 2
- 2
lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart View File

@@ -88,7 +88,7 @@ class SearchResultGoodsListRepository {
var result = await NetUtil.post(url, var result = await NetUtil.post(url,
params: { params: {
'keyword': keyword, 'keyword': keyword,
'size': MAX.toString(),
// 'size': MAX.toString(),
'p': _currentPage.toString(), 'p': _currentPage.toString(),
}, },
method: NetMethod.POST); method: NetMethod.POST);
@@ -96,7 +96,7 @@ class SearchResultGoodsListRepository {
// search_list // search_list
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
List data = List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['search_list']); List data = List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['search_list']);
if (data.length >= MAX) {
if ((data?.length ?? 0) > 0) {
_hasNomore = true; _hasNomore = true;
++_currentPage; ++_currentPage;
} else { } else {


Loading…
Cancel
Save