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

class QueueItemNormalCard extends StatelessWidget {
  final String ticketNo;
  final String roomNo;
  final bool isClinicAdded;
  final TextDirection textDirection;
  final String roomText;
  final String roomTextAr;
  final GlobalConfigurationsModel globalConfigurationsModel;
  final CallTypeEnum callTypeEnum;
  final ScreenTypeEnum screenTypeEnum;
  final LanguageEnum langTypeEnum;

  const QueueItemNormalCard({
    super.key,
    required this.isClinicAdded,
    required this.ticketNo,
    required this.roomNo,
    required this.textDirection,
    required this.roomText,
    required this.roomTextAr,
    required this.globalConfigurationsModel,
    required this.callTypeEnum,
    required this.screenTypeEnum,
    required this.langTypeEnum,
  });

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

  @override
  Widget build(BuildContext context) {
    final text = "${callTypeEnum.getMessageByCallTypeForEnglish(globalConfigurationsModel, isListView: false)} | $roomText $roomNo";
    return Stack(
      children: [
        customShadowSmoothContainer(
          padding: EdgeInsets.symmetric(
            vertical: SizeConfig.getHeightMultiplier() * 0.1,
            horizontal: SizeConfig.getWidthMultiplier() * 1.5,
          ),
          child: Directionality(
            textDirection: textDirection,
            child: Column(
              children: [
                SizedBox(height: SizeConfig.getHeightMultiplier()! * 0.14),
                AppText(
                  getFormattedTicket(ticketNo, isClinicAdded),
                  fontSize: SizeConfig.getWidthMultiplier() * 5,
                  letterSpacing: -1,
                  fontHeight: 0.5,
                  color: AppColors.greyTextColor,
                  fontWeight: FontWeight.bold,
                  fontFamily: AppStrings.fontNamePoppins,
                ),
                SizedBox(height: SizeConfig.getHeightMultiplier()! * 0.15),
                Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    callTypeEnum.getIconByCallType(SizeConfig.getHeightMultiplier() * 0.35),
                  ],
                ),
                SizedBox(height: SizeConfig.getHeightMultiplier()! * 0.14),
                IntrinsicWidth(
                  child: callTypeContainer(
                    textDirection: textDirection,
                    isDisableRightBorderRadius: false,
                    padding: EdgeInsets.all(SizeConfig.getHeightMultiplier() * 0.05),
                    color: callTypeEnum.getColorByCallType(),
                    child: engArabicTextWithSeparatorWidget(
                      fontSize: SizeConfig.getWidthMultiplier()! * 1.8,
                      englishText: roomNo,
                      arabicText: roomTextAr,
                      color: AppColors.whiteColor,
                      mainAxisAlignment: MainAxisAlignment.center,
                    ),
                  ),
                ),
                SizedBox(height: SizeConfig.getHeightMultiplier()! * 0.14),
                AppText(
                  textAlign: TextAlign.center,
                  callTypeEnum.getMessageByCallTypeForArabic(globalConfigurationsModel, isListView: false),
                  color: callTypeEnum.getColorByCallType(),
                  fontSize: SizeConfig.getWidthMultiplier() * 2,
                  fontHeight: 1,
                  fontFamily: AppStrings.fontNameGesTwo,
                  maxLines: 2,
                  textOverflow: TextOverflow.clip,
                ),
                SizedBox(height: SizeConfig.getHeightMultiplier()! * 0.14),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Expanded(
                      child: Center(
                        child: ClipRRect(
                          child: AppText(
                            text,
                            color: callTypeEnum.getColorByCallType(),
                            fontSize: SizeConfig.getWidthMultiplier() * 1.6,
                            fontFamily: AppStrings.fontNamePoppins,
                            textAlign: TextAlign.left,
                            textOverflow: TextOverflow.clip,
                            maxLines: 1,
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        ),
        Padding(
          padding: EdgeInsets.only(
            left: textDirection == TextDirection.ltr ? SizeConfig.getWidthMultiplier() * 2 : 0,
            right: textDirection == TextDirection.rtl ? SizeConfig.getWidthMultiplier() * 2 : 0,
            top: SizeConfig.getHeightMultiplier() * 0.1,
          ),
          child: SvgPicture.asset(AppAssets.hmgLogoPatternLightIcon, height: SizeConfig.getHeightMultiplier() * 0.8),
        ),
      ],
    );
  }
}
