import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:domain/entity/facility_index_entity.dart';
import 'package:flutter/material.dart';
import 'package:shared/utils/log_utils.dart';
import 'package:shared/utils/util.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_load_image.dart';
import 'package:widgets/my_text_view.dart';

///  设施的Book的Item
class FacilityBookItem extends StatelessWidget {
  final int index;
  final FacilityIndexEntity item;

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

  @override
  Widget build(BuildContext context) {
    Log.d("width:${Utils.extractWidthHeight(item.icon)?[0]} height:${Utils.extractWidthHeight(item.icon)?[1]}");
    return Container(
      width: double.infinity,
      height: 80,
      margin: const EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
      padding: const EdgeInsets.symmetric(horizontal: 20),
      decoration: BoxDecoration(
        color: context.appColors.whiteBG,
        borderRadius: BorderRadius.circular(6.0), // 圆角
      ),
      child: Row(
        mainAxisSize: MainAxisSize.max,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          MyLoadImage(
            item.icon,
            //因为传的是xxhdpi的图片，故要除以3才是显示的宽高
            width: Utils.extractWidthHeight(item.icon) == null ? 40 : Utils.extractWidthHeight(item.icon)![0] / 3,
            height: Utils.extractWidthHeight(item.icon) == null ? 40 : Utils.extractWidthHeight(item.icon)![1] / 3,
          ),
          MyTextView(
            item.name ?? "-",
            marginLeft: 17,
            fontSize: 15.5,
            textColor: context.appColors.textBlack,
            isFontMedium: true,
          ).expanded(),
        ],
      ),
    );
  }
}
