|
@@ -19,40 +19,30 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
|
|
|
|
|
ScrollController _scrollController = ScrollController(); //初始化滚动轴监控对象
|
|
ScrollController _scrollController = ScrollController(); //初始化滚动轴监控对象
|
|
|
List listObj = [];
|
|
List listObj = [];
|
|
|
- List lineList=[];
|
|
|
|
|
- List<PopupMenuEntry<String>> widgets=[];
|
|
|
|
|
|
|
+ List lineList = [];
|
|
|
|
|
+ String stationId;
|
|
|
|
|
+ List < bool > checkStatusList = [];
|
|
|
|
|
+ bool showLineStatus = true;
|
|
|
@override
|
|
@override
|
|
|
void initState() {
|
|
void initState() {
|
|
|
super.initState();
|
|
super.initState();
|
|
|
- getOrderList().then((resp) {
|
|
|
|
|
- setState(() {
|
|
|
|
|
- listObj = resp.orderList;
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // getOrderList().then((resp) {
|
|
|
|
|
+ // setState(() {
|
|
|
|
|
+ // listObj = resp.orderList;
|
|
|
|
|
+ // });
|
|
|
|
|
+ // });
|
|
|
getKey('stationId').then((value){
|
|
getKey('stationId').then((value){
|
|
|
- getLineFromStation(value).then((resp){
|
|
|
|
|
- if(resp.success && resp.code==1){
|
|
|
|
|
- setState(() {
|
|
|
|
|
- lineList = resp.data;
|
|
|
|
|
- });
|
|
|
|
|
- List<PopupMenuEntry<String>> tempWidgets = [];
|
|
|
|
|
- for(int i=0;i<lineList.length;i++){
|
|
|
|
|
- tempWidgets.add(
|
|
|
|
|
- PopupMenuItem<String>(
|
|
|
|
|
- value: lineList[i].name,
|
|
|
|
|
- child: Text(lineList[i].name,)
|
|
|
|
|
- )
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
- print(lineList.length);
|
|
|
|
|
- setState(() {
|
|
|
|
|
- widgets =tempWidgets;
|
|
|
|
|
- });
|
|
|
|
|
- print(widgets.length);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ stationId = value;
|
|
|
});
|
|
});
|
|
|
|
|
+ getLine(value);
|
|
|
});
|
|
});
|
|
|
_scrollController.addListener(() {
|
|
_scrollController.addListener(() {
|
|
|
|
|
+ if(!showLineStatus){
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ showLineStatus = true;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
|
|
if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {
|
|
|
print("滑到底部了");
|
|
print("滑到底部了");
|
|
|
// getOrderList().then((resp) {
|
|
// getOrderList().then((resp) {
|
|
@@ -63,18 +53,31 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
}
|
|
}
|
|
|
//print(_scrollController.position.pixels);
|
|
//print(_scrollController.position.pixels);
|
|
|
});
|
|
});
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ void getLine(value){
|
|
|
|
|
+ getLineFromStation(value).then((resp) {
|
|
|
|
|
+ if (resp.success && resp.code == 1) {
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ checkStatusList = [];
|
|
|
|
|
+ lineList = resp.data;
|
|
|
|
|
+ for(int i=0;i<lineList.length;i++){
|
|
|
|
|
+ if(i==0){
|
|
|
|
|
+ checkStatusList.add(true);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ checkStatusList.add(false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ stationId = value;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
@override
|
|
|
bool get wantKeepAlive => true;
|
|
bool get wantKeepAlive => true;
|
|
|
|
|
|
|
|
- @override
|
|
|
|
|
- void dispose() {
|
|
|
|
|
- super.dispose();
|
|
|
|
|
- _scrollController.dispose();
|
|
|
|
|
- print('接单页listView滚动监听销毁了');
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
@override
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
@@ -86,48 +89,112 @@ class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeep
|
|
|
centerTitle: true,
|
|
centerTitle: true,
|
|
|
backgroundColor: Color.fromRGBO(64, 98, 254, 1),
|
|
backgroundColor: Color.fromRGBO(64, 98, 254, 1),
|
|
|
actions: < Widget > [
|
|
actions: < Widget > [
|
|
|
- Container(
|
|
|
|
|
- child: PopupMenuButton(
|
|
|
|
|
- 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){
|
|
|
|
|
- return widgets;
|
|
|
|
|
- // <PopupMenuEntry<String>>[
|
|
|
|
|
- // PopupMenuItem<String>(
|
|
|
|
|
- // value: '1111',
|
|
|
|
|
- // child: Text('lineList[0].name',)
|
|
|
|
|
- // )
|
|
|
|
|
- // ];
|
|
|
|
|
|
|
+ IconButton(icon: Icon(Icons.add_circle_outline),
|
|
|
|
|
+ onPressed: () {
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ showLineStatus = !showLineStatus;
|
|
|
|
|
+ });
|
|
|
|
|
+ if (!showLineStatus) {
|
|
|
|
|
+ getKey('stationId').then((value) {
|
|
|
|
|
+ if(stationId!=value){
|
|
|
|
|
+ getLine(value);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- )
|
|
|
|
|
- ),
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ }, )
|
|
|
|
|
+ ]
|
|
|
),
|
|
),
|
|
|
- body: Container(
|
|
|
|
|
- padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
|
|
|
|
|
- decoration: BoxDecoration(
|
|
|
|
|
- color: Color.fromRGBO(246, 246, 254, 1)
|
|
|
|
|
- ),
|
|
|
|
|
- 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 OrderCardContainer(order: listObj[index], index: index, callback: (val) => deleteOrder(val));
|
|
|
|
|
- }
|
|
|
|
|
- return _getMoreWidget();
|
|
|
|
|
|
|
+ body: Stack(
|
|
|
|
|
+ children: < Widget > [
|
|
|
|
|
+ InkWell(
|
|
|
|
|
+ child: Container(
|
|
|
|
|
+ padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), ScreenUtil.getInstance().setWidth(20), 0),
|
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
|
+ color: Color.fromRGBO(246, 246, 254, 1)
|
|
|
|
|
+ ),
|
|
|
|
|
+ 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 OrderCardContainer(order: listObj[index], index: index, callback: (val) => deleteOrder(val));
|
|
|
|
|
+ }
|
|
|
|
|
+ return _getMoreWidget();
|
|
|
|
|
+ },
|
|
|
|
|
+ )
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ onTap: () {
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ showLineStatus = true;
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
|
|
+ ),
|
|
|
|
|
+ Positioned(
|
|
|
|
|
+ top: 0,
|
|
|
|
|
+ right: 0,
|
|
|
|
|
+ child:
|
|
|
|
|
+ Offstage(
|
|
|
|
|
+ offstage: showLineStatus,
|
|
|
|
|
+ child: Container(
|
|
|
|
|
+ width: ScreenUtil.getInstance().setWidth(350),
|
|
|
|
|
+ height: ScreenUtil.getInstance().setHeight(500),
|
|
|
|
|
+ margin: EdgeInsets.fromLTRB(0, 1, 1, 0),
|
|
|
|
|
+ padding: EdgeInsets.fromLTRB(1, 0, 1, 0),
|
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
|
+ color: Color.fromRGBO(0, 0, 0, 0.7),
|
|
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(4.0))
|
|
|
|
|
+ ),
|
|
|
|
|
+ child: ListView.builder(
|
|
|
|
|
+ itemCount: lineList.length,
|
|
|
|
|
+ itemBuilder: (BuildContext context, int index) { //itemBuilder实际上就是一个map的循环
|
|
|
|
|
+ if (index < lineList.length) {
|
|
|
|
|
+ return _lineWidget(lineList[index],index,checkStatusList[index]);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ )
|
|
|
)
|
|
)
|
|
|
- ),
|
|
|
|
|
|
|
+ ],
|
|
|
)
|
|
)
|
|
|
),
|
|
),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ Widget _lineWidget(LineObj lineObj,int index,bool checked) {
|
|
|
|
|
+ return InkWell(
|
|
|
|
|
+ child: Container(
|
|
|
|
|
+ height: ScreenUtil.getInstance().setHeight(80),
|
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
|
+ border: BorderDirectional(bottom: BorderSide(color: Colors.white))
|
|
|
|
|
+ ),
|
|
|
|
|
+ child: Row(
|
|
|
|
|
+ children: < Widget > [
|
|
|
|
|
+ Padding(
|
|
|
|
|
+ padding: EdgeInsets.only(right: 10),
|
|
|
|
|
+ child:checked?Icon(Icons.check, color: Colors.white, ):Icon(Icons.check, color: Color.fromRGBO(0, 0, 0, 0.0) ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ Expanded(
|
|
|
|
|
+ flex: 1,
|
|
|
|
|
+ child: Center(
|
|
|
|
|
+ child: Text(lineObj.name, style: TextStyle(color: Colors.white))
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ ],
|
|
|
|
|
+ ),
|
|
|
|
|
+ ),
|
|
|
|
|
+ onTap: (){
|
|
|
|
|
+ setState(() {
|
|
|
|
|
+ checkStatusList[index] = !checked;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Widget _getMoreWidget() {
|
|
Widget _getMoreWidget() {
|
|
|
return Center(
|
|
return Center(
|
|
|
child: Padding(
|
|
child: Padding(
|
|
@@ -283,7 +350,7 @@ class _OrderCardContainerState extends State < OrderCardContainer > with SingleT
|
|
|
),
|
|
),
|
|
|
),
|
|
),
|
|
|
onTap: () {
|
|
onTap: () {
|
|
|
- getKey('stationId').then((value){
|
|
|
|
|
|
|
+ getKey('stationId').then((value) {
|
|
|
print(value);
|
|
print(value);
|
|
|
});
|
|
});
|
|
|
showDialog < Null > (
|
|
showDialog < Null > (
|
|
@@ -391,14 +458,13 @@ Widget orderPhone(String key, String value, int marginBottom) {
|
|
|
], )
|
|
], )
|
|
|
),
|
|
),
|
|
|
onLongPress: () async {
|
|
onLongPress: () async {
|
|
|
- String phone = 'tel:${value}';
|
|
|
|
|
|
|
+ String phone = 'tel:${value}';
|
|
|
print(phone);
|
|
print(phone);
|
|
|
- if(await canLaunch(phone)){
|
|
|
|
|
|
|
+ if (await canLaunch(phone)) {
|
|
|
await (launch(phone));
|
|
await (launch(phone));
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
throw 'Could not launch $value';
|
|
throw 'Could not launch $value';
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
|
|
+}
|