import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:flutter/material.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_load_image.dart';
import 'package:widgets/my_text_view.dart';


class HomeCategoryItem extends StatelessWidget {
  final Map<String, dynamic> category;

  HomeCategoryItem({required this.category});

  @override
  Widget build(BuildContext context) {
    // 使用 LayoutBuilder 获取当前可用宽度
    return LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constraints) {
        double itemWidth = constraints.maxWidth; // 获取可用宽度
        return Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            MyAssetImage(
              category['category_icon'],
              width: itemWidth, // 动态设置宽度
              height: itemWidth * (101.5 / 124.5), // 按照比例动态设置高度
            ),
            MyTextView(
              category['category_name'],
              fontSize: 14,
              isFontRegular: true,
              textColor: context.appColors.textBlack,
            ),
          ],
        );
      },
    );
  }
}

