import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ride/constant/colors.dart';
import 'package:ride/constant/style.dart';
import 'package:ride/controller/auth/captin/history_captain.dart';
import 'package:ride/controller/functions/launch.dart';
import 'package:ride/views/widgets/my_scafold.dart';

import '../../../widgets/mycircular.dart';

class HistoryDetailsPage extends StatelessWidget {
  HistoryDetailsPage({super.key});
  HistoryCaptainController historyCaptainController =
      Get.put(HistoryCaptainController());
  @override
  Widget build(BuildContext context) {
    return MyScafolld(
      title: 'Trip Detail'.tr,
      body: [
        GetBuilder<HistoryCaptainController>(
            builder: (historyCaptainController) {
          var res = historyCaptainController.historyDetailsData['data'];
          return Expanded(
              child: historyCaptainController.isloading
                  ? const MyCircularProgressIndicator()
                  : SingleChildScrollView(
                      child: Column(
                        children: [
                          Container(
                            width: Get.width * .8,
                            decoration: BoxDecoration(
                                border: Border.all(
                                    color: AppColor.blueColor, width: 2)),
                            child: TextButton(
                              onPressed: () {
                                String mapUrl =
                                    'https://www.google.com/maps/dir/${res['start_location']}/${res['end_location']}/';
                                print(mapUrl);
                                showInBrowser(mapUrl);
                              },
                              child: Text(
                                'Trip on Map Click here'.tr,
                                style: AppStyle.title,
                              ),
                            ),
                          ),
                          const SizedBox(
                            height: 10,
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              Text(
                                'Order ID ${res['id']}',
                                style: AppStyle.title,
                              ),
                              Text(
                                res['date'].toString(),
                                style: AppStyle.title,
                              ),
                            ],
                          ),
                          const SizedBox(
                            height: 10,
                          ),
                          Container(
                            width: Get.width * .8,
                            decoration: BoxDecoration(
                                border: Border.all(
                                    color: AppColor.greenColor, width: 2)),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                              children: [
                                Text(
                                  'Price is ${res['price_for_driver']}',
                                  style: AppStyle.title,
                                ),
                                Text(
                                  'Distance is ${res['distance']} KM',
                                  style: AppStyle.title,
                                ),
                              ],
                            ),
                          ),
                          const SizedBox(
                            height: 10,
                          ),
                          Text(
                            'Times of Trip'.tr,
                            style: AppStyle.title,
                          ),
                          const SizedBox(
                            height: 10,
                          ),
                          Container(
                            width: Get.width * .8,
                            decoration: BoxDecoration(
                                border: Border.all(
                                    color: AppColor.redColor, width: 2)),
                            child: Column(
                              children: [
                                Text(
                                  'To Passenger is ${res['DriverIsGoingToPassenger']}',
                                  style: AppStyle.title,
                                ),
                                Text(
                                  'TimeStart is ${res['rideTimeStart']}',
                                  style: AppStyle.title,
                                ),
                                Text(
                                  'Time Finish is ${res['rideTimeFinish']}',
                                  style: AppStyle.title,
                                ),
                              ],
                            ),
                          ),
                          const SizedBox(
                            height: 10,
                          ),
                          Container(
                            width: Get.width * .8,
                            decoration: BoxDecoration(
                                border: Border.all(
                                    color: AppColor.greenColor, width: 2)),
                            child: Center(
                              child: Text(
                                'Passenger Name is ${res['first_name']} ${res['last_name']} ',
                                style: AppStyle.title,
                              ),
                            ),
                          ),
                          const SizedBox(
                            height: 10,
                          ),
                          Container(
                            width: Get.width * .8,
                            decoration: BoxDecoration(
                                border: Border.all(
                                    color: AppColor.yellowColor, width: 2)),
                            child: Center(
                              child: Text(
                                'Status is ${res['status']}',
                                style: AppStyle.title,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ));
        })
      ],
      isleading: true,
    );
  }
}
