import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_rx/src/rx_typedefs/rx_typedefs.dart';
import 'package:SEFER/constant/box_name.dart';
import 'package:SEFER/constant/links.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/controller/functions/crud.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/admin/rides/rides.dart';
import 'package:SEFER/views/admin/static/static.dart';
import 'package:SEFER/views/admin/wallet/wallet.dart';
import 'package:SEFER/views/widgets/my_scafold.dart';

import '../../controller/auth/captin/ml_google_doc.dart';
import '../../controller/functions/device_info.dart';
import '../../controller/functions/gemeni.dart';
import 'captain/captain.dart';
import 'passenger/passenger.dart';

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

  @override
  Widget build(BuildContext context) {
    return MyScafolld(
        title: 'Admin Home Page',
        body: [
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              alignment: WrapAlignment.center,
              children: [
                AdminWidgetsDashBoard(
                    title: 'Passengers',
                    onPressed: () => Get.to(() => Passengrs(),
                        transition: Transition.topLevel)),
                AdminWidgetsDashBoard(
                    title: 'Captains',
                    onPressed: () =>
                        Get.to(() => Captain(), transition: Transition.size)),
                AdminWidgetsDashBoard(
                    title: 'Wallet',
                    onPressed: () =>
                        Get.to(() => Wallet(), transition: Transition.fade)),
                AdminWidgetsDashBoard(
                    title: 'Rides',
                    onPressed: () =>
                        Get.to(() => Rides(), transition: Transition.downToUp)),
                AdminWidgetsDashBoard(
                    title: 'Static',
                    onPressed: () => Get.to(() => StaticDash())),
                AdminWidgetsDashBoard(
                    title: 'Gemeni', onPressed: () => AI().generateContent()),
                AdminWidgetsDashBoard(
                    title: 'CarLicenseJordan',
                    onPressed: () => AI().carLicenseJordan()),
                AdminWidgetsDashBoard(
                    title: 'JordanID', onPressed: () => AI().jordanID()),
                AdminWidgetsDashBoard(
                    title: 'Llama',
                    onPressed: () =>
                        CarRegistrationRecognizerController().scanText()),
                AdminWidgetsDashBoard(
                    title: 'Add device to be Admin',
                    onPressed: () async {
                      // Map device = DeviceInfoPlus.deviceData;
                      // print(device);
                      await CRUD().post(link: AppLink.addAdminUser, payload: {
                        // 'deviceNumber': device['serialNumber'].toString(),
                        'name': 'b',
                      });
                    }),
              ],
            ),
          )
        ],
        isleading: false);
  }
}

class AdminWidgetsDashBoard extends StatelessWidget {
  const AdminWidgetsDashBoard({
    super.key,
    required this.title,
    required this.onPressed,
  });
  final String title;
  final Callback onPressed;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: InkWell(
        onTap: onPressed,
        child: Container(
          decoration: AppStyle.boxDecoration,
          height: 100,
          width: Get.width * .4,
          child: Center(
            child: Text(
              title.tr,
              style: AppStyle.title,
            ),
          ),
        ),
      ),
    );
  }
}
