Skip to content

Commit

Permalink
首页跳转详情
Browse files Browse the repository at this point in the history
首页跳转详情
  • Loading branch information
shaoting0730 committed Apr 2, 2019
1 parent dd765c5 commit a2ffd74
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 25 deletions.
36 changes: 27 additions & 9 deletions lib/pages/details_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provide/provide.dart';
import '../provide/details_info.dart';
Expand All @@ -8,19 +9,36 @@ class DetailsPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
_getBackInfo(context);
return Scaffold(
appBar: AppBar(title: Text('详情')),
body: Container(
child: Text(goodsId),
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
title: Text('详情')),
body: FutureBuilder(
future: _getBackInfo(context),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Container(
child: Column(
children: <Widget>[
Text(goodsId)
],
),
);
} else {
return Text('加载中');
}
},
),
);
}

void _getBackInfo(BuildContext context) async{
await Provide.value<DetailsInfoProvide>(context).getGoodsInfo(goodsId);
print('👌');

Future _getBackInfo(BuildContext context) async {
await Provide.value<DetailsInfoProvide>(context).getGoodsInfo(goodsId);
return '加载完成';
}

}
41 changes: 25 additions & 16 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,13 @@ class SwiperDiy extends StatelessWidget {
width: ScreenUtil().setWidth(750),
child: Swiper(
itemBuilder: (BuildContext context, int index) {
return Image.network('${swiperDateList[index]['image']}',
fit: BoxFit.fill);
return InkWell(
onTap: (){
Application.router.navigateTo(context, "./detail?id=${swiperDateList[index]['goodsId']}");
},
child: Image.network('${swiperDateList[index]['image']}',
fit: BoxFit.fill),
);
},
itemCount: swiperDateList.length,
pagination: SwiperPagination(),
Expand Down Expand Up @@ -297,9 +302,11 @@ class Recommend extends StatelessWidget {
}

// 商品单项weiget
Widget _item(index) {
Widget _item(index,context) {
return InkWell(
onTap: () {},
onTap: () {
Application.router.navigateTo(context, "./detail?id=${recommendList[index]['goodsId']}");
},
child: Container(
height: ScreenUtil().setHeight(330),
width: ScreenUtil().setWidth(250),
Expand Down Expand Up @@ -331,7 +338,7 @@ class Recommend extends StatelessWidget {
scrollDirection: Axis.horizontal,
itemCount: recommendList.length,
itemBuilder: (context, index) {
return _item(index);
return _item(index,context);
},
),
);
Expand Down Expand Up @@ -373,45 +380,47 @@ class FloorContent extends StatelessWidget {
return Container(
child: Column(
children: <Widget>[
_firstRow(),
_otherGoods(),
_firstRow(context),
_otherGoods(context),
],
),
);
}

// 左上 img
Widget _goodsItem(Map goods) {
Widget _goodsItem(BuildContext context,Map goods) {
return Container(
width: ScreenUtil().setWidth(375),
child: InkWell(
onTap: () {},
onTap: () {
Application.router.navigateTo(context, "./detail?id=${goods['goodsId']}");
},
child: Image.network(goods['image']),
),
);
}

// 上部
Widget _firstRow() {
Widget _firstRow(context) {
return Row(
children: <Widget>[
_goodsItem(floorGoodsList[0]),
_goodsItem(context,floorGoodsList[0]),
Column(
children: <Widget>[
_goodsItem(floorGoodsList[1]),
_goodsItem(floorGoodsList[2]),
_goodsItem(context,floorGoodsList[1]),
_goodsItem(context,floorGoodsList[2]),
],
)
],
);
}

//下部
Widget _otherGoods() {
Widget _otherGoods(context) {
return Row(
children: <Widget>[
_goodsItem(floorGoodsList[3]),
_goodsItem(floorGoodsList[4]),
_goodsItem(context,floorGoodsList[3]),
_goodsItem(context,floorGoodsList[4]),
],
);
}
Expand Down

0 comments on commit a2ffd74

Please sign in to comment.