import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:service/controller/mainController/main_controller.dart';
import 'package:service/controller/mainController/pages/complaint.dart';
import 'package:service/controller/mainController/pages/edit_car_plate.dart';
import 'package:service/controller/mainController/pages/passengers_cant_regster.dart';
import 'package:service/views/widgets/my_dialog.dart';
import 'package:service/views/widgets/my_textField.dart';

import '../../constant/style.dart';
import '../../controller/mainController/pages/add_car.dart';
import '../../controller/mainController/pages/drivers_cant_register.dart';
import '../../controller/mainController/pages/welcome_call.dart';
import '../widgets/my_scafold.dart';

class Main extends StatelessWidget {
  Main({super.key});
  MainController mainController = Get.put(MainController());
  @override
  Widget build(BuildContext context) {
    return MyScaffold(title: 'Sefer Service'.tr, isleading: false, body: [
      ListView(
        children: [
          InkWell(
            onTap: () {
              MyDialog().getDialog(
                'insert passenger phone'.tr,
                'midTitle',
                Column(
                  children: [
                    Form(
                        key: mainController.formKey,
                        child: MyTextForm(
                          controller: mainController.passengerPhoneController,
                          label: 'insert passenger phone'.tr,
                          hint: 'insert passenger phone'.tr,
                          type: TextInputType.phone,
                        )),
                  ],
                ),
                () {
                  mainController.searchPassengerByPhone();
                },
              );
            },
            child: Container(
              decoration: AppStyle.boxDecoration,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'passenger details by phone'.tr,
                  style: AppStyle.title,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
          const SizedBox(
            height: 20,
          ),
          InkWell(
            onTap: () {
              MyDialog().getDialog(
                'insert Driver phone'.tr,
                'midTitle',
                Column(
                  children: [
                    Form(
                        key: mainController.formKey,
                        child: MyTextForm(
                          controller: mainController.driverPhoneController,
                          label: 'insert Driver phone'.tr,
                          hint: 'insert Driver phone'.tr,
                          type: TextInputType.phone,
                        )),
                  ],
                ),
                () {
                  mainController.searchDriverByPhone();
                },
              );
            },
            child: Container(
              decoration: AppStyle.boxDecoration,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'Driver details by phone'.tr,
                  style: AppStyle.title,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
          const SizedBox(
            height: 20,
          ),
          InkWell(
            onTap: () async {
              await mainController.getDriverNotCompleteRegistration();
              Get.to(() => DriversCantRegister());
            },
            child: Container(
              decoration: AppStyle.boxDecoration,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'Drivers Cant Register'.tr,
                  style: AppStyle.title,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
          const SizedBox(
            height: 20,
          ),
          InkWell(
            onTap: () async {
              await mainController.getPassengerNotCompleteRegistration();
              Get.to(() => PassengersCantRegister());
            },
            child: Container(
              decoration: AppStyle.boxDecoration,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'Passengers Cant Register'.tr,
                  style: AppStyle.title,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
          const SizedBox(
            height: 20,
          ),
          InkWell(
            onTap: () async {
              await mainController.getdriverWithoutCar();
              if (mainController.driverWithoutCar.isNotEmpty) {
                Get.to(() => const AddCar());
              }
            },
            child: Container(
              decoration: AppStyle.boxDecoration,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'Add car'.tr,
                  style: AppStyle.title,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
          InkWell(
            onTap: () async {
              await mainController.getCarPlateNotEdit();
              if (mainController.carPlateNotEdit.isNotEmpty) {
                Get.to(() => const EditCarPlate());
              }
            },
            child: Container(
              decoration: AppStyle.boxDecoration,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  'Edit car plate'.tr,
                  style: AppStyle.title,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
          const SizedBox(
            height: 20,
          ),
          InkWell(
            onTap: () async {
              // await mainController.getCarPlateNotEdit();
              // if (mainController.carPlateNotEdit.isNotEmpty) {
              Get.to(() => const Complaint());
              // }
            },
            child: Container(
              decoration: AppStyle.boxDecoration,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  "View complaint".tr,
                  style: AppStyle.title,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
          const SizedBox(
            height: 20,
          ),
          InkWell(
            onTap: () async {
              await mainController.getNewDriverRegister();
              // if (mainController.carPlateNotEdit.isNotEmpty) {
              Get.to(() => const WelcomeCall());
              // }
            },
            child: Container(
              decoration: AppStyle.boxDecoration,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  "Welcome call".tr,
                  style: AppStyle.title,
                  textAlign: TextAlign.center,
                ),
              ),
            ),
          ),
        ],
      )
    ]);
  }
}
