import 'package:cpt_facility/modules/facility/active/facility_active_screen.dart';
import 'package:cs_resources/generated/l10n.dart';
import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:domain/entity/facility_page_entity.dart';
import 'package:flutter/material.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_text_view.dart';

///  设施的History的Item
class FacilityHistoryItem extends StatelessWidget {
  final int index;
  final FacilityDetail item;

  const FacilityHistoryItem({
    required this.index,
    required this.item,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      margin: const EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
      padding: const EdgeInsets.only(left: 20, right: 15, top: 18, bottom: 23),
      decoration: BoxDecoration(
        color: context.appColors.whiteBG,
        borderRadius: BorderRadius.circular(6.0), // 圆角
      ),
      child: Row(
        mainAxisSize: MainAxisSize.max,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              //设施
              MyTextView(
                item.facility?.type?.name ?? "",
                fontSize: 16,
                maxLines: 3,
                textColor: context.appColors.textBlack,
                isFontMedium: true,
              ),

              //分类
              MyTextView(
                item.facility?.name ?? "",
                fontSize: 14,
                marginTop: 3,
                textColor: context.appColors.textBlack,
                isFontRegular: true,
              ),

              //预订人
              MyTextView(
                S.current.booked_by_someone(item.account?.name ?? ""),
                fontSize: 14,
                marginTop: 3,
                textColor: context.appColors.textBlack,
                isFontRegular: true,
              ),

              //日期
              MyTextView(
                item.booking?.date ?? "",
                fontSize: 14,
                marginTop: 16,
                textColor: context.appColors.textBlack,
                isFontRegular: true,
              ),

              //时间
              MyTextView(
                "${item.booking?.start ?? ""}-${item.booking?.end ?? ""}",
                fontSize: 14,
                marginBottom: 7,
                marginTop: 3,
                textColor: context.appColors.textBlack,
                isFontRegular: true,
              ),

              //标签
              Row(
                children: [
                  MyTextView(
                    "Fee Paid",
                    textColor: context.appColors.textPrimary,
                    fontSize: 13,
                    isFontRegular: true,
                    backgroundColor: context.appColors.lightBlueDarkBg,
                    cornerRadius: 3,
                    paddingLeft: 7,
                    marginRight: 6,
                    paddingRight: 7,
                    paddingTop: 3,
                    paddingBottom: 3,
                  ),
                  MyTextView(
                    "Deposit Released",
                    textColor: context.appColors.textPrimary,
                    fontSize: 13,
                    isFontRegular: true,
                    backgroundColor: context.appColors.lightBlueDarkBg,
                    cornerRadius: 3,
                    paddingLeft: 7,
                    marginRight: 6,
                    paddingRight: 7,
                    paddingTop: 3,
                    paddingBottom: 3,
                  )
                ],
              )
            ],
          ).expanded(),
          Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment:MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              MyTextView(
                item.order?.refundStatus != 0
                    ? S.current.refunded
                    : item.order?.paymentStatus == 1
                    ? S.current.paid
                    : S.current.unpaid,
                textColor: item.order?.refundStatus != 0
                    ? context.appColors.textDisEnableGray
                    : item.order?.paymentStatus == 1
                    ? context.appColors.textPrimary
                    : context.appColors.deleteRed,
                cornerRadius: 3,
                borderWidth: 0.5,
                borderColor: item.order?.refundStatus != 0
                    ? context.appColors.textDisEnableGray
                    : item.order?.paymentStatus == 1
                    ? context.appColors.textPrimary
                    : context.appColors.deleteRed,
                paddingTop: 3,
                paddingBottom: 3,
                paddingLeft: 15,
                paddingRight: 15,
                textAlign: TextAlign.center,
              ),
            ],
          )
        ],
      ),
    );
  }
}
