import 'package:cs_resources/generated/assets.dart';
import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:domain/entity/notification_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';
import 'package:widgets/utils/dark_theme_util.dart';

class NotificationItem extends StatelessWidget {
  final NotificationPageList item;
  final int index;

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

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      color: context.appColors.whiteBG,
      padding: const EdgeInsets.only(left: 11, right: 15, top: 10.5),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const MyAssetImage(
                Assets.mainNotificationItemIcon,
                width: 42.5,
                height: 42.5,
              ).marginOnly(right: 16),

              Column(
                children: [
                  //标题
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [

                      //未读的小圆点
                      Visibility(
                        visible: !item.read,
                        child: Container(
                        width: 6,
                        height: 6,
                        margin: const EdgeInsets.only(right: 8.5),
                        decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          color: context.appColors.tabBgSelectedPrimary,
                        ),
                      ),),


                      //消息标题
                      MyTextView(
                        item.title??"",
                        fontSize: 16,
                        isFontBold: true,
                        textColor: context.appColors.textBlack,
                        maxLines: 2,
                      ).expanded(),

                      //消息时间
                      MyTextView(
                        item.createdAt!.split(" at ")[1],
                        fontSize: 13,
                        marginLeft: 10,
                        isFontRegular: true,
                        textColor: context.appColors.textLightPurple,
                      ),
                    ],
                  ),

                  //内容
                  Row(
                    children: [
                      //文本内容
                      MyTextView(
                        item.body??"",
                        fontSize: 15,
                        marginRight: 15,
                        isFontRegular: true,
                        textColor: context.appColors.textBlack,
                      ).expanded(),

                      // //图片
                      // MyLoadImage(
                      //   "https://img1.baidu.com/it/u=1656098746,3560654086&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800",
                      //   width: 87.5,
                      //   height: 60.5,
                      // ),
                    ],
                  ).marginOnly(top: 9),
                ],
              ).expanded(),
            ],
          ),
          const SizedBox(height: 17.5),
          Divider(
            height: 0.5,
            color: context.appColors.backgroundDark,
          ),
        ],
      ),
    );
  }
}
