|
@@ -12,20 +12,32 @@ class OrderTakingPage extends StatefulWidget {
|
|
|
_OrderTakingPageState createState() => _OrderTakingPageState();
|
|
_OrderTakingPageState createState() => _OrderTakingPageState();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeepAliveClientMixin {
|
|
|
|
|
-
|
|
|
|
|
- List listObj=[];
|
|
|
|
|
|
|
+class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeepAliveClientMixin {
|
|
|
|
|
+
|
|
|
|
|
+ ScrollController _scrollController =ScrollController();//初始化滚动轴监控对象
|
|
|
|
|
+ List listObj = [];
|
|
|
|
|
|
|
|
@override
|
|
@override
|
|
|
void initState() {
|
|
void initState() {
|
|
|
// TODO: implement initState
|
|
// TODO: implement initState
|
|
|
super.initState();
|
|
super.initState();
|
|
|
- getOrderList().then((resp){
|
|
|
|
|
|
|
+ getOrderList().then((resp) {
|
|
|
setState(() {
|
|
setState(() {
|
|
|
listObj = resp.orderList;
|
|
listObj = resp.orderList;
|
|
|
});
|
|
});
|
|
|
- //print(listObj[0].id);
|
|
|
|
|
});
|
|
});
|
|
|
|
|
+ _scrollController.addListener((){
|
|
|
|
|
+ if(_scrollController.position.pixels==_scrollController.position.maxScrollExtent){
|
|
|
|
|
+ print("滑到底部了");
|
|
|
|
|
+ getOrderList().then((resp) {
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ listObj.addAll(resp.orderList);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ //print(_scrollController.position.pixels);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
@override
|
|
@@ -39,55 +51,103 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKee
|
|
|
backgroundColor: Color.fromRGBO(64, 98, 254, 1),
|
|
backgroundColor: Color.fromRGBO(64, 98, 254, 1),
|
|
|
actions: < Widget > [
|
|
actions: < Widget > [
|
|
|
Container(
|
|
Container(
|
|
|
- child: PopupMenuButton<String>(
|
|
|
|
|
- icon: Icon(Icons.add_circle_outline),
|
|
|
|
|
- offset: Offset(0, 60),
|
|
|
|
|
- padding: EdgeInsets.zero,
|
|
|
|
|
- //child: IconButton(icon: Image.asset('lib/images/icon_shaixuan.png', scale: 1.8, ),onPressed: (){},),
|
|
|
|
|
- itemBuilder: (BuildContext context)=><PopupMenuEntry<String>>[
|
|
|
|
|
- PopupMenuItem<String>(
|
|
|
|
|
- child:Text("hahahahahh"),
|
|
|
|
|
- ),
|
|
|
|
|
- PopupMenuDivider(height: 1.0),
|
|
|
|
|
- PopupMenuItem<String>(
|
|
|
|
|
- child:Text("hahahahahh"),
|
|
|
|
|
- ),
|
|
|
|
|
- PopupMenuDivider(height: 1.0),
|
|
|
|
|
- PopupMenuItem<String>(
|
|
|
|
|
- child:Text("hahahahahh"),
|
|
|
|
|
- ),
|
|
|
|
|
- PopupMenuDivider(height: 1.0),
|
|
|
|
|
- ]
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ child: PopupMenuButton < String > (
|
|
|
|
|
+ icon: Icon(Icons.add_circle_outline),
|
|
|
|
|
+ offset: Offset(0, 60),
|
|
|
|
|
+ padding: EdgeInsets.zero,
|
|
|
|
|
+ //child: IconButton(icon: Image.asset('lib/images/icon_shaixuan.png', scale: 1.8, ),onPressed: (){},),
|
|
|
|
|
+ itemBuilder: (BuildContext context) => < PopupMenuEntry < String >> [
|
|
|
|
|
+ PopupMenuItem < String > (
|
|
|
|
|
+ child: Text("hahahahahh"),
|
|
|
|
|
+ ),
|
|
|
|
|
+ PopupMenuDivider(height: 1.0),
|
|
|
|
|
+ PopupMenuItem < String > (
|
|
|
|
|
+ child: Text("hahahahahh"),
|
|
|
|
|
+ ),
|
|
|
|
|
+ PopupMenuDivider(height: 1.0),
|
|
|
|
|
+ PopupMenuItem < String > (
|
|
|
|
|
+ child: Text("hahahahahh"),
|
|
|
|
|
+ ),
|
|
|
|
|
+ PopupMenuDivider(height: 1.0),
|
|
|
|
|
+ ]
|
|
|
|
|
+ )
|
|
|
),
|
|
),
|
|
|
],
|
|
],
|
|
|
),
|
|
),
|
|
|
body: Container(
|
|
body: Container(
|
|
|
- padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
|
|
|
|
|
|
|
+ padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
|
|
|
decoration: BoxDecoration(
|
|
decoration: BoxDecoration(
|
|
|
color: Color.fromRGBO(246, 246, 254, 1)
|
|
color: Color.fromRGBO(246, 246, 254, 1)
|
|
|
),
|
|
),
|
|
|
- child: ListView.builder(
|
|
|
|
|
- itemCount: listObj.length,
|
|
|
|
|
- itemBuilder: (BuildContext context,int index){
|
|
|
|
|
- return OrderCard(order:listObj[index]);
|
|
|
|
|
|
|
+ child: RefreshIndicator(//下拉刷新组件
|
|
|
|
|
+ onRefresh: _onRefresh,//回调方法
|
|
|
|
|
+ child: ListView.builder(
|
|
|
|
|
+ controller: _scrollController,
|
|
|
|
|
+ itemCount: listObj.length+1,
|
|
|
|
|
+ itemBuilder: (BuildContext context, int index) {//itemBuilder实际上就是一个map的循环
|
|
|
|
|
+ if(index<listObj.length){
|
|
|
|
|
+ return OrderCard(order: listObj[index]);
|
|
|
|
|
+ }
|
|
|
|
|
+ return _getMoreWidget();
|
|
|
},
|
|
},
|
|
|
|
|
+ )
|
|
|
),
|
|
),
|
|
|
)
|
|
)
|
|
|
),
|
|
),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ Widget _getMoreWidget() {
|
|
|
|
|
+ return Center(
|
|
|
|
|
+ child: Padding(
|
|
|
|
|
+ padding: EdgeInsets.all(10.0),
|
|
|
|
|
+ child: Row(
|
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
+ children: <Widget>[
|
|
|
|
|
+ Text(
|
|
|
|
|
+ '加载中...',
|
|
|
|
|
+ style: TextStyle(fontSize: 16.0),
|
|
|
|
|
+ ),
|
|
|
|
|
+ CircularProgressIndicator(
|
|
|
|
|
+ strokeWidth: 1.0,
|
|
|
|
|
+ )
|
|
|
|
|
+ ],
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Future<Null> _onRefresh() async {
|
|
|
|
|
+ await getOrderList().then((resp) {
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ listObj = resp.orderList;
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@override
|
|
@override
|
|
|
bool get wantKeepAlive => true;
|
|
bool get wantKeepAlive => true;
|
|
|
|
|
+
|
|
|
|
|
+ @override
|
|
|
|
|
+ void dispose() {
|
|
|
|
|
+ // TODO: implement dispose
|
|
|
|
|
+ super.dispose();
|
|
|
|
|
+ _scrollController.dispose();
|
|
|
|
|
+ print('接单页listView滚动监听销毁了');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class OrderCard extends StatefulWidget {
|
|
class OrderCard extends StatefulWidget {
|
|
|
final OrderList order;
|
|
final OrderList order;
|
|
|
-
|
|
|
|
|
- OrderCard({Key key,@required this.order}): super(key: key);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ OrderCard({
|
|
|
|
|
+ Key key,
|
|
|
|
|
+ @required this.order
|
|
|
|
|
+ }): super(key: key);
|
|
|
|
|
|
|
|
_OrderCardState createState() => _OrderCardState();
|
|
_OrderCardState createState() => _OrderCardState();
|
|
|
}
|
|
}
|
|
@@ -110,7 +170,10 @@ class _OrderCardState extends State < OrderCard > {
|
|
|
class OrderCardContainer extends StatefulWidget {
|
|
class OrderCardContainer extends StatefulWidget {
|
|
|
final OrderList order;
|
|
final OrderList order;
|
|
|
|
|
|
|
|
- OrderCardContainer({Key key, @required this.order}): super(key: key);
|
|
|
|
|
|
|
+ OrderCardContainer({
|
|
|
|
|
+ Key key,
|
|
|
|
|
+ @required this.order
|
|
|
|
|
+ }): super(key: key);
|
|
|
|
|
|
|
|
_OrderCardContainerState createState() => _OrderCardContainerState();
|
|
_OrderCardContainerState createState() => _OrderCardContainerState();
|
|
|
}
|
|
}
|
|
@@ -118,57 +181,57 @@ class OrderCardContainer extends StatefulWidget {
|
|
|
class _OrderCardContainerState extends State < OrderCardContainer > with SingleTickerProviderStateMixin {
|
|
class _OrderCardContainerState extends State < OrderCardContainer > with SingleTickerProviderStateMixin {
|
|
|
Animation < double > animation;
|
|
Animation < double > animation;
|
|
|
AnimationController controller;
|
|
AnimationController controller;
|
|
|
- String str="联系方式";
|
|
|
|
|
- bool animationStatus =true;
|
|
|
|
|
|
|
+ String str = "联系方式";
|
|
|
|
|
+ bool animationStatus = true;
|
|
|
@override
|
|
@override
|
|
|
initState() {
|
|
initState() {
|
|
|
super.initState();
|
|
super.initState();
|
|
|
controller = new AnimationController(
|
|
controller = new AnimationController(
|
|
|
- duration: const Duration(milliseconds: 200), vsync: this);
|
|
|
|
|
|
|
+ duration: const Duration(milliseconds: 200), vsync: this);
|
|
|
animation = new Tween(begin: 0.0, end: 230.0).animate(controller);
|
|
animation = new Tween(begin: 0.0, end: 230.0).animate(controller);
|
|
|
- animation.addStatusListener((status){
|
|
|
|
|
|
|
+ animation.addStatusListener((status) {
|
|
|
if (status == AnimationStatus.completed) {
|
|
if (status == AnimationStatus.completed) {
|
|
|
//动画执行结束时反向执行动画
|
|
//动画执行结束时反向执行动画
|
|
|
- setState(() {
|
|
|
|
|
- animationStatus = false;
|
|
|
|
|
- str="收起";
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ animationStatus = false;
|
|
|
|
|
+ str = "收起";
|
|
|
|
|
+ });
|
|
|
} else if (status == AnimationStatus.dismissed) {
|
|
} else if (status == AnimationStatus.dismissed) {
|
|
|
//动画恢复到初始状态时执行动画(正向)
|
|
//动画恢复到初始状态时执行动画(正向)
|
|
|
- setState(() {
|
|
|
|
|
- animationStatus=true;
|
|
|
|
|
- str="联系方式";
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ animationStatus = true;
|
|
|
|
|
+ str = "联系方式";
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@override
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
|
return Container(
|
|
return Container(
|
|
|
padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), 0),
|
|
padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), 0),
|
|
|
child: Column(
|
|
child: Column(
|
|
|
children: < Widget > [
|
|
children: < Widget > [
|
|
|
- orderNoRow(widget.order.orderNo,widget.order.createTime),
|
|
|
|
|
- orderAddress(widget.order.startAddress,widget.order.endAddress),
|
|
|
|
|
|
|
+ orderNoRow(widget.order.orderNo, widget.order.createTime),
|
|
|
|
|
+ orderAddress(widget.order.startAddress, widget.order.endAddress),
|
|
|
orderItem('货物名称', widget.order.itemName, 15),
|
|
orderItem('货物名称', widget.order.itemName, 15),
|
|
|
orderItem('货物件数', '${widget.order.itemNo}件', 30),
|
|
orderItem('货物件数', '${widget.order.itemNo}件', 30),
|
|
|
orderCutLine(),
|
|
orderCutLine(),
|
|
|
- orderBtn(animationStatus,controller,str),
|
|
|
|
|
- AnimatedOpen(animation: animation,openInfo: widget.order,)
|
|
|
|
|
|
|
+ orderBtn(animationStatus, controller, str),
|
|
|
|
|
+ AnimatedOpen(animation: animation, openInfo: widget.order, )
|
|
|
],
|
|
],
|
|
|
),
|
|
),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
- dispose() {
|
|
|
|
|
|
|
+ dispose() {
|
|
|
//路由销毁时需要释放动画资源
|
|
//路由销毁时需要释放动画资源
|
|
|
controller.dispose();
|
|
controller.dispose();
|
|
|
super.dispose();
|
|
super.dispose();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Widget orderBtn(bool animationStatus,AnimationController controller,String str){
|
|
|
|
|
- return Container(
|
|
|
|
|
|
|
+Widget orderBtn(bool animationStatus, AnimationController controller, String str) {
|
|
|
|
|
+ return Container(
|
|
|
margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
|
|
margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
|
|
|
child: Row(
|
|
child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
@@ -183,13 +246,13 @@ Widget orderBtn(bool animationStatus,AnimationController controller,String str){
|
|
|
)
|
|
)
|
|
|
),
|
|
),
|
|
|
onTap: () {
|
|
onTap: () {
|
|
|
- if (animationStatus) {
|
|
|
|
|
- //动画恢复到初始状态时执行动画(正向)
|
|
|
|
|
- controller.forward();
|
|
|
|
|
- } else{
|
|
|
|
|
- //动画执行结束时反向执行动画
|
|
|
|
|
- controller.reverse();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (animationStatus) {
|
|
|
|
|
+ //动画恢复到初始状态时执行动画(正向)
|
|
|
|
|
+ controller.forward();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //动画执行结束时反向执行动画
|
|
|
|
|
+ controller.reverse();
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
),
|
|
),
|
|
|
GestureDetector(
|
|
GestureDetector(
|
|
@@ -229,7 +292,7 @@ class AnimatedOpen extends AnimatedWidget {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-Widget orderNoRow(int orderNo,String createTime) { //订单号及时间
|
|
|
|
|
|
|
+Widget orderNoRow(int orderNo, String createTime) { //订单号及时间
|
|
|
return Container(
|
|
return Container(
|
|
|
margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
|
|
margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
|
|
|
child: Row(
|
|
child: Row(
|
|
@@ -242,7 +305,7 @@ Widget orderNoRow(int orderNo,String createTime) { //订单号及时间
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Widget orderAddress(String startAddress,String endAddress) { //运送路线
|
|
|
|
|
|
|
+Widget orderAddress(String startAddress, String endAddress) { //运送路线
|
|
|
return Container(
|
|
return Container(
|
|
|
margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
|
|
margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
|
|
|
child: Row(children: < Widget > [
|
|
child: Row(children: < Widget > [
|
|
@@ -260,7 +323,7 @@ Widget orderCutLine() { //分割线
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-Widget orderDetailInfo(OrderList obj) {//卡片展开信息
|
|
|
|
|
|
|
+Widget orderDetailInfo(OrderList obj) { //卡片展开信息
|
|
|
return Container(
|
|
return Container(
|
|
|
child: Wrap(
|
|
child: Wrap(
|
|
|
children: < Widget > [
|
|
children: < Widget > [
|
|
@@ -274,7 +337,7 @@ Widget orderDetailInfo(OrderList obj) {//卡片展开信息
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Widget orderItem(String key, String value, int marginBottom) {//货物名称,件数
|
|
|
|
|
|
|
+Widget orderItem(String key, String value, int marginBottom) { //货物名称,件数
|
|
|
return Container(
|
|
return Container(
|
|
|
margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(marginBottom)),
|
|
margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(marginBottom)),
|
|
|
child: Row(children: < Widget > [
|
|
child: Row(children: < Widget > [
|
|
@@ -291,4 +354,4 @@ Widget orderPhone(String key, String value, int marginBottom) {
|
|
|
Text('${value}', style: TextStyle(color: Color.fromRGBO(64, 98, 254, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
|
|
Text('${value}', style: TextStyle(color: Color.fromRGBO(64, 98, 254, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
|
|
|
], )
|
|
], )
|
|
|
);
|
|
);
|
|
|
-}
|
|
|
|
|
|
|
+}
|