import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:domain/entity/latest_news_page_entity.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';

///  首页最新新闻News 的Item
class LatestNewsItem extends StatelessWidget {
  final int index;
  final LatestNewsList item;

  const LatestNewsItem({
    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),
      decoration: BoxDecoration(
        color: context.appColors.whiteBG,
        borderRadius: BorderRadius.circular(6.0),
        boxShadow: [
          BoxShadow(
            color: context.appColors.itemBGShadow,
            offset: const Offset(0, 3),
            blurRadius: 8.0,
            spreadRadius: 3.0,
          ),
        ],
      ),
      child: Row(
        mainAxisSize: MainAxisSize.max,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          MyLoadImage(
            item.coverImage,
            width: 100,
            height: 117.5, // 这里可以保留
          ).marginOnly(right: 18),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisSize: MainAxisSize.min,
              children: [
                MyTextView(
                  item.title ?? "",
                  marginTop: 12,
                  fontSize: 16,
                  maxLines: 2,
                  textColor: context.appColors.textBlack,
                  isFontMedium: true,
                ),
                MyTextView(
                  item.content ?? "",
                  marginTop: 5,
                  fontSize: 12,
                  maxLines: 2,
                  textColor: context.appColors.textBlack,
                  isFontRegular: true,
                ),
                MyTextView(
                  item.createdAt ?? "",
                  fontSize: 12,
                  marginBottom: 12,
                  marginTop: 12,
                  textColor: context.appColors.textBlack,
                  isFontRegular: true,
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

}
