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/firebase/firbase_messge.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';
import 'package:SEFER/views/widgets/my_textField.dart';

import '../../../controller/admin/passenger_admin_controller.dart';

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

  @override
  Widget build(BuildContext context) {
    final arguments = Get.arguments;
    final Map<String, dynamic> data = arguments['data'];
    var key = Get.find<PassengerAdminController>().formPrizeKey;
    var titleNotify = Get.find<PassengerAdminController>().titleNotify;
    var bodyNotify = Get.find<PassengerAdminController>().bodyNotify;
    return MyScafolld(
      title: data['first_name'],
      body: [
        Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                'Email is ${data['email']}',
                style: AppStyle.title,
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'Phone is ${data['phone']}',
                    style: AppStyle.title,
                  ),
                  Text(
                    'gender is ${data['gender']}',
                    style: AppStyle.title,
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'status is ${data['status']}',
                    style: AppStyle.title,
                  ),
                  Text(
                    'birthdate is ${data['birthdate']}',
                    style: AppStyle.title,
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'site is ${data['site']}',
                    style: AppStyle.title,
                  ),
                  Text(
                    'sosPhone is ${data['sosPhone']}',
                    style: AppStyle.title,
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'Count Feedback is ${data['countFeedback']}',
                    style: AppStyle.title,
                  ),
                  Text(
                    'Count Driver Rate is ${data['countDriverRate']}',
                    style: AppStyle.title,
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'Count Cancel is ${data['countPassengerCancel']}',
                    style: AppStyle.title,
                  ),
                  Text(
                    'Count Ride is ${data['countPassengerRide']}',
                    style: AppStyle.title,
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'Rating Captain Avarage is ${data['passengerAverageRating']}',
                    style: AppStyle.title,
                  ),
                  Text(
                    'Rating is ${data['ratingPassenger']}',
                    style: AppStyle.title,
                  ),
                ],
              ),
              Container(
                decoration: BoxDecoration(
                    border: Border.all(width: 3, color: AppColor.yellowColor)),
                child: TextButton(
                  onPressed: () async {
                    Get.defaultDialog(
                        title: 'Send Notification'.tr,
                        titleStyle: AppStyle.title,
                        content: Form(
                          key: key,
                          child: Column(
                            children: [
                              MyTextForm(
                                  controller: titleNotify,
                                  label: 'title'.tr,
                                  hint: 'title notificaton'.tr,
                                  type: TextInputType.name),
                              const SizedBox(
                                height: 10,
                              ),
                              MyTextForm(
                                  controller: bodyNotify,
                                  label: 'body'.tr,
                                  hint: 'body notificaton'.tr,
                                  type: TextInputType.name)
                            ],
                          ),
                        ),
                        confirm: MyElevatedButton(
                            title: 'Send',
                            onPressed: () {
                              print(titleNotify.text);
                              if (key.currentState!.validate()) {
                                FirebaseMessagesController()
                                    .sendNotificationToAnyWithoutData(
                                  titleNotify.text,
                                  bodyNotify.text,
                                  data['passengerToken'],
                                );
                                Get.back();
                              }
                            }));
                  },
                  child: Text(
                    "Send Notificaion to Passenger ".tr,
                    style: AppStyle.title,
                  ),
                ),
              )
            ],
          ),
        )
      ],
      isleading: true,
    );
  }
}
