Bladeren bron

1.修复热榜序号

tags/0.0.3+6
“yanghuaxuan” 3 jaren geleden
bovenliggende
commit
b76baf7367
2 gewijzigde bestanden met toevoegingen van 123 en 111 verwijderingen
  1. +104
    -96
      lib/widgets/home/home_goods/home_goods_item_single.dart
  2. +19
    -15
      lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list.dart

+ 104
- 96
lib/widgets/home/home_goods/home_goods_item_single.dart Bestand weergeven

@@ -18,8 +18,12 @@ class HomeGoodsItemSingle extends StatelessWidget {
final double marginRight;
final double marginTop;
final double marginBottom;
final String indexImage;

HomeGoodsItemSingle(this.goods, this.style, {Key key, this.data, this.marginBottom = 4, this.marginTop = 4, this.marginLeft = 12.5, this.marginRight = 12.5}) : super(key: key) {
///排序标题

HomeGoodsItemSingle(this.goods, this.style, {Key key, this.data, this.marginBottom = 4, this.marginTop = 4, this.marginLeft = 12.5, this.marginRight = 12.5, this.indexImage})
: super(key: key) {
if (this.data != null && this.data.containsKey('data')) {
String data = this.data['data'];
Map<String, dynamic> json = Map<String, dynamic>.from(jsonDecode(data));
@@ -37,48 +41,66 @@ class HomeGoodsItemSingle extends StatelessWidget {
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => _onJumpGoodsDetails(context, goods),
child: Container(
margin: EdgeInsets.only(left: marginLeft, right: marginRight, top: marginTop, bottom: marginBottom),
padding: EdgeInsets.all(7.5),
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(7.5))),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: 126,
height: 126,
margin: EdgeInsets.only(right: 10),
child: ClipRRect(
borderRadius: BorderRadius.circular(7.5),
child: CachedNetworkImage(
imageUrl: goods.goodImage,
fit: BoxFit.fitHeight,
),
),
),
Expanded(
child: Container(
height: 126,
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: double.infinity,
child: _createTitle(),
child: Stack(
children: <Widget>[
Container(
margin: EdgeInsets.only(left: marginLeft, right: marginRight, top: marginTop, bottom: marginBottom),
padding: EdgeInsets.all(7.5),
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(7.5))),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: 126,
height: 126,
margin: EdgeInsets.only(right: 10),
child: ClipRRect(
borderRadius: BorderRadius.circular(7.5),
child: CachedNetworkImage(
imageUrl: goods.goodImage,
fit: BoxFit.fitHeight,
),
style?.listStyle?.hotRank?.isOpen == "0" ? _createShop() : Container(),
_createCupone(),
style?.listStyle?.hotRank?.isOpen == "0"? Expanded(child: Container()):Container(),
_createBottom(),
style?.listStyle?.hotRank?.isOpen == "1"? Expanded(child: Container()):Container(),
style?.listStyle?.hotRank?.isOpen == "1"? _buildHotItem():Container()
],
),
),
),
)
],
),
Expanded(
child: Container(
height: 126,
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
width: double.infinity,
child: _createTitle(),
),
style?.listStyle?.hotRank?.isOpen == "0" ? _createShop() : Container(),
_createCupone(),
style?.listStyle?.hotRank?.isOpen == "0" ? Expanded(child: Container()) : Container(),
_createBottom(),
style?.listStyle?.hotRank?.isOpen == "1" ? Expanded(child: Container()) : Container(),
style?.listStyle?.hotRank?.isOpen == "1" ? _buildHotItem() : Container()
],
),
),
)
],
),
),
style?.listStyle?.hotRank?.isOpen == "1"
? Align(
alignment: Alignment.topLeft,
child: Container(
decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(indexImage ?? ""))),
margin: EdgeInsets.only(left: 20, top: 4),
height: 30,
width: 30,
),
)
: Container(
width: 0,
height: 0,
)
],
),
);
}
@@ -288,7 +310,7 @@ class HomeGoodsItemSingle extends StatelessWidget {
_createPrice(),
_createOriginPrice(),
Expanded(child: Container()),
style?.listStyle?.hotRank?.isOpen == "0"? _createSale():Container(),
style?.listStyle?.hotRank?.isOpen == "0" ? _createSale() : Container(),
],
),
);
@@ -349,67 +371,53 @@ class HomeGoodsItemSingle extends StatelessWidget {

///热点
_buildHotItem() {
var hotRank=style?.listStyle?.hotRank;
var hotRank = style?.listStyle?.hotRank;
return Row(
children: <Widget>[
Expanded(
child: Stack(
alignment: Alignment.centerLeft,
alignment: Alignment.centerLeft,
children: <Widget>[
Row(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Container(
alignment: Alignment.centerLeft,
height: 20,
padding: EdgeInsets.only(
left: 20,
),
margin:
EdgeInsets.only(right: 20, left: 10),
color: HexColor.fromHex(
hotRank.bgColor ?? ""),
child: Text(
(goods.inorderCount??"") ,
style: TextStyle(
color: Colors.white,
fontSize: 11,
fontFamily: 'Din',
package: 'zhiying_comm'),
),
))
],
),
Container(
width: 24,
height: 24,
child: CachedNetworkImage(
imageUrl:
hotRank?.hotSaleImg ?? "",
width: 24,
height: 24,
placeholder: (context, _) =>
Container(color: Colors.yellow),
fit: BoxFit.fill,
),
),
Align(
alignment: Alignment.centerRight,
Expanded(
child: Container(
height: 24,
width: 63.5,
decoration: BoxDecoration(
image: DecorationImage(
image: CachedNetworkImageProvider(
hotRank.buyNowImg ??
""),
fit: BoxFit.fitWidth),
borderRadius:
BorderRadius.circular(20)),
margin: EdgeInsets.only(right: 0),
))
alignment: Alignment.centerLeft,
height: 20,
padding: EdgeInsets.only(
left: 20,
),
margin: EdgeInsets.only(right: 20, left: 10),
color: HexColor.fromHex(hotRank.bgColor ?? ""),
child: Text(
(goods.inorderCount ?? ""),
style: TextStyle(color: Colors.white, fontSize: 11, fontFamily: 'Din', package: 'zhiying_comm'),
),
))
],
))
),
Container(
width: 24,
height: 24,
child: CachedNetworkImage(
imageUrl: hotRank?.hotSaleImg ?? "",
width: 24,
height: 24,
placeholder: (context, _) => Container(color: Colors.yellow),
fit: BoxFit.fill,
),
),
Align(
alignment: Alignment.centerRight,
child: Container(
height: 24,
width: 63.5,
decoration: BoxDecoration(
image: DecorationImage(image: CachedNetworkImageProvider(hotRank.buyNowImg ?? ""), fit: BoxFit.fitWidth), borderRadius: BorderRadius.circular(20)),
margin: EdgeInsets.only(right: 0),
))
],
))
],
);
}


+ 19
- 15
lib/widgets/hot_ranking/hot_ranking_list/hot_ranking_list.dart Bestand weergeven

@@ -28,8 +28,7 @@ class HotRankingList extends StatefulWidget {
_HotRankingState createState() => _HotRankingState();
}

class _HotRankingState extends State<HotRankingList>
with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
class _HotRankingState extends State<HotRankingList> with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
HotRankingListBloc _bloc;
TabController _tabController;
RefreshController _refreshController;
@@ -39,7 +38,7 @@ class _HotRankingState extends State<HotRankingList>

ScrollController _scrollcontroller;

bool isFirstTime=true;
bool isFirstTime = true;

@override
void initState() {
@@ -51,14 +50,13 @@ class _HotRankingState extends State<HotRankingList>
if (_pageBloc != null) {
_pageBloc.event.listen((event) {
if (event.containsKey('type') && event['type'] == "loadData") {
if(!isFirstTime){
if (!isFirstTime) {
Loading.show(context);
}
isFirstTime=false;
isFirstTime = false;
_bloc.currentPage = 1;
_bloc.loadData(event['type_id'], _bloc.currentPage, () {});
_scrollcontroller.animateTo(0,
duration: Duration(milliseconds: 500), curve: Curves.bounceInOut);
_scrollcontroller.animateTo(0, duration: Duration(milliseconds: 500), curve: Curves.bounceInOut);
}
});
}
@@ -97,11 +95,7 @@ class _HotRankingState extends State<HotRankingList>
footer: RefreshFooter(),
child: CustomScrollView(
controller: _scrollcontroller,
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(_buildListItem,
childCount: goods.length))
],
slivers: <Widget>[SliverList(delegate: SliverChildBuilderDelegate(_buildListItem, childCount: goods.length))],
),
);
}
@@ -123,9 +117,19 @@ class _HotRankingState extends State<HotRankingList>
}

Widget _buildListItem(BuildContext context, int index) {
HomeGoodsStyleModel homeGoodsStyleModel=HomeGoodsStyleModel();
homeGoodsStyleModel.listStyle=HomeGoodsListStyleModel.fromJson(json.decode(widget.data['data']));
return HomeGoodsItemSingle(goods[index],homeGoodsStyleModel);
HomeGoodsStyleModel homeGoodsStyleModel = HomeGoodsStyleModel();
homeGoodsStyleModel.listStyle = HomeGoodsListStyleModel.fromJson(json.decode(widget.data['data']));
var indexImage;
if (homeGoodsStyleModel.listStyle.hotRankIconList != null &&
homeGoodsStyleModel.listStyle.hotRankIconList.length > 0 &&
homeGoodsStyleModel.listStyle.hotRankIconList.length - 1 >= index) {
indexImage = homeGoodsStyleModel.listStyle.hotRankIconList[index];
}
return HomeGoodsItemSingle(
goods[index],
homeGoodsStyleModel,
indexImage: indexImage,
);
// return HotRankingGoods(
// styleModel:
// HotRankingListModel.fromJson(json.decode(widget.data['data'])),


Laden…
Annuleren
Opslaan