import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:siro_service/views/widgets/my_scafold.dart';

import '../../best_driver_controllers.dart';
import '../../functions/encrypt_decrypt.dart';

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

  @override
  Widget build(BuildContext context) {
    Get.put(DriverTheBestAlexandriaController(), permanent: true);
    return MyScaffold(
      title: 'Alexandria'.tr,
      body: [
        GetBuilder<DriverTheBestAlexandriaController>(builder: (driverthebest) {
          return driverthebest.driver.isNotEmpty
              ? ListView.builder(
                  itemCount: driverthebest.driver.length,
                  itemBuilder: (context, index) {
                    final driver = driverthebest.driver[index];
                    return ListTile(
                      leading: CircleAvatar(
                        child: Text(
                          (int.parse(driver['driver_count'] * 5) / 3600)
                              .toStringAsFixed(0),
                        ),
                      ),
                      title: Text((driver['name_arabic']) ??
                          'Unknown Name'),
                      subtitle: Text(
                          'Phone: ${(driver['phone']) ?? 'N/A'}'),
                      trailing: IconButton(
                        onPressed: () async {
                          Get.defaultDialog(
                              title:
                                  'are you sure to pay to this driver gift'.tr,
                              middleText: '',
                              onConfirm: () async {},
                              onCancel: () => Get.back());
                        },
                        icon: const Icon(Icons.wallet_giftcard_rounded),
                      ),
                    );
                  },
                )
              : const Center(
                  child: Text('No drivers available.'),
                );
        })
      ],
      isleading: true,
    );
  }
}
