import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../models/entities/OrderListAll.dart';
import '../pages/OrderConfirmation/index.dart';
import '../pages/orderInfo/index.dart';
import 'LinearGradientText.dart';


class OrderListCard extends StatefulWidget {

  final OrderListAll item;

  const OrderListCard({Key? key, required this.item}) : super(key: key);

  @override
  _OrderListCardPages createState() => _OrderListCardPages(item);
}




class _OrderListCardPages extends State<OrderListCard> {

  final OrderListAll item;

  _OrderListCardPages(this.item);


  void orderStates(item){
    // if (item.payStatus == 0) {
    //   return {
    //     title: '待付款',
    //     styleColor: '#51D4FF'
    //   };
    // } else if (item.payStatus == 1 && item.workStatus == 0 && item.dispatchStatus == 0) {
    //   return {
    //     title: '已付款',
    //     styleColor: '#FF703B'
    //   };
    // } else if (item.payStatus == 1 && item.dispatchStatus == 1 && item.workStatus == 0) {
    //   return {
    //     title: '待作业',
    //     styleColor: '#FF703B'
    //   };
    //
    // } else if (item.payStatus == 1 && (item.workStatus == 1 || item.workStatus == 2)) {
    //   return {
    //     title: '进行中',
    //     styleColor: '#44F68B'
    //   };
    // } else if (item.workStatus == 3 && item.isEvaluated == 0) {
    //   return {
    //     title: '待评价',
    //     styleColor: '#51D4FF'
    //   };
    // } if (item.workStatus == 3 && item.isEvaluated == 1 && item.dispatchStatus == 1) {
    //   return {
    //     title: '已完成',
    //     styleColor: '#FF703B'
    //   };
    // } else if (item.payStatus == -1 && item.workStatus == 0 && item.isRefund == 1) {
    //   return {
    //     title: '已退单',
    //     styleColor: '#FF703B'
    //   };
    // } else if (item.payStatus == 3 && (item.dispatchStatus == 1 || item.dispatchStatus == 0)) {
    //   return {
    //     title: '退单申请中',
    //     styleColor: '#FF703B'
    //   };
    // } else {
    //   return {
    //     title: '异常',
    //     styleColor: '#FF0000'
    //   };
    // }



  }


  @override
  Widget build(BuildContext context) {
    return Container(
      width: 375.w,
      height: 345.h,
      margin: EdgeInsets.fromLTRB(0, 0, 0, 20),
      decoration: const BoxDecoration(color: Colors.white, boxShadow: [
        BoxShadow(
            color: Colors.black12,
            offset: Offset(0.0, 15.0), //阴影xy轴偏移量
            blurRadius: 15.0, //阴影模糊程度
            spreadRadius: 1.0 //阴影扩散程度
            )
      ]),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Container(
            margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
            width: 18.0,
            height: 275.h,
            child: Image(
              image: AssetImage('images/ordersLeft.png'),
            ),
          ),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Container(
                  width: 320.w,
                  margin: EdgeInsets.fromLTRB(0, 10, 0, 15),
                  padding: EdgeInsets.fromLTRB(0, 0, 0, 20),
                  decoration: const BoxDecoration(
                      border: Border(
                          bottom:
                              BorderSide(width: 0.5, color: Color(0x20000000)
                                  // 0x17000000
                                  ))),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Container(
                        child: RichText(
                          text:  TextSpan(children: <InlineSpan>[
                            TextSpan(
                                text: '订单编号:',
                                style: TextStyle(
                                    color: Color(0xff666666),
                                    fontSize: 16,
                                    fontWeight: FontWeight.bold)),
                            TextSpan(
                                text: item.orderNo,
                                style: TextStyle(
                                    color: Color(0xff222222),
                                    fontSize: 16,
                                    fontWeight: FontWeight.bold)),
                          ]),
                        ),
                      ),
                      GestureDetector(
                        child: const Text('详情 >>',
                            style: TextStyle(
                              color: Color(0xff222222),
                              fontSize: 16,
                              fontWeight: FontWeight.bold,
                            )),
                        onTap: () {
                          print('进入详情');
                          Get.toNamed('/orderPageInfo');
                        },
                      )
                    ],
                  ),
                ),
                Expanded(
                    child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Padding(
                      padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
                      child: RichText(
                        text:  TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '农机名称:',
                              style: TextStyle(
                                  color: Color(0xff666666),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                          TextSpan(
                              text: item.machineryName,
                              style: TextStyle(
                                  color: Color(0xff222222),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                        ]),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
                      child: RichText(
                        text:  TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '作业面积:',
                              style: TextStyle(
                                  color: Color(0xff666666),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                          TextSpan(
                              text: item.amount.toString(),
                              style: TextStyle(
                                  color: Color(0xff222222),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                        ]),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
                      child: RichText(
                        text:  TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '需求时间:',
                              style: TextStyle(
                                  color: Color(0xff666666),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                          TextSpan(
                              text: item.appointmentDate.toString(),
                              style: TextStyle(
                                  color: Color(0xff222222),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                        ]),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.fromLTRB(0, 0, 0, 4),
                      child: RichText(
                        text:  TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '下单时间:',
                              style: TextStyle(
                                  color: Color(0xff666666),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                          TextSpan(
                              text: item.createDate.toString(),
                              style: TextStyle(
                                  color: Color(0xff222222),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                        ]),
                      ),
                    ),
                  ],
                )),
                Container(
                  margin: EdgeInsets.fromLTRB(0, 0, 0, 30),
                  padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
                  decoration: const BoxDecoration(
                      border: Border(
                          top: BorderSide(
                              width: 0.5, color: Color(0x20000000)))),
                  width: 320.w,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      RichText(
                        text: const TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '订单状态:',
                              style: TextStyle(
                                  color: Color(0xff666666),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                          TextSpan(
                              text: '待付款',
                              style: TextStyle(
                                  color: Color(0xff51D4FF),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                        ]),
                      ),
                      Container(
                        child: Row(
                          children: [
                            const Text('费用:',style: TextStyle(
                                color: Color(0xff666666),
                                fontSize: 16,
                                fontWeight: FontWeight.bold)),
                            LinearGradientText(
                              colors: const <Color>[
                                Color(0xFFFA7878),
                                Color(0xFFB61515),
                              ],
                              child: RichText(
                                text:  TextSpan(
                                    children: <InlineSpan>[
                                      TextSpan(
                                          text:( item.charges!/100).toString(),
                                          style: TextStyle(
                                            fontSize: 16,
                                            fontWeight: FontWeight.bold,
                                          )),
                                      TextSpan(
                                          text: "元",
                                          style: TextStyle(
                                            fontSize: 16,
                                            fontWeight: FontWeight.bold,
                                          )),

                                    ]
                                ),
                              ),
                            ),

                          ],
                        ),
                      ),

                    ],
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}