import 'package:SEFER/constant/style.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:SEFER/controller/home/captin/map_driver_controller.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';

import '../../../controller/functions/location_controller.dart';
import '../../Rate/rate_passenger.dart';
import 'mapDriverWidgets/driver_end_ride_bar.dart';
import 'mapDriverWidgets/google_driver_map_page.dart';
import 'mapDriverWidgets/google_map_app.dart';
import 'mapDriverWidgets/passenger_info_window.dart';
import 'mapDriverWidgets/sos_connect.dart';

class PassengerLocationMapPage extends StatelessWidget {
  PassengerLocationMapPage({super.key});
  final LocationController locationController = Get.put(LocationController());
  final MapDriverController mapDriverController =
      Get.put(MapDriverController());
  @override
  Widget build(BuildContext context) {
    // Get.put(MapDriverController());

    return MyScafolld(
        title: 'Map Passenger'.tr,
        body: [
          GoogleDriverMap(locationController: locationController),
          const PassengerInfoWindow(),
          driverEndRideBar(),
          const SosConnect(),
          speedCircle(),
          const GoogleMapApp(),
          PricesWindow(),
        ],
        isleading: false);
  }
}

class PricesWindow extends StatelessWidget {
  const PricesWindow({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MapDriverController>(builder: (mapDriverController) {
      return mapDriverController.isPriceWindow
          ? Positioned(
              bottom: Get.height * 1.2,
              // top: Get.height * 3,
              left: Get.height * 1,
              right: Get.height * 1,
              child: Container(
                height: Get.height * 3,
                decoration: AppStyle.boxDecoration1,
                child: Column(
                  children: [
                    Container(
                        decoration: AppStyle.boxDecoration1,
                        child: Padding(
                          padding: const EdgeInsets.all(3),
                          child: Text(
                            'Total Price is '.tr,
                            style: AppStyle.headTitle2,
                            textAlign: TextAlign.center,
                          ),
                        )),
                    const SizedBox(
                      height: 20,
                    ),
                    MyElevatedButton(
                        title: 'ok'.tr,
                        onPressed: () =>
                            Get.to(() => RatePassenger(), arguments: {
                              'rideId': mapDriverController.rideId,
                              'passengerId': mapDriverController.passengerId,
                              'driverId': mapDriverController.driverId
                            }))
                  ],
                ),
              ),
            )
          : const SizedBox();
    });
  }
}
