import 'package:farmer_client/widgets/DefaultButton.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';

import '../../widgets/OrderInfoCard.dart';

class OrderPageInfo extends StatefulWidget {
  const OrderPageInfo({Key? key}) : super(key: key);

  @override
  State<OrderPageInfo> createState() => _OrderPageInfoState();
}

class _OrderPageInfoState extends State<OrderPageInfo> {
  void onCancel() {
    showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(content: Text("您确定要取消订单吗?"), actions: <Widget>[
            TextButton(
              child: Text("取消"),
              onPressed: () {
                print("取消");
                Navigator.pop(context, 'Cancle');
              },
            ),
            TextButton(
                child: Text("确定"),
                onPressed: () {
                  // setState(() {
                  //   addressList.remove(addressList[e]);
                  // });
                  Navigator.pop(context, "Ok");
                  Fluttertoast.showToast(msg: '取消成功!');
                  Get.offAllNamed('/');
                })
          ]);
        });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: AppBar(
        elevation: 0,
        centerTitle: true,
        backgroundColor: Colors.white,
        title: Text(
          '订单详情',
          style: TextStyle(
              color: Colors.black,
              fontSize: 17.sp,
              letterSpacing: 2,
              fontWeight: FontWeight.bold),
        ),
      ),
      body: Column(
        children: [
          OrderInfoCard(),
          Spacer(),
          Container(
            margin: EdgeInsets.fromLTRB(15.w, 0, 15.w, 50.h),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                GestureDetector(
                  onTap: () {
                    onCancel();
                  },
                  child: Container(
                    width: 150.w,
                    height: 49.h,
                    decoration: BoxDecoration(
                        color: const Color(0xffffffff),
                        border: Border.all(
                            color: const Color(0xFFFF703B),
                            width: 1.w,
                            style: BorderStyle.solid),
                        borderRadius:
                            BorderRadius.all(Radius.circular(24.5.w))),
                    child: Center(
                      child: Text(
                        '取消',
                        style: TextStyle(
                            fontSize: 20.sp,
                            color: const Color(0xFFFF703B),
                            fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),
                ),
                DefaultButton(
                  color: const Color(0xffffffff),
                  backColor: const Color(0xFFFF703B),
                  width: 150.w,
                  height: 49.h,
                  text: '支付',
                  onPressed: () {
                    Fluttertoast.showToast(msg: '支付成功!');
                    Get.offAllNamed('/');
                  },
                  margin: const EdgeInsets.all(0),
                  fontSize: 20.sp,
                  radius: 24.5.w,
                ),
              ],
            ),
          ),
          // Container(
          //   height: 130.h,
          //   margin: EdgeInsets.only(top: 20.0, bottom: 0.0),
          //   alignment: Alignment.bottomCenter,
          //   child: SizedBox(
          //     width: 315.w,
          //     height: 49.h,
          //     child: ElevatedButton(
          //       onPressed: () {
          //         // _handelSubmit();
          //         print('用户点击了支付啊阿松大撒地方');
          //       },
          //       child: const Text(
          //         "支付",
          //         style: TextStyle(
          //             fontSize: 18,
          //             color: Colors.white,
          //             fontWeight: FontWeight.bold),
          //       ),
          //       style: ButtonStyle(
          //         elevation: MaterialStateProperty.all(0),
          //         backgroundColor:
          //             MaterialStateProperty.all(const Color(0xFFFF703B)),
          //         shape: MaterialStateProperty.all(const RoundedRectangleBorder(
          //             borderRadius: BorderRadius.all(Radius.circular(24.4)))),
          //       ),
          //     ),
          //   ),
          // ),
        ],
      ),
    );
  }
}