import 'package:flutter/material.dart';
import 'package:hmg_qline/models/global_config_model.dart';
import 'package:hmg_qline/models/ticket_model.dart';
import 'package:hmg_qline/utilities/enums.dart';
import 'package:hmg_qline/views/main_queue_screen/components/ticket_item.dart';
import 'package:hmg_qline/views/view_helpers/size_config.dart';

class PriorityTickets extends StatelessWidget {
  final List<TicketDetailsModel> tickets;
  final GlobalConfigurationsModel globalConfigurationsModel;

  const PriorityTickets({required this.tickets, required this.globalConfigurationsModel, super.key});

  @override
  Widget build(BuildContext context) {
    final TicketDetailsModel firstTicket = tickets[0];
    final List<TicketDetailsModel> otherTickets = tickets.sublist(1, tickets.length);
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        TicketItem(
          ticketNo: firstTicket.ticketModel!.queueNo ?? '',
          scale: globalConfigurationsModel.screenTypeEnum == ScreenTypeEnum.roomLevelScreen ? 2 : 1.2,
          blink: true,
          roomNo: firstTicket.ticketModel!.roomNo ?? '',
          roomText: globalConfigurationsModel.counterText ?? "",
          isClinicAdded: false,
          textDirection: globalConfigurationsModel.textDirection,
          message: globalConfigurationsModel.ticketNoText,
          screenTypeEnum: globalConfigurationsModel.screenTypeEnum,
          langTypeEnum: globalConfigurationsModel.screenLanguageEnum,
        ),
        if (tickets.length > 1) ...[
          // SizedBox(height: SizeConfig.getHeightMultiplier() * 0.8),
          Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: otherTickets
                .map(
                  (ticket) => Padding(
                    padding: EdgeInsets.only(top: SizeConfig.getHeightMultiplier() * 0.5),
                    child: TicketItem(
                      ticketNo: ticket.ticketModel!.queueNo ?? '',
                      scale: 0.8,
                      roomNo: firstTicket.ticketModel!.roomNo ?? '',
                      roomText: globalConfigurationsModel.counterText ?? "",
                      isClinicAdded: false,
                      textDirection: globalConfigurationsModel.textDirection,
                      message: globalConfigurationsModel.ticketNoText,
                      screenTypeEnum: globalConfigurationsModel.screenTypeEnum,
                      langTypeEnum: globalConfigurationsModel.screenLanguageEnum,
                    ),
                  ),
                )
                .toList(),
          )
        ]
      ],
    );
  }
}
