import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/colors.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/auth/captin/history_captain.dart';
import 'package:SEFER/controller/functions/launch.dart';
import 'package:SEFER/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'.tr} ${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'.tr} ${res['price_for_driver']}',
                                  style: AppStyle.title,
                                ),
                                Text(
                                  '${'Distance is'.tr} ${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(
                                  '${'Time to Passenger is'.tr} ${res['DriverIsGoingToPassenger']}',
                                  style: AppStyle.title,
                                ),
                                Text(
                                  '${'TimeStart is'.tr} ${res['rideTimeStart']}',
                                  style: AppStyle.title,
                                ),
                                Text(
                                  '${'Time Finish is'.tr} ${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'.tr} ${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'.tr} ${res['status']}',
                                style: AppStyle.title,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ));
        })
      ],
      isleading: true,
    );
  }
}
