| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import '../util/api.dart';
- import '../util/models.dart';
- class OrderTakingPage extends StatefulWidget {
- OrderTakingPage({
- Key key
- }): super(key: key);
- _OrderTakingPageState createState() => _OrderTakingPageState();
- }
- class _OrderTakingPageState extends State < OrderTakingPage > with AutomaticKeepAliveClientMixin {
-
- List listObj=[];
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- getOrderList().then((resp){
- setState(() {
- listObj = resp.orderList;
- });
- //print(listObj[0].id);
- });
- }
- @override
- Widget build(BuildContext context) {
- super.build(context);
- return Container(
- child: Scaffold(
- appBar: AppBar(
- title: Text('接单', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
- centerTitle: true,
- backgroundColor: Color.fromRGBO(64, 98, 254, 1),
- actions: < Widget > [
- 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),
- ]
- )
- ),
- ],
- ),
- 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: ListView.builder(
- itemCount: listObj.length,
- itemBuilder: (BuildContext context,int index){
- return OrderCard(order:listObj[index]);
- },
- ),
- )
- ),
- );
- }
- @override
- bool get wantKeepAlive => true;
- }
- 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;
- OrderCardContainer({Key key, @required this.order}): super(key: key);
- _OrderCardContainerState createState() => _OrderCardContainerState();
- }
- class _OrderCardContainerState extends State < OrderCardContainer > with SingleTickerProviderStateMixin {
- Animation < double > animation;
- AnimationController controller;
- String str="联系方式";
- bool animationStatus =true;
- @override
- initState() {
- super.initState();
- controller = new AnimationController(
- duration: const Duration(milliseconds: 200), vsync: this);
- animation = new Tween(begin: 0.0, end: 230.0).animate(controller);
- animation.addStatusListener((status){
- if (status == AnimationStatus.completed) {
- //动画执行结束时反向执行动画
- setState(() {
- animationStatus = false;
- str="收起";
- });
- } else if (status == AnimationStatus.dismissed) {
- //动画恢复到初始状态时执行动画(正向)
- setState(() {
- animationStatus=true;
- str="联系方式";
- });
- }
- });
- }
-
- @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,)
- ],
- ),
- );
- }
- dispose() {
- //路由销毁时需要释放动画资源
- 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), ),
- ),
- ),
- onTap: () {
- print("22222");
- },
- )
- ],
- )
- );
- }
- class AnimatedOpen extends AnimatedWidget {
- final OrderList openInfo;
- AnimatedOpen({
- Key key,
- Animation < double > animation,
- @required this.openInfo
- }): super(key: key, listenable: animation);
- Widget build(BuildContext context) {
- final Animation < double > animation = listenable;
- return Container(
- height: ScreenUtil.getInstance().setHeight(animation.value),
- child: orderDetailInfo(openInfo),
- );
- }
- }
- Widget orderNoRow(int orderNo,String createTime) { //订单号及时间
- return Container(
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Text("订单号:${orderNo}", style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
- Text(createTime, style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
- ],
- ),
- );
- }
- Widget orderAddress(String startAddress,String endAddress) { //运送路线
- return Container(
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Row(children: < Widget > [
- Text('${startAddress} ---> ${endAddress}', style: TextStyle(color: Colors.black, fontSize: ScreenUtil.getInstance().setSp(30)), ),
- ], )
- );
- }
- Widget orderCutLine() { //分割线
- return Container(
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- height: ScreenUtil.getInstance().setHeight(1),
- color: Color.fromRGBO(223, 223, 223, 1),
- );
- }
- Widget orderDetailInfo(OrderList obj) {//卡片展开信息
- return Container(
- child: Wrap(
- children: < Widget > [
- orderCutLine(),
- orderPhone('发件电话', obj.sendPhone, 15),
- orderItem('发件地址', obj.sendAddress, 30),
- orderPhone('收件电话', obj.getPhone, 15),
- orderItem('收件地址', obj.getAddress, 30),
- ],
- )
- );
- }
- Widget orderItem(String key, String value, int marginBottom) {//货物名称,件数
- return Container(
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(marginBottom)),
- child: Row(children: < Widget > [
- Text('${key}:${value}', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
- ], )
- );
- }
- Widget orderPhone(String key, String value, int marginBottom) {
- return Container(
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(marginBottom)),
- child: Row(children: < Widget > [
- Text('${key}:', style: TextStyle(color: Color.fromRGBO(153, 153, 153, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
- Text('${value}', style: TextStyle(color: Color.fromRGBO(64, 98, 254, 1), fontSize: ScreenUtil.getInstance().setSp(24)), ),
- ], )
- );
- }
|