import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:taafee_mobile/features/home/business_logic_layer/home_controller.dart';

import '../../../../common/const/const.dart';
import '../../../../common/widgets/text.dart';

class AppointmentWidget extends StatelessWidget {
  AppointmentWidget({
    super.key,
    required this.dateTime,
  });
  final DateTime dateTime;
  final HomeController homeController = Get.find<HomeController>();
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(8),
        color: AppColors.tailAuthColor.withOpacity(0.5),
      ),
      child: SizedBox(
        width: 100,
        height: 50,
        child: Row(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              const Icon(
                Icons.date_range,
                color: Colors.black87,
              ),
              RegularTextWidget(
                DateFormat.EEEE().format(dateTime).tr,
                color: Colors.black87,
              ),
              RegularTextWidget(
                '${dateTime.day} / ${dateTime.month}',
                color: Colors.black87,
              ),
              if (!homeController.isArabic.value)
                RegularTextWidget(
                  '${dateTime.hour % 12} : ${dateTime.minute >= 10 ? dateTime.minute : '0${dateTime.minute}'} ${(dateTime.hour <= 12) ? 'am'.tr : 'pm'.tr}',
                  color: Colors.black87,
                ),
              if (homeController.isArabic.value)
                RegularTextWidget(
                  '${dateTime.minute >= 10 ? dateTime.minute : '0${dateTime.minute}'} : ${dateTime.hour % 12}   ${(dateTime.hour <= 12) ? 'am'.tr : 'pm'.tr}',
                  color: Colors.black87,
                ),
            ]),
      ),
    );
  }
}
