import 'dart:math';

import 'package:confetti/confetti.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:intl/intl.dart';

import '../../../Controller/Createorder/Createordercontroller.dart';
import '../../../Controller/Directionmap/Directionmapcontroller.dart';
import '../../../Controller/Sucessreview/Sucessscreencontroller.dart';
import '../../../Helper/Constants/Assetconstants.dart';
import '../../../Helper/Constants/Colorconstants.dart';
import '../../../Helper/custombutton.dart';
import '../../../Model/Response/Createorder/CreateOrderResponsemodel.dart';
import '../../Home/Homeview.dart';

class OrderSuccessView extends StatelessWidget {
  final OrderResponseDetails orderResponseDetails;
   OrderSuccessView({super.key, required this.orderResponseDetails});

  SuccessScreenController successScreenController = Get.put(SuccessScreenController());
   DirectionMapController directionMapController = Get.put(DirectionMapController());
   CreateOrderController createOrderController = Get.put(CreateOrderController());

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async {
        Get.back();
        return false;
      },
      child: Scaffold(
        backgroundColor: ColorConstants.secondaryColor,
        appBar: AppBar(
          elevation: 0,
          automaticallyImplyLeading: false,
          backgroundColor: ColorConstants.primaryColor,
          title:  Row(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              InkWell(
                onTap: () {
                  Get.back();
                },
                child: Icon(
                  Icons.arrow_back,
                  color: ColorConstants.secondaryColor,
                  size: 25,
                ),
              ),
              const SizedBox(
                width: 10,
              ),
              Text('Order details',
                  style: TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 16,
                    color: ColorConstants.secondaryColor,
                    fontFamily: "Inter",
                  )),
              Spacer(),
              // Row(
              //   children: [
              //     Text(
              //       DateFormat("dd-MMM-yyyy").format(DateFormat("yyyy-MM-dd HH:mm:ss", "en_US").parse(orderResponseDetails.orderdate??'')),
              //       style: const TextStyle(
              //           fontSize: 14,
              //           fontWeight:
              //           FontWeight
              //               .w700),
              //     ),
              //   ],
              // ),
              Row(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Text('SMS delivery',style: TextStyle(color: ColorConstants.secondaryColor,fontWeight: FontWeight.bold,fontSize: 14),),
                  const SizedBox(width: 5,),
                  GetBuilder<CreateOrderController>(
                      builder: (controller) {
                        return Switch(value: controller.smsSelected ,
                          onChanged: (val){
                            controller.smsSelected = val;
                            print('SwitchsmsSelected ${controller.smsSelected}');
                            controller.update();
                          },
                          activeColor: ColorConstants.secondaryColor,
                          activeTrackColor: ColorConstants.primaryColor1,
                          inactiveTrackColor: ColorConstants.primaryColor1,
                        );
                      }
                  )
                ],
              ),
            ],
          ),
        ),
        body: ListView(
          children: [
            GetBuilder<CreateOrderController>(
              initState: (_){
                createOrderController.distanceCalculation();
                createOrderController.calculateCharges();
              },
              builder: (controller) {
                return Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [

                    // Column(
                    //   mainAxisAlignment: MainAxisAlignment.start,
                    //   crossAxisAlignment: CrossAxisAlignment.center,
                    //   children: [
                    //     GetBuilder<SuccessScreenController>(
                    //         initState: (_){
                    //           successScreenController.confettiController.play();
                    //         },
                    //         builder: (controller) {
                    //           return Center(
                    //             child: ConfettiWidget(
                    //               confettiController: controller.confettiController,
                    //               blastDirectionality: BlastDirectionality.explosive,
                    //               shouldLoop: true,
                    //               colors: const [
                    //                 Colors.green,
                    //                 Colors.blue,
                    //                 Colors.pink,
                    //                 Colors.orange,
                    //                 ColorConstants.primaryColor,
                    //               ],
                    //               createParticlePath: drawStar,
                    //             ),
                    //           );
                    //         }
                    //     ),
                    //     // CircleAvatar(
                    //     //   radius: 80,
                    //     //   backgroundColor: Colors.white,
                    //     //   child: Image.asset(AssetConstants.nearleAppbarDarkLogo,height: Get.height*0.25,),
                    //     // ),
                    //     // Lottie.asset('assets/successfull_anim.json',
                    //     //   repeat: true,
                    //     //   reverse: true,
                    //     //   animate: true,
                    //     //   width: 200,
                    //     //   height: 200,
                    //     //   fit: BoxFit.fill,
                    //     // ),
                    //   ],
                    // ),
                    const SizedBox(
                      height: 0,
                    ),
                    Container(
                      height: Get.height*0.42,
                      // width: Get.width*0.99,
                      // decoration: BoxDecoration(color: ColorConstants.secondaryColor,border: Border.all(color: ColorConstants.darkGreyColor!)),
                      child:  GetBuilder<DirectionMapController>(
                          initState: (_){
                            print('pickupLatinitstatesuccess ${orderResponseDetails.pickuplat}');
                            print('pickupLonginitstatesuccess ${orderResponseDetails.pickuplong}');
                            print('dropLatinitstatesuccess ${orderResponseDetails.deliverylat}');
                            print('dropLonginitstatesuccess ${orderResponseDetails.deliverylong}');

                            directionMapController.originLatitude = double.parse(orderResponseDetails.pickuplat.toString());
                            directionMapController.originLongitude = double.parse(orderResponseDetails.pickuplong.toString());
                            directionMapController.destLatitude = double.parse(orderResponseDetails.deliverylat.toString());
                            directionMapController.destLongitude = double.parse(orderResponseDetails.deliverylong.toString());
                            DirectionMapController.center = LatLng(double.parse(orderResponseDetails.pickuplat!), double.parse(orderResponseDetails.pickuplong!));

                            directionMapController.addMarker(LatLng(directionMapController.originLatitude??0.0, directionMapController.originLongitude??0.0), "origin",
                                BitmapDescriptor.defaultMarker);
                            directionMapController.addMarker(LatLng(directionMapController.destLatitude??0.0, directionMapController.destLongitude??0.0), "destination",
                                BitmapDescriptor.defaultMarkerWithHue(90));
                            directionMapController.getPolyline();
                          },
                          builder: (controller) {
                            return GoogleMap(
                              initialCameraPosition: CameraPosition(

                                  target: LatLng(controller.originLatitude??0.0, controller.originLongitude??0.0), zoom: 12),
                              tiltGesturesEnabled: true,
                              compassEnabled: true,
                              scrollGesturesEnabled: true,
                              zoomGesturesEnabled: true,
                              onMapCreated: controller.onMapCreated,
                              trafficEnabled: true,
                              cameraTargetBounds: CameraTargetBounds.unbounded,
                              zoomControlsEnabled: true,
                              buildingsEnabled: true,
                              indoorViewEnabled: true,
                              mapToolbarEnabled: true,
                              minMaxZoomPreference: MinMaxZoomPreference.unbounded,

                              onCameraMove: (position) {
                                DirectionMapController.center = position.target;
                                controller.update();

                              },
                              onCameraIdle: () async {

                              },
                              markers: Set<Marker>.of(controller.markers.values),
                              polylines: Set<Polyline>.of(controller.polylines.values),
                            );
                          }
                      ),
                    ),
                    // Column(
                    //   mainAxisAlignment: MainAxisAlignment
                    //       .start,
                    //   crossAxisAlignment: CrossAxisAlignment
                    //       .start,
                    //   children: [
                    //     Row(
                    //       children: [
                    //         Padding(
                    //           padding: const EdgeInsets
                    //               .only(
                    //               top: 15, left: 15),
                    //           child: Text(
                    //             'Approximate Charges : ',
                    //             style: TextStyle(
                    //                 color: ColorConstants
                    //                     .primaryColor,
                    //                 fontSize: 14,
                    //                 fontWeight: FontWeight
                    //                     .bold),),
                    //         ),
                    //
                    //       ],
                    //     ),
                    //     Row(
                    //       children: [
                    //         Padding(
                    //           padding: const EdgeInsets
                    //               .only(left: 25),
                    //           child: Card(
                    //             elevation: 0,
                    //             child: Container(
                    //               height: Get.height *
                    //                   0.14,
                    //               width: Get.width *
                    //                   0.2,
                    //               decoration: BoxDecoration(
                    //                   color: ColorConstants
                    //                       .secondaryColor,
                    //                   borderRadius: BorderRadius
                    //                       .circular(
                    //                       10)),
                    //               child: Column(
                    //                 children: [
                    //                   const SizedBox(
                    //                     height: 10,),
                    //                   CircleAvatar(
                    //                     radius: 25,
                    //                     backgroundColor: ColorConstants
                    //                         .primaryColor,
                    //                     child: CircleAvatar(
                    //                       radius: 20,
                    //                       backgroundColor: ColorConstants
                    //                           .secondaryColor,
                    //                       child: CircleAvatar(
                    //                         radius: 15,
                    //                         backgroundColor: ColorConstants
                    //                             .primaryColor,
                    //                         child: Icon(
                    //                           Icons
                    //                               .location_on,
                    //                           size: 20,
                    //                           color: ColorConstants
                    //                               .secondaryColor,),
                    //
                    //                       ),
                    //                     ),
                    //                   ),
                    //                   const SizedBox(
                    //                     height: 5,),
                    //                   Text(
                    //                     '${createOrderController
                    //                         .distanceKm} km',
                    //                     style: TextStyle(
                    //                         color: ColorConstants
                    //                             .darkGreyColor,
                    //                         fontSize: 16,
                    //                         fontWeight: FontWeight
                    //                             .bold),
                    //                     maxLines: 1,
                    //                     overflow: TextOverflow
                    //                         .ellipsis,),
                    //
                    //                 ],
                    //               ),
                    //             ),
                    //           ),
                    //         ),
                    //         Padding(
                    //           padding: const EdgeInsets
                    //               .only(left: 10),
                    //           child: Card(
                    //             elevation: 0,
                    //             child: Container(
                    //               height: Get.height *
                    //                   0.14,
                    //               width: Get.width *
                    //                   0.2,
                    //               decoration: BoxDecoration(
                    //                   color: ColorConstants
                    //                       .secondaryColor,
                    //                   borderRadius: BorderRadius
                    //                       .circular(
                    //                       10)),
                    //               child: Column(
                    //                 children: [
                    //                   const SizedBox(
                    //                     height: 10,),
                    //                   CircleAvatar(
                    //                     radius: 25,
                    //                     backgroundColor: ColorConstants
                    //                         .primaryColor,
                    //                     child: CircleAvatar(
                    //                       radius: 20,
                    //                       backgroundColor: ColorConstants
                    //                           .secondaryColor,
                    //                       child: CircleAvatar(
                    //                         radius: 15,
                    //                         backgroundColor: ColorConstants
                    //                             .primaryColor,
                    //                         child: Icon(
                    //                           Icons
                    //                               .currency_rupee,
                    //                           size: 20,
                    //                           color: ColorConstants
                    //                               .secondaryColor,),
                    //
                    //                       ),
                    //                     ),
                    //                   ),
                    //                   const SizedBox(
                    //                     height: 5,),
                    //                   Text(
                    //                     '₹ ${createOrderController.totalDeliveryAmount }',
                    //                     style: TextStyle(
                    //                         color: ColorConstants
                    //                             .darkGreyColor,
                    //                         fontSize: 16,
                    //                         fontWeight: FontWeight
                    //                             .bold),
                    //                     maxLines: 1,
                    //                     overflow: TextOverflow
                    //                         .ellipsis,),
                    //                 ],
                    //               ),
                    //             ),
                    //           ),
                    //         ),
                    //       ],
                    //     ),
                    //
                    //     Padding(
                    //       padding: const EdgeInsets
                    //           .only(top: 0,
                    //           left: 15,
                    //           right: 10),
                    //       child: Text(
                    //         '* Actual delivery charges will be calculated at the time of delivery.',
                    //         style: TextStyle(
                    //             color: ColorConstants
                    //                 .darkGreyColor,
                    //             fontSize: 13,
                    //             fontWeight: FontWeight
                    //                 .bold),),
                    //     ),
                    //     const Divider(color: Colors.grey,thickness: 2),
                    //     Padding(
                    //       padding: const EdgeInsets
                    //           .only(
                    //           top: 0, left: 15),
                    //       child: Text(
                    //         'Select Payment method : ',
                    //         style: TextStyle(
                    //             color: ColorConstants
                    //                 .primaryColor,
                    //             fontSize: 14,
                    //             fontWeight: FontWeight
                    //                 .bold),),
                    //     ),
                    //     const SizedBox(height: 15,),
                    //     Container(
                    //       height: Get.height*0.12,
                    //       width: Get.width*0.80,
                    //       child: GetBuilder<CreateOrderController>(
                    //           builder: (controller) {
                    //             return ListView.builder(
                    //                 scrollDirection: Axis
                    //                     .horizontal,
                    //                 itemCount: controller
                    //                     .paymentMethod
                    //                     .length,
                    //                 itemBuilder: (
                    //                     BuildContext context,
                    //                     int index) {
                    //                   return InkWell(
                    //                     onTap: () {
                    //                       controller.paymentSelectedIndex = index;
                    //                       controller.payment = controller.paymentMethod[index]['Paymentmethod'];
                    //                       print('paymentRange${controller.payment}');
                    //                       controller.update();
                    //                       // Get.back();
                    //                     },
                    //                     child: Padding(
                    //                       padding: const EdgeInsets
                    //                           .only(
                    //                           left: 25),
                    //                       child: Column(
                    //                         children: [
                    //                           CircleAvatar(
                    //                             radius: 30,
                    //                             backgroundColor: controller
                    //                                 .paymentSelectedIndex ==
                    //                                 index
                    //                                 ? Colors
                    //                                 .green
                    //                                 : Colors
                    //                                 .grey[400],
                    //                             child: CircleAvatar(
                    //                               radius: 25,
                    //                               backgroundColor: ColorConstants
                    //                                   .secondaryColor,
                    //                               child: CircleAvatar(
                    //                                 radius: 20,
                    //                                 backgroundColor: controller
                    //                                     .paymentSelectedIndex ==
                    //                                     index
                    //                                     ? Colors
                    //                                     .green
                    //                                     : Colors
                    //                                     .grey[400],
                    //                                 child: controller
                    //                                     .paymentMethod[index]['icon'],
                    //                               ),
                    //                             ),
                    //                           ),
                    //                           const SizedBox(
                    //                             height: 10,),
                    //                           Text(
                    //                             '${controller
                    //                                 .paymentMethod[index]['Paymentmethod']}',
                    //                             style: TextStyle(
                    //                                 color: ColorConstants
                    //                                     .primaryColor,
                    //                                 fontSize: 16,
                    //                                 fontWeight: FontWeight
                    //                                     .bold),
                    //                             maxLines: 1,
                    //                             overflow: TextOverflow
                    //                                 .ellipsis,),
                    //
                    //                         ],
                    //                       ),
                    //                     ),
                    //                   );
                    //                 });
                    //           }
                    //       ),
                    //     ),
                    //     const Divider(color: Colors.grey,thickness: 2),
                    //     Padding(
                    //       padding: const EdgeInsets.only(left: 15,top: 0),
                    //       child: Column(
                    //         mainAxisAlignment: MainAxisAlignment.start,
                    //         crossAxisAlignment: CrossAxisAlignment.start,
                    //         children: [
                    //           Text('Fulfilment:',style: TextStyle(color: ColorConstants.primaryColor,fontSize: 20,fontWeight: FontWeight.bold)),
                    //           // const SizedBox(height: 5,),
                    //           Row(
                    //             mainAxisAlignment: MainAxisAlignment.start,
                    //             crossAxisAlignment: CrossAxisAlignment.center,
                    //             children: [
                    //               Text('SMS required to complete this delivery',style: TextStyle(color: ColorConstants.darkGreyColor,fontWeight: FontWeight.bold,fontSize: 16),),
                    //               const SizedBox(width: 5,),
                    //               GetBuilder<CreateOrderController>(
                    //                   builder: (controller) {
                    //                     return Switch(value: controller.smsSelected ,
                    //                       onChanged: (val){
                    //                         controller.smsSelected = val;
                    //                         print('SwitchsmsSelected ${controller.smsSelected}');
                    //                         controller.update();
                    //                       },
                    //                       activeColor: ColorConstants.primaryColor,);
                    //                   }
                    //               )
                    //             ],
                    //           ),
                    //         ],
                    //       ),
                    //     ),
                    //
                    //   ],
                    // ),

                    Padding(
                      padding: const EdgeInsets.only(left: 0),
                      child:  Card(
                        color: ColorConstants.primaryColor1,
                        // Utility.getLightColors(controller.getOrderAllList[index].tenantname![0]).withAlpha(100),
                        elevation: 0,
                        // shape: RoundedRectangleBorder(
                        //   borderRadius: BorderRadius.circular(10),
                        // ),
                        child: SizedBox(
                          height: Get.height*0.18,
                          width: MediaQuery.of(context).size.width,
                          child: Row(
                            children: [
                              Expanded(
                                flex: 2,
                                child: Column(
                                  // mainAxisSize: MainAxisSize.min,
                                  mainAxisAlignment:
                                  MainAxisAlignment
                                      .spaceBetween,
                                  children: [
                                    Container(
                                      width:45,
                                      margin: const EdgeInsets.only(left: 8,right: 0,top: 12,bottom: 0),
                                      padding: const EdgeInsets.only(left: 5,right: 5,top: 5,bottom: 5),
                                      decoration:  BoxDecoration(
                                        color: Colors.white70,
                                        borderRadius: BorderRadius.circular(5),
                                        // shape: BoxShape.circle
                                      ),
                                      child: Column(
                                        children: [
                                          Text(
                                            DateFormat("dd").format(DateFormat("yyyy-MM-dd HH:mm:ss", "en_US").parse(orderResponseDetails.orderdate??'')),

                                            style: const TextStyle(
                                                fontSize: 12,
                                                fontWeight:
                                                FontWeight
                                                    .w700),
                                          ),
                                          const SizedBox(
                                            height: 2,
                                          ),
                                          Text(
                                            DateFormat("MMM").format(DateFormat("yyyy-MM-dd HH:mm:ss", "en_US").parse(orderResponseDetails.orderdate??'')),

                                            style: const TextStyle(
                                                fontSize: 12,
                                                fontWeight:
                                                FontWeight
                                                    .w700),
                                          ),
                                        ],
                                      ),
                                    ),

                                    Column(
                                      children: [
                                        const SizedBox(
                                          width: 10,
                                        ),
                                        Container(
                                          width:45,
                                          margin: const EdgeInsets.only(left: 8,right: 0,top: 0,bottom: 5),
                                          padding: const EdgeInsets.only(left: 5,right: 5,top: 5,bottom: 5),
                                          decoration:  BoxDecoration(
                                            color: Colors.white70,
                                            borderRadius: BorderRadius.circular(5),
                                            // shape: BoxShape.circle
                                          ),
                                          // radius: 22,
                                          // backgroundColor: Colors.white70,
                                          child: Column(
                                            mainAxisAlignment: MainAxisAlignment.center,
                                            crossAxisAlignment: CrossAxisAlignment.center,
                                            children: [
                                              Text(
                                                  DateFormat("hh:mm").format(DateFormat("yyyy-mm-dd HH:mm:ss", "en_US").parse(orderResponseDetails.deliverydate??'')),
                                                  style: const TextStyle(fontSize: 11,color: Colors.black,fontWeight: FontWeight.bold)),
                                              const SizedBox(height: 2,),
                                              Text(
                                                  DateFormat("a").format(DateFormat("yyyy-mm-dd HH:mm:ss", "en_US").parse(orderResponseDetails.deliverydate??'')),
                                                  style: const TextStyle(fontSize: 11,color: Colors.black,fontWeight: FontWeight.bold)),
                                              const SizedBox(height: 2,),
                                            ],
                                          ),
                                        ),
                                        const SizedBox(height: 5,)
                                      ],
                                    ),
                                  ],
                                ),
                              ),
                              Expanded(
                                flex: 12,
                                child: Padding(
                                  padding: const EdgeInsets.all(5.0),
                                  child: Card(
                                    elevation: 0,
                                    shape: RoundedRectangleBorder(
                                      borderRadius: BorderRadius.circular(10),
                                    ),
                                    child: Row(
                                      children: [
                                        Expanded(
                                          flex: 7,
                                          child: Padding(
                                            padding: const EdgeInsets.only(left: 10),
                                            child: Column(
                                              children: [

                                                Expanded(
                                                  flex: 4,
                                                  child: Column(
                                                    crossAxisAlignment: CrossAxisAlignment.center,
                                                    mainAxisAlignment: MainAxisAlignment.center,
                                                    children: [
                                                      Row(
                                                        children: [
                                                          Icon(Icons.person,color: ColorConstants.primaryColor,size: 20),
                                                          const SizedBox(width: 5,),
                                                          Expanded(
                                                            child: Text(
                                                              '${orderResponseDetails.pickupcustomer??''}',
                                                              style: const TextStyle(
                                                                  color: Colors.black87, fontSize: 16),
                                                              maxLines: 1,
                                                              overflow: TextOverflow.ellipsis,
                                                            ),
                                                          ),
                                                          const SizedBox(width: 4,)
                                                        ],
                                                      ),
                                                      const SizedBox(
                                                        height:5,
                                                      ),
                                                      Row(
                                                        children: [
                                                          Icon(
                                                            Icons.location_on_rounded,
                                                            size: 20,
                                                            color: ColorConstants.primaryColor,
                                                          ),
                                                          const SizedBox(
                                                            width: 5,
                                                          ),
                                                          Expanded(
                                                            child: Padding(
                                                              padding: const EdgeInsets.only(top: 5),
                                                              child: Text(
                                                                "${orderResponseDetails.pickupsuburb??''}",
                                                                style: const TextStyle(
                                                                    color: Colors.black87,
                                                                    overflow: TextOverflow.visible,
                                                                    fontSize: 14),
                                                                maxLines: 1,
                                                                overflow: TextOverflow.ellipsis,
                                                              ),
                                                            ),
                                                          ),


                                                          const SizedBox(
                                                            width: 8,
                                                          ),
                                                        ],
                                                      ),
                                                      const SizedBox(
                                                        height:5,
                                                      ),
                                                      // Row(
                                                      //   children: [
                                                      //     Container(
                                                      //       padding: EdgeInsets.only(left: 5,right: 5,top: 5,bottom: 5),
                                                      //       decoration: BoxDecoration(color: ColorConstants.primaryColor,borderRadius: BorderRadius.circular(10)),
                                                      //       child: Row(
                                                      //         children: [
                                                      //           Text('${orderResponseDetails.orderid??''}',style: TextStyle(color: ColorConstants.secondaryColor,fontSize: 12),)
                                                      //         ],
                                                      //       ),
                                                      //     ),
                                                      //   ],
                                                      // ),
                                                      // const SizedBox(
                                                      //   height:5,
                                                      // ),
                                                      Row(
                                                        children: [
                                                          Icon(
                                                            Icons.person,
                                                            size: 20,
                                                            color: ColorConstants.primaryColor,
                                                          ),
                                                          const SizedBox(
                                                            width: 5,
                                                          ),
                                                          Padding(
                                                            padding: const EdgeInsets.only(top: 5),
                                                            child: Text(
                                                              "${orderResponseDetails.deliverycustomer??''}",
                                                              style: const TextStyle(
                                                                  color: Colors.black87,
                                                                  overflow: TextOverflow.visible,
                                                                  fontSize: 14),
                                                            ),
                                                          ),

                                                        ],
                                                      ),
                                                      const SizedBox(
                                                        height:5,
                                                      ),

                                                      Row(
                                                        children: [
                                                          Row(
                                                            children: [
                                                              Icon(
                                                                Icons.location_on_rounded,
                                                                size: 20,
                                                                color: ColorConstants.primaryColor,
                                                              ),
                                                              const SizedBox(
                                                                width: 5,
                                                              ),
                                                              Padding(
                                                                padding: const EdgeInsets.only(top: 5),
                                                                child: Text(
                                                                  "${orderResponseDetails.deliverysuburb??''}",
                                                                  style: const TextStyle(
                                                                      color: Colors.black87,
                                                                      overflow: TextOverflow.visible,
                                                                      fontSize: 14),
                                                                ),
                                                              ),

                                                            ],
                                                          ),

                                                          SizedBox(width: 10,)
                                                        ],
                                                      ),


                                                    ],
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ),

                    Column(
                      mainAxisAlignment: MainAxisAlignment
                          .start,
                      crossAxisAlignment: CrossAxisAlignment
                          .start,
                      children: [
                        Padding(
                          padding: const EdgeInsets
                              .only(
                              top: 2, left: 15),
                          child: Text(
                            'Approximate charges : ',
                            style: TextStyle(
                                color: ColorConstants
                                    .primaryColor,
                                fontSize: 16,
                                fontWeight: FontWeight
                                    .bold),),
                        ),
                        const SizedBox(height: 5,),
                        Padding(
                          padding: const EdgeInsets.only(left: 15),
                          child: Row(
                            children: [
                              Chip(
                                avatar:Icon(Icons.location_on,color: ColorConstants.primaryColor,size: 20,),
                                label: Text(
                                  '${controller
                                      .distanceKms} km',
                                  style: TextStyle(
                                      color: ColorConstants
                                          .darkGreyColor,
                                      fontSize: 14,
                                      fontWeight: FontWeight
                                          .bold),
                                  maxLines: 2,
                                  overflow: TextOverflow
                                      .ellipsis,),),
                              SizedBox(width: 10,),
                              Chip(
                                avatar:Icon(Icons.currency_rupee,color: ColorConstants.primaryColor,size: 20,),
                                label: Text(
                                  '₹ ${controller
                                      .totalDeliveryAmount }',
                                  style: TextStyle(
                                      color: ColorConstants
                                          .darkGreyColor,
                                      fontSize: 14,
                                      fontWeight: FontWeight
                                          .bold),
                                  maxLines: 1,
                                  overflow: TextOverflow
                                      .ellipsis,),
                              ),
                            ],
                          ),
                        ),
                        Padding(
                          padding: const EdgeInsets
                              .only(top: 5,
                              left: 5,
                              right: 5),
                          child: Text(
                            '* Actual delivery charges will be calculated at the time of delivery.',
                            style: TextStyle(
                                color: ColorConstants
                                    .darkGreyColor,
                                fontSize: 12,
                                fontWeight: FontWeight
                                    .bold),),
                        ),
                      ],
                    ),



                    createOrderController.paymentType == 0 ?Container():Column(
                      mainAxisAlignment: MainAxisAlignment
                          .start,
                      crossAxisAlignment: CrossAxisAlignment
                          .start,
                      children: [

                        Padding(
                          padding: const EdgeInsets
                              .only(
                              top: 8, left: 15),
                          child: Text(
                            'Select Payment method : ',
                            style: TextStyle(
                                color: ColorConstants
                                    .primaryColor,
                                fontSize: 16,
                                fontWeight: FontWeight
                                    .bold),),
                        ),
                        const SizedBox(height: 8,),
                        SizedBox(
                          height: Get.height*0.04,
                          width: Get.width*0.6,
                          child: GetBuilder<CreateOrderController>(
                              builder: (controller) {
                                return ListView.builder(
                                    scrollDirection: Axis
                                        .horizontal,
                                    itemCount: controller
                                        .paymentMethod
                                        .length,
                                    shrinkWrap: true,
                                    itemBuilder: (
                                        BuildContext context,
                                        int index) {
                                      return InkWell(
                                        onTap: () {
                                          controller.paymentSelectedIndex = index;
                                          controller.payment = controller.paymentMethod[index]['Paymentmethod'];
                                          print('paymentRange${controller.payment}');
                                          controller.update();
                                          // Get.back();
                                        },
                                        child: Padding(
                                          padding: const EdgeInsets
                                              .only(
                                              left: 20),
                                          child: Row(
                                            children: [
                                              Chip(
                                                backgroundColor: controller
                                                    .paymentSelectedIndex ==
                                                    index
                                                    ? Colors
                                                    .green
                                                    : Colors
                                                    .grey[300],
                                                label: Text(
                                                '${controller
                                                    .paymentMethod[index]['Paymentmethod']}',
                                                style: TextStyle(
                                                    color:  controller
                                                        .paymentSelectedIndex ==
                                                        index
                                                        ? ColorConstants.secondaryColor
                                                        : ColorConstants.darkGreyColor,
                                                    fontSize: 14,
                                                    fontWeight: FontWeight
                                                        .bold),
                                                maxLines: 2,
                                                overflow: TextOverflow
                                                    .ellipsis,),
                                              )
                                            ],
                                          ),

                                          // Column(
                                          //   children: [
                                          //     CircleAvatar(
                                          //       radius: 30,
                                          //       backgroundColor: controller
                                          //           .paymentSelectedIndex ==
                                          //           index
                                          //           ? Colors
                                          //           .green
                                          //           : Colors
                                          //           .grey[400],
                                          //       child: CircleAvatar(
                                          //         radius: 25,
                                          //         backgroundColor: ColorConstants
                                          //             .secondaryColor,
                                          //         child: CircleAvatar(
                                          //           radius: 20,
                                          //           backgroundColor: controller
                                          //               .paymentSelectedIndex ==
                                          //               index
                                          //               ? Colors
                                          //               .green
                                          //               : Colors
                                          //               .grey[400],
                                          //           child: controller
                                          //               .paymentMethod[index]['icon'],
                                          //         ),
                                          //       ),
                                          //     ),
                                          //     const SizedBox(
                                          //       height: 10,),
                                          //     Text(
                                          //       '${controller
                                          //           .paymentMethod[index]['Paymentmethod']}',
                                          //       style: TextStyle(
                                          //           color: ColorConstants
                                          //               .primaryColor,
                                          //           fontSize: 14,
                                          //           fontWeight: FontWeight
                                          //               .bold),
                                          //       maxLines: 2,
                                          //       overflow: TextOverflow
                                          //           .ellipsis,),
                                          //
                                          //   ],
                                          // ),
                                        ),
                                      );
                                    });
                              }
                          ),
                        ),
                        // const Divider(color: Colors.grey,thickness: 2),
                        // Padding(
                        //   padding: const EdgeInsets.only(left: 15,top: 0),
                        //   child: Column(
                        //     mainAxisAlignment: MainAxisAlignment.start,
                        //     crossAxisAlignment: CrossAxisAlignment.start,
                        //     children: [
                        //       Text('Fulfilment:',style: TextStyle(color: ColorConstants.primaryColor,fontSize: 16,fontWeight: FontWeight.bold)),
                        //       // const SizedBox(height: 5,),
                        //       Row(
                        //         mainAxisAlignment: MainAxisAlignment.start,
                        //         crossAxisAlignment: CrossAxisAlignment.center,
                        //         children: [
                        //           Text('SMS required to complete this delivery',style: TextStyle(color: ColorConstants.darkGreyColor,fontWeight: FontWeight.bold,fontSize: 14),),
                        //           const SizedBox(width: 5,),
                        //           GetBuilder<CreateOrderController>(
                        //               builder: (controller) {
                        //                 return Switch(value: controller.smsSelected ,
                        //                   onChanged: (val){
                        //                     controller.smsSelected = val;
                        //                     print('SwitchsmsSelected ${controller.smsSelected}');
                        //                     controller.update();
                        //                   },
                        //                   activeColor: ColorConstants.primaryColor,);
                        //               }
                        //           )
                        //         ],
                        //       ),
                        //     ],
                        //   ),
                        // ),


                      ],
                    )

                  ],
                );
                  // Column(
                  //   mainAxisAlignment: MainAxisAlignment.start,
                  //   crossAxisAlignment: CrossAxisAlignment.start,
                  //   children: <Widget>[
                  //     Stack(
                  //       children: <Widget>[
                  //         Container(
                  //           margin: const EdgeInsets.only(bottom: 10.0),
                  //           alignment: Alignment.centerLeft,
                  //           height: 180.0,
                  //           decoration: BoxDecoration(
                  //             borderRadius: const BorderRadius.only(
                  //               bottomLeft: Radius.elliptical(00, 8),
                  //               bottomRight: Radius.elliptical(00, 8),
                  //             ),
                  //             color: ColorConstants.primaryColor1,
                  //           ),
                  //           child: Padding(
                  //             padding: const EdgeInsets.only(bottom: 60,left: 20,top: 10),
                  //             child: Column(
                  //               crossAxisAlignment: CrossAxisAlignment.center,
                  //               mainAxisAlignment: MainAxisAlignment.center,
                  //               children: [
                  //                 Row(
                  //                   children: [
                  //                     Icon(Icons.person,color: ColorConstants.primaryColor,size: 20),
                  //                     const SizedBox(width: 5,),
                  //                     Expanded(
                  //                       child: Text(
                  //                         '${orderResponseDetails.pickupcustomer??''}',
                  //                         style: const TextStyle(
                  //                             color: Colors.black87, fontSize: 16),
                  //                         maxLines: 1,
                  //                         overflow: TextOverflow.ellipsis,
                  //                       ),
                  //                     ),
                  //                     const SizedBox(width: 4,)
                  //                   ],
                  //                 ),
                  //                 const SizedBox(
                  //                   height:5,
                  //                 ),
                  //                 Row(
                  //                   children: [
                  //                     Icon(
                  //                       Icons.location_on_rounded,
                  //                       size: 20,
                  //                       color: ColorConstants.primaryColor,
                  //                     ),
                  //                     const SizedBox(
                  //                       width: 5,
                  //                     ),
                  //                     Expanded(
                  //                       child: Padding(
                  //                         padding: const EdgeInsets.only(top: 5),
                  //                         child: Text(
                  //                           "${orderResponseDetails.pickupsuburb??''}",
                  //                           style: const TextStyle(
                  //                               color: Colors.black87,
                  //                               overflow: TextOverflow.visible,
                  //                               fontSize: 14),
                  //                           maxLines: 1,
                  //                           overflow: TextOverflow.ellipsis,
                  //                         ),
                  //                       ),
                  //                     ),
                  //
                  //
                  //                     const SizedBox(
                  //                       width: 8,
                  //                     ),
                  //                   ],
                  //                 ),
                  //                 const SizedBox(
                  //                   height:5,
                  //                 ),
                  //                 // Row(
                  //                 //   children: [
                  //                 //     Container(
                  //                 //       padding: EdgeInsets.only(left: 5,right: 5,top: 5,bottom: 5),
                  //                 //       decoration: BoxDecoration(color: ColorConstants.primaryColor,borderRadius: BorderRadius.circular(10)),
                  //                 //       child: Row(
                  //                 //         children: [
                  //                 //           Text('${orderResponseDetails.orderid??''}',style: TextStyle(color: ColorConstants.secondaryColor,fontSize: 12),)
                  //                 //         ],
                  //                 //       ),
                  //                 //     ),
                  //                 //   ],
                  //                 // ),
                  //                 // const SizedBox(
                  //                 //   height:5,
                  //                 // ),
                  //                 Row(
                  //                   children: [
                  //                     Icon(
                  //                       Icons.person,
                  //                       size: 20,
                  //                       color: ColorConstants.primaryColor,
                  //                     ),
                  //                     const SizedBox(
                  //                       width: 5,
                  //                     ),
                  //                     Padding(
                  //                       padding: const EdgeInsets.only(top: 5),
                  //                       child: Text(
                  //                         "${orderResponseDetails.deliverycustomer??''}",
                  //                         style: const TextStyle(
                  //                             color: Colors.black87,
                  //                             overflow: TextOverflow.visible,
                  //                             fontSize: 14),
                  //                       ),
                  //                     ),
                  //
                  //                   ],
                  //                 ),
                  //                 const SizedBox(
                  //                   height:5,
                  //                 ),
                  //
                  //                 Row(
                  //                   children: [
                  //                     Row(
                  //                       children: [
                  //                         Icon(
                  //                           Icons.location_on_rounded,
                  //                           size: 20,
                  //                           color: ColorConstants.primaryColor,
                  //                         ),
                  //                         const SizedBox(
                  //                           width: 5,
                  //                         ),
                  //                         Padding(
                  //                           padding: const EdgeInsets.only(top: 5),
                  //                           child: Text(
                  //                             "${orderResponseDetails.deliverysuburb??''}",
                  //                             style: const TextStyle(
                  //                                 color: Colors.black87,
                  //                                 overflow: TextOverflow.visible,
                  //                                 fontSize: 14),
                  //                           ),
                  //                         ),
                  //
                  //                       ],
                  //                     ),
                  //
                  //                     SizedBox(width: 10,)
                  //                   ],
                  //                 ),
                  //
                  //
                  //               ],
                  //             ),
                  //           ),
                  //           //child: Image.asset("assets/bgImage.jpg"),
                  //         ),
                  //         Card(
                  //           elevation: 0,
                  //           borderOnForeground: false,
                  //           semanticContainer: false,
                  //           shape: RoundedRectangleBorder(
                  //             side: BorderSide(color: ColorConstants.secondaryColor!, width: 1),
                  //             borderRadius: BorderRadius.circular(0),
                  //           ),
                  //           margin: const EdgeInsets.only(
                  //               left: 10, right: 10, top: 130),
                  //           shadowColor: ColorConstants.secondaryColor,
                  //           // color: ColorConstants.secondaryColor,
                  //           // elevation: 2,
                  //           child: SizedBox(
                  //             // height:Get.height * 0.74,
                  //             width: Get.width,
                  //             child: Padding(
                  //               padding: const EdgeInsets.only(top: 9),
                  //               child: Column(
                  //                 children: [
                  //
                  //                 ],
                  //               ),
                  //             ),
                  //           ),
                  //         ),
                  //       ],
                  //     ),
                  //   ]);
              }
            ),
          ],
        ),
        bottomNavigationBar: Container(
          height: Get.height*0.08,
          decoration: BoxDecoration(color: ColorConstants.secondaryColor),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Center(
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 11,top: 0),
                    child: RoundedButton(
                      onPressed: () {
                        createOrderController.orderCreateDescribeValidation();

                      },
                      color:ColorConstants.primaryColor,
                      title: 'Create',
                      controller: createOrderController.createBtnController,
                      textStyle: const TextStyle(
                          fontSize: 18,
                          fontFamily: "Lato",
                          color: Colors.white,
                          fontWeight: FontWeight.bold),
                      height: Get.height*0.06,
                      width: Get.width*0.8,
                    ),
                  )),
            ],
          ),
        ),
        // Container(
        //   height: Get.height*0.08,
        //   decoration: BoxDecoration(color: ColorConstants.secondaryColor),
        //   child:  Padding(
        //     padding: const EdgeInsets.only(top: 6),
        //     child: Row(
        //       mainAxisAlignment: MainAxisAlignment.center,
        //       crossAxisAlignment: CrossAxisAlignment.center,
        //       children: [
        //         Container(
        //           width: Get.width*0.80,
        //           height: Get.height*0.06,
        //           margin: EdgeInsets.only(bottom: 10),
        //           decoration: BoxDecoration(color: ColorConstants.primaryColor,borderRadius: BorderRadius.circular(5)),
        //           child:InkWell(
        //             onTap: (){
        //               Get.to(HomeView(
        //                 selectedIndex: 0,
        //               ));
        //             },
        //             child: Center(
        //               child: Text("Home",
        //                   style: TextStyle(
        //                       fontWeight: FontWeight.bold,
        //                       fontSize: 16,
        //                       color: ColorConstants
        //                           .secondaryColor,
        //                       fontFamily: "Inter")),
        //             ),
        //           ) ,
        //         ),
        //
        //       ],
        //     ),
        //   ),
        // ),
      ),
    );
  }

  Path drawStar(Size size) {
    // Method to convert degree to radians
    double degToRad(double deg) => deg * (pi / 180.0);
    const numberOfPoints = 5;
    final halfWidth = size.width / 2;
    final externalRadius = halfWidth;
    final internalRadius = halfWidth / 2.5;
    final degreesPerStep = degToRad(360 / numberOfPoints);
    final halfDegreesPerStep = degreesPerStep / 2;
    final path = Path();
    final fullAngle = degToRad(360);
    path.moveTo(size.width, halfWidth);
    for (double step = 0; step < fullAngle; step += degreesPerStep) {
      path.lineTo(halfWidth + externalRadius * cos(step),
          halfWidth + externalRadius * sin(step));
      path.lineTo(halfWidth + internalRadius * cos(step + halfDegreesPerStep),
          halfWidth + internalRadius * sin(step + halfDegreesPerStep));
    }
    path.close();
    return path;
  }
}
