import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../constant/box_name.dart';
import '../../constant/colors.dart';
import '../../controller/home/map_passenger_controller.dart';
import '../../main.dart';
import '../../views/home/map_widget.dart/cancel_raide_page.dart';
import '../../views/home/map_widget.dart/ride_begin_passenger.dart';

import '../../controller/home/menu_controller.dart';
import 'map_widget.dart/apply_order_widget.dart';
import 'map_widget.dart/buttom_sheet_map_show.dart';
import 'map_widget.dart/car_details_widget_to_go.dart';
import 'map_widget.dart/cash_confirm_bottom_page.dart';
import 'map_widget.dart/google_map_passenger_widget.dart';
import 'map_widget.dart/left_main_menu_icons.dart';
import 'map_widget.dart/main_bottom_menu_map.dart';
import 'map_widget.dart/map_menu_widget.dart';
import 'map_widget.dart/menu_map_page.dart';
import 'map_widget.dart/payment_method.page.dart';
import 'map_widget.dart/points_page_for_rider.dart';
import 'map_widget.dart/ride_from_start_app.dart';
import 'map_widget.dart/searching_captain_window.dart';

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

  @override
  Widget build(BuildContext context) {
    Get.put(MapPassengerController());
    Get.put(MyMenuController());
    return Scaffold(
      body: SafeArea(
        child: Stack(
          children: [
            GoogleMapPassengerWidget(),
            leftMainMenuIcons(),
            // PaymobPackage(),
            const PickerIconOnMap(),
            // PickerAnimtionContainerFormPlaces(),
            const MainBottomMenuMap(),
            // NewMainBottomSheet(),
            const MapMenuWidget(),
            const MenuIconMapPageWidget(),
            buttomSheetMapPage(),
            CarDetailsTypeToChoose(),
            const Burc(),
            const ApplyOrderWidget(),
            // hexagonClipper(),
            const CancelRidePageShow(),
            CashConfirmPageShown(),
            const PaymentMethodPage(),
            const SearchingCaptainWindow(),
            // timerForCancelTripFromPassenger(),
            // const DriverTimeArrivePassengerPage(),
            // const TimerToPassengerFromDriver(),
            const RideBeginPassenger(), const RideFromStartApp(),
            cancelRidePage(),
            PointsPageForRider()
          ],
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MapPassengerController>(
        builder: (controller) =>
            (controller.data.isNotEmpty && controller.remainingTime > 0)
                // ||
                //     controller.timeToPassengerFromDriverAfterApplied == 0
                ? Positioned(
                    right: box.read(BoxName.lang) != 'ar' ? 10 : null,
                    left: box.read(BoxName.lang) == 'ar' ? 10 : null,
                    top: 30,
                    child: GestureDetector(
                      onTap: () {
                        controller.changeCancelRidePageShow();
                      },
                      child: Container(
                        decoration: BoxDecoration(
                            color: AppColor.redColor,
                            borderRadius: BorderRadius.circular(15)),
                        child: const Padding(
                          padding: EdgeInsets.all(3),
                          child: Icon(
                            Icons.clear,
                            size: 40,
                            color: AppColor.secondaryColor,
                          ),
                        ),
                      ),
                    ))
                : const SizedBox());
  }
}

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

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MapPassengerController>(
        builder: (controller) => controller.isPickerShown
            ? Positioned(
                bottom: 0,
                top: 0,
                left: 0,
                right: 0,
                child: controller.isPickerShown
                    ? const Icon(
                        Icons.add_location,
                        color: Colors.purple,
                      )
                    : const SizedBox(),
              )
            : const SizedBox());
  }
}
