import 'package:comwell_key_app/check_out/components/check_out_bill_list_item.dart';
import 'package:comwell_key_app/services/models/booking_dto.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:comwell_key_app/utils/l10n_utils.dart';
import 'package:flutter/material.dart';

class CheckoutItemizedBill extends StatelessWidget {
  final Iterable<BookingAddonItem> addOnItems;
  final bool applyClubPoints;
  final int totalPriceBeforeDiscount;
  final int totalPriceAfterDiscount;
  final int trimmedBalance;
  const CheckoutItemizedBill({super.key, required this.addOnItems, required this.applyClubPoints, required this.totalPriceBeforeDiscount, required this.totalPriceAfterDiscount, required this.trimmedBalance});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ...addOnItems.map((item) => Column(
              children: [
                CheckOutBillListItem(item: item),
                const SizedBox(height: 14)
              ],
            )),
        const Divider(color: colorDivider),
        const SizedBox(height: 12),
        Row(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(context.strings.checkout_page_payment_total),
            if (applyClubPoints)
              Row(
                children: [
                  Text(
                    "$totalPriceBeforeDiscount",
                    style: const TextStyle(
                        decoration: TextDecoration.lineThrough,
                        decorationColor: colorDivider,
                        color: colorDivider),
                  ),
                  const SizedBox(width: 4),
                  Text("$totalPriceAfterDiscount"),
                ],
              )
            else
              Text(trimmedBalance.toString()),
          ],
        ),
        const SizedBox(height: 12),
        const Divider(color: colorDivider),
      ],
    );
  }
}