Переглянути джерело

更新商品详情,推荐列表重用

tags/0.0.1
Weller 4 роки тому
джерело
коміт
414671863c
1 змінених файлів з 42 додано та 42 видалено
  1. +42
    -42
      lib/widgets/goods_details/recommend/goods_detail_commend_list.dart

+ 42
- 42
lib/widgets/goods_details/recommend/goods_detail_commend_list.dart Переглянути файл

@@ -72,7 +72,9 @@ class _GoodsDetailCommendListContainerState
super.didChangeDependencies(); super.didChangeDependencies();
print('didChangeDependencies'); print('didChangeDependencies');
bool isNeedLoadMore = bool isNeedLoadMore =
Provider.of<GoodsDetailsPageNotifier>(context).scrollEnd;
Provider
.of<GoodsDetailsPageNotifier>(context)
.scrollEnd;
if (isNeedLoadMore && _provider != '') { if (isNeedLoadMore && _provider != '') {
print('HomeGoods loadmore...'); print('HomeGoods loadmore...');
_bloc.loadMore(_provider); _bloc.loadMore(_provider);
@@ -81,52 +83,50 @@ class _GoodsDetailCommendListContainerState


@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container(
width: double.infinity,
child: StreamBuilder<List<HomeGoodsModel>>(
return StreamBuilder<List<HomeGoodsModel>>(
stream: _bloc.outData, stream: _bloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) { builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.data == null) {
return Container();
}
// if (snapshot.data == null) {
// return Container();
// }


List<HomeGoodsModel> goods = snapshot.data; List<HomeGoodsModel> goods = snapshot.data;
int column = 2; int column = 2;
int count = (goods.length / column).ceil();
return ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: count,
itemBuilder: (context, index) {
if (column == 1) {
return HomeGoodsItemSingle(
goods[index],
_style,
data: widget.data,
);
} else {
// return Container(color: Colors.red, height: 126,margin: EdgeInsets.all(10),);
return Padding(
padding: const EdgeInsets.only(left: 5, right: 5),
child: Row(
children: List.generate(column, (c) {
int i = index * column + c;
return Expanded(
child: i < goods.length
? HomeGoodsItem(
goods[i],
_style,
data: widget.data,
)
: Container(),
);
}).toList(),
),
);
}
});
},
),
int count = ((goods?.length ?? 0) / column).ceil();
return SliverList(
delegate: SliverChildBuilderDelegate((context, index) {
if (column == 1) {
return HomeGoodsItemSingle(
goods[index],
_style,
data: widget.data,
);
} else {
// return Container(color: Colors.red, height: 126,margin: EdgeInsets.all(10),);
return Padding(
padding: const EdgeInsets.only(left: 5, right: 5),
child: Row(
children: List.generate(column, (c) {
int i = index * column + c;
return Expanded(
child: i < goods.length
? HomeGoodsItem(
goods[i],
_style,
data: widget.data,
)
: Container(),
);
}).toList(),
),
);
}
}, childCount
:
count
,
),);
}
); );
} }
} }

Завантаження…
Відмінити
Зберегти