import 'package:blinking_text/blinking_text.dart';
import 'package:flutter/material.dart';
import 'package:hmg_qline/constants/app_constants.dart';
import 'package:hmg_qline/utilities/enums.dart';
import 'package:hmg_qline/views/common_widgets/app_texts_widget.dart';
import 'package:hmg_qline/views/view_helpers/size_config.dart';

class TicketItem extends StatelessWidget {
  final String ticketNo;
  final String roomNo;
  final bool blink;
  final double scale;
  final bool isClinicAdded;
  final TextDirection textDirection;
  final String message;
  final String roomText;
  final ScreenTypeEnum screenTypeEnum;
  final LanguageEnum langTypeEnum;

  const TicketItem({
    super.key,
    required this.isClinicAdded,
    required this.ticketNo,
    required this.roomNo,
    required this.scale,
    required this.textDirection,
    required this.message,
    required this.roomText,
    required this.screenTypeEnum,
    required this.langTypeEnum,
    this.blink = false,
  });

  String getFormattedTicket(String ticketNo, bool isClinicAdded) {
    if (isClinicAdded) {
      var formattedString = ticketNo.split(" ");
      return "${formattedString[0]}   ${formattedString[1]}";
    }
    return ticketNo;
  }

  @override
  Widget build(BuildContext context) {
    return Transform.scale(
      scale: scale,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          BlinkText(getFormattedTicket(ticketNo, isClinicAdded),
              style: TextStyle(
                fontSize: SizeConfig.getWidthMultiplier() * 10,
                letterSpacing: -1,
                height: 0.5,
                fontWeight: FontWeight.bold,
                fontFamily: langTypeEnum == LanguageEnum.arabic ? AppStrings.fontNameCairo : AppStrings.fontNamePoppins,
              ),
              beginColor: Colors.black,
              endColor: blink ? Colors.black.withOpacity(0.1) : Colors.black,
              // endColor: blink ? AppGlobal.appRedColor : Colors.black,
              times: 0,
              duration: const Duration(seconds: 1)),
          const SizedBox(height: 20),
          screenTypeEnum == ScreenTypeEnum.roomLevelScreen
              ? const SizedBox()
              : Directionality(
                  textDirection: textDirection,
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.end,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      AppText(
                        message,
                        color: AppColors.blackColor,
                        letterSpacing: -1,
                        fontSize: SizeConfig.getWidthMultiplier() * 3.8,
                        fontWeight: FontWeight.w600,
                        fontHeight: 1,
                        fontFamily: langTypeEnum == LanguageEnum.arabic ? AppStrings.fontNameCairo : AppStrings.fontNamePoppins,
                      ),
                      Container(
                        color: Colors.grey.withOpacity(0.5),
                        width: 5,
                        height: SizeConfig.getHeightMultiplier() * 0.3,
                        margin: const EdgeInsets.symmetric(horizontal: 15),
                      ),
                      AppText(
                        textDirection == TextDirection.ltr ? "$roomText: $roomNo" : " $roomNo : $roomText",
                        color: AppColors.blackColor,
                        letterSpacing: -1,
                        fontSize: SizeConfig.getWidthMultiplier() * 3.8,
                        fontWeight: FontWeight.w600,
                        fontHeight: 1,
                        fontFamily: langTypeEnum == LanguageEnum.arabic ? AppStrings.fontNameCairo : AppStrings.fontNamePoppins,
                      ),
                    ],
                  ),
                ),
        ],
      ),
    );
  }
}
