import 'package:farmer_client/models/entities/OrderInfoModel.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';

import 'LinearGradientText.dart';

class OrderInfoCard extends StatelessWidget {
  final OrderInfoModel item;
  final String orderStateText;
  final Color orderStateColor;

 // final  DateTime timeNew=item.appointmentDate;

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



  @override
  Widget build(BuildContext context) {
    return Container(
        width: 345.w,
        height: 484.5.h,
        margin: EdgeInsets.fromLTRB(15.w, 17.w, 15.w, 0),
        decoration: BoxDecoration(
          color: Colors.white,
          //设置四周圆角 角度
          borderRadius: BorderRadius.all(Radius.circular(2.0)),
          //设置四周边框
          boxShadow: [
            BoxShadow(
              blurRadius: 10, //阴影范围
              spreadRadius: 0.1, //阴影浓度
              color: Colors.grey.withOpacity(0.2), //阴影颜色
            ),
          ],
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
                margin: EdgeInsets.fromLTRB(15.w, 0, 0, 0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      padding: EdgeInsets.fromLTRB(0, 15, 0, 20),
                      width: 314.w,
                      decoration: const BoxDecoration(
                          border: Border(
                              bottom: BorderSide(
                                  width: 0.5, color: Color(0x20000000)
                                  // 0x17000000
                                  ))),
                      child: RichText(
                        text:  TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '订单编号:',
                              style: TextStyle(
                                  color: Color(0xff666666),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                          TextSpan(
                              text: item.orderNo.toString(),
                              style: TextStyle(
                                  color: Color(0xff222222),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                        ]),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.fromLTRB(0, 20, 0, 15),
                      child: RichText(
                        text:  TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '农机名称:',
                              style: TextStyle(
                                  color: Color(0xff666666),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                          TextSpan(
                              text: item.machineryName.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.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(
                          // '${DateFormat("yyyy-MM-dd").format(item.appointmentDate.toString())}'
                              text: DateFormat("yyyy-MM-dd").format(DateTime.parse(item.appointmentDate.toString())),
                              style: TextStyle(
                                  color: Color(0xff222222),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                        ]),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.fromLTRB(0, 0, 0, 20),
                      child: RichText(
                        text:  TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '下单时间:',
                              style: TextStyle(
                                  color: Color(0xff666666),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                          TextSpan(
                              text: DateFormat("yyyy-MM-dd").format(DateTime.parse(item.createDate.toString())),

                              style: TextStyle(
                                  color: Color(0xff222222),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                        ]),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.fromLTRB(0, 0, 0, 20),
                      child: RichText(
                        text:  TextSpan(children: <InlineSpan>[
                          TextSpan(
                              text: '订单状态:',
                              style: TextStyle(
                                  color: Color(0xff666666),
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                          TextSpan(
                              text: orderStateText,
                              style: TextStyle(
                                  color:orderStateColor,
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold)),
                        ]),
                      ),
                    ),
                    Container(
                        padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
                        width: 314.w,
                        decoration: const BoxDecoration(
                            border: Border(
                                top: BorderSide(
                                    width: 0.8, color: Color(0x20000000)
                                    // 0x17000000
                                    ))),
                        child: Column(
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children:  [
                                const Text('费用:',
                                    style: TextStyle(
                                        color: Color(0xff666666),
                                        fontSize: 16,
                                        fontWeight: FontWeight.bold)),
                                LinearGradientText(
                                  colors: const <Color>[
                                    Color(0xFFFA7878),
                                    Color(0xFFB61515),
                                  ],
                                  child: const Text('8880',
                                      style: TextStyle(
                                          color: Color(0xffB61515),
                                          fontSize: 16,
                                          fontWeight: FontWeight.bold)),
                                ),

                              ],
                            ),
                            Padding(
                              padding: EdgeInsets.fromLTRB(0, 30, 0, 0),
                              child: Row(
                                mainAxisAlignment:
                                MainAxisAlignment.spaceBetween,
                                children:  [
                                  Text('状态:',
                                      style: TextStyle(
                                          color: Color(0xff666666),
                                          fontSize: 16,
                                          fontWeight: FontWeight.bold)),
                                  Text(orderStateText,
                                      style: TextStyle(
                                          color: orderStateColor,
                                          fontSize: 16,
                                          fontWeight: FontWeight.bold)),
                                ],
                              ),
                            ),
                          ],
                        )),
                  ],
                )),
          ],
        ),

    );
  }
}