|
|
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
import '../util/api.dart';
|
|
|
import '../util/models.dart';
|
|
|
+import '../showDialog.dart';
|
|
|
|
|
|
class OrderTakingPage extends StatefulWidget {
|
|
|
|
|
|
@@ -14,9 +15,10 @@ class OrderTakingPage extends StatefulWidget {
|
|
|
|
|
|
class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeepAliveClientMixin {
|
|
|
|
|
|
- ScrollController _scrollController =ScrollController();//初始化滚动轴监控对象
|
|
|
+ ScrollController _scrollController = ScrollController(); //初始化滚动轴监控对象
|
|
|
List listObj = [];
|
|
|
|
|
|
+
|
|
|
@override
|
|
|
void initState() {
|
|
|
// TODO: implement initState
|
|
|
@@ -26,8 +28,8 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
listObj = resp.orderList;
|
|
|
});
|
|
|
});
|
|
|
- _scrollController.addListener((){
|
|
|
- if(_scrollController.position.pixels==_scrollController.position.maxScrollExtent){
|
|
|
+ _scrollController.addListener(() {
|
|
|
+ if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
|
|
|
print("滑到底部了");
|
|
|
getOrderList().then((resp) {
|
|
|
setState(() {
|
|
|
@@ -40,6 +42,17 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @override
|
|
|
+ bool get wantKeepAlive => true;
|
|
|
+
|
|
|
+ @override
|
|
|
+ void dispose() {
|
|
|
+ // TODO: implement dispose
|
|
|
+ super.dispose();
|
|
|
+ _scrollController.dispose();
|
|
|
+ print('接单页listView滚动监听销毁了');
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
super.build(context);
|
|
|
@@ -79,15 +92,15 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
decoration: BoxDecoration(
|
|
|
color: Color.fromRGBO(246, 246, 254, 1)
|
|
|
),
|
|
|
- child: RefreshIndicator(//下拉刷新组件
|
|
|
- onRefresh: _onRefresh,//回调方法
|
|
|
+ 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]);
|
|
|
- }
|
|
|
+ itemCount: listObj.length + 1,
|
|
|
+ itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
|
|
|
+ if (index < listObj.length) {
|
|
|
+ return OrderCardContainer(order:listObj[index],index:index,callback:(val)=>deleteOrder(val));
|
|
|
+ }
|
|
|
return _getMoreWidget();
|
|
|
},
|
|
|
)
|
|
|
@@ -104,7 +117,7 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
- children: <Widget>[
|
|
|
+ children: < Widget > [
|
|
|
Text(
|
|
|
'加载中...',
|
|
|
style: TextStyle(fontSize: 16.0),
|
|
|
@@ -118,61 +131,39 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- Future<Null> _onRefresh() async {
|
|
|
- await getOrderList().then((resp) {
|
|
|
+ Future < Null > _onRefresh() async {
|
|
|
+ await getOrderList().then((resp) {
|
|
|
setState(() {
|
|
|
listObj = resp.orderList;
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- @override
|
|
|
- bool get wantKeepAlive => true;
|
|
|
-
|
|
|
- @override
|
|
|
- void dispose() {
|
|
|
- // TODO: implement dispose
|
|
|
- super.dispose();
|
|
|
- _scrollController.dispose();
|
|
|
- print('接单页listView滚动监听销毁了');
|
|
|
+ void deleteOrder(val){
|
|
|
+ setState(() {
|
|
|
+ listObj.removeAt(val);
|
|
|
+ if(listObj.length<4){
|
|
|
+ getOrderList().then((resp) {
|
|
|
+ setState(() {
|
|
|
+ listObj.addAll(resp.orderList);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
-
|
|
|
-class OrderCard extends StatefulWidget {
|
|
|
- final OrderList order;
|
|
|
-
|
|
|
- OrderCard({
|
|
|
- Key key,
|
|
|
- @required this.order
|
|
|
- }): super(key: key);
|
|
|
-
|
|
|
- _OrderCardState createState() => _OrderCardState();
|
|
|
}
|
|
|
|
|
|
-class _OrderCardState extends State < OrderCard > {
|
|
|
- @override
|
|
|
- Widget build(BuildContext context) {
|
|
|
- return Card(
|
|
|
- color: Colors.white,
|
|
|
- elevation: 3.0,
|
|
|
- child: Column(
|
|
|
- children: < Widget > [
|
|
|
- OrderCardContainer(order: widget.order)
|
|
|
- ],
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
class OrderCardContainer extends StatefulWidget {
|
|
|
final OrderList order;
|
|
|
-
|
|
|
+ final int index;
|
|
|
+ final callback;
|
|
|
OrderCardContainer({
|
|
|
Key key,
|
|
|
- @required this.order
|
|
|
+ @required this.order,
|
|
|
+ @required this.index,
|
|
|
+ @required this.callback
|
|
|
}): super(key: key);
|
|
|
|
|
|
_OrderCardContainerState createState() => _OrderCardContainerState();
|
|
|
@@ -208,19 +199,23 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return Container(
|
|
|
- padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), 0),
|
|
|
- child: Column(
|
|
|
- children: < Widget > [
|
|
|
- orderNoRow(widget.order.orderNo, widget.order.createTime),
|
|
|
- orderAddress(widget.order.startAddress, widget.order.endAddress),
|
|
|
- orderItem('货物名称', widget.order.itemName, 15),
|
|
|
- orderItem('货物件数', '${widget.order.itemNo}件', 30),
|
|
|
- orderCutLine(),
|
|
|
- orderBtn(animationStatus, controller, str),
|
|
|
- AnimatedOpen(animation: animation, openInfo: widget.order, )
|
|
|
- ],
|
|
|
- ),
|
|
|
+ return Card(
|
|
|
+ color: Colors.white,
|
|
|
+ elevation: 3.0,
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(30), 0),
|
|
|
+ child: Column(
|
|
|
+ children: < Widget > [
|
|
|
+ orderNoRow(widget.order.orderNo,widget.order.createTime),
|
|
|
+ orderAddress(widget.order.startAddress,widget.order.endAddress),
|
|
|
+ orderItem('货物名称', widget.order.itemName, 15),
|
|
|
+ orderItem('货物件数', '${widget.order.itemNo}件', 30),
|
|
|
+ orderCutLine(),
|
|
|
+ orderBtn(context, animationStatus, controller, str),
|
|
|
+ AnimatedOpen(animation: animation, openInfo: widget.order, )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ )
|
|
|
);
|
|
|
}
|
|
|
dispose() {
|
|
|
@@ -228,54 +223,70 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
|
|
|
controller.dispose();
|
|
|
super.dispose();
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-Widget orderBtn(bool animationStatus, AnimationController controller, String str) {
|
|
|
- return Container(
|
|
|
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: < Widget > [
|
|
|
- GestureDetector(
|
|
|
- child: Container(
|
|
|
- width: ScreenUtil.getInstance().setWidth(100),
|
|
|
- height: ScreenUtil.getInstance().setHeight(48),
|
|
|
- color: Colors.white,
|
|
|
- child: Center(
|
|
|
- child: Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1)), ),
|
|
|
- )
|
|
|
- ),
|
|
|
- onTap: () {
|
|
|
- if (animationStatus) {
|
|
|
- //动画恢复到初始状态时执行动画(正向)
|
|
|
- controller.forward();
|
|
|
- } else {
|
|
|
- //动画执行结束时反向执行动画
|
|
|
- controller.reverse();
|
|
|
- }
|
|
|
- },
|
|
|
- ),
|
|
|
- GestureDetector(
|
|
|
- child: Container(
|
|
|
- width: ScreenUtil.getInstance().setWidth(94),
|
|
|
- height: ScreenUtil.getInstance().setWidth(48),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Color.fromRGBO(252, 97, 128, 1),
|
|
|
- borderRadius: BorderRadius.all(Radius.circular(4.0))
|
|
|
- ),
|
|
|
- child: Center(
|
|
|
- child: Text("接单", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Colors.white), ),
|
|
|
+ Widget orderBtn(BuildContext context, bool animationStatus, AnimationController controller, String str) {
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: < Widget > [
|
|
|
+ GestureDetector(
|
|
|
+ child: Container(
|
|
|
+ width: ScreenUtil.getInstance().setWidth(100),
|
|
|
+ height: ScreenUtil.getInstance().setHeight(48),
|
|
|
+ color: Colors.white,
|
|
|
+ child: Center(
|
|
|
+ child: Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Color.fromRGBO(64, 98, 254, 1)), ),
|
|
|
+ )
|
|
|
),
|
|
|
+ onTap: () {
|
|
|
+ if (animationStatus) {
|
|
|
+ //动画恢复到初始状态时执行动画(正向)
|
|
|
+ controller.forward();
|
|
|
+ } else {
|
|
|
+ //动画执行结束时反向执行动画
|
|
|
+ controller.reverse();
|
|
|
+ }
|
|
|
+ },
|
|
|
),
|
|
|
- onTap: () {
|
|
|
- print("22222");
|
|
|
- },
|
|
|
- )
|
|
|
- ],
|
|
|
- )
|
|
|
- );
|
|
|
+ GestureDetector(
|
|
|
+ child: Container(
|
|
|
+ width: ScreenUtil.getInstance().setWidth(94),
|
|
|
+ height: ScreenUtil.getInstance().setWidth(48),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Color.fromRGBO(252, 97, 128, 1),
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(4.0))
|
|
|
+ ),
|
|
|
+ child: Center(
|
|
|
+ child: Text("接单", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(24), color: Colors.white), ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ showDialog < Null > (
|
|
|
+ context: context, //BuildContext对象
|
|
|
+ barrierDismissible: false,
|
|
|
+ builder: (BuildContext context) {
|
|
|
+ return new LoadingDialog( //调用对话框
|
|
|
+ text:'是否确认接单',childCallback: (val){
|
|
|
+ if(val){
|
|
|
+ widget.callback(widget.index);
|
|
|
+ }else{
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ );
|
|
|
+ });
|
|
|
+ },
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
class AnimatedOpen extends AnimatedWidget {
|
|
|
final OrderList openInfo;
|
|
|
AnimatedOpen({
|