import 'package:flutter/material.dart';
import '../../../../customWidget/ItemWidgetFactory.dart';
import '../../../../customWidget/single_image_viewer.dart';
import '../../../../tools/tools.dart';

class DangerDetail extends StatelessWidget {
  const DangerDetail({super.key});

  @override
  Widget build(BuildContext context) {
    final List<String> imgUrls = [
      "https://pic.rmb.bdstatic.com/bjh/news/100b8b78cbd136ede03249d9f3b3f5c42221.jpeg",
      "https://pic.rmb.bdstatic.com/bjh/news/100b8b78cbd136ede03249d9f3b3f5c42221.jpeg",
    ];
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(5),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          ListView.separated(
            shrinkWrap: true,
            physics: NeverScrollableScrollPhysics(),
            itemCount: 16,
            separatorBuilder: (_, __) => const Divider(height: 1),
            itemBuilder: (context, index) {
              Widget item;
              if (index == 0) {
                item = ListItemFactory.createAloneTextItem(
                  text: "地坪漆漆未分配全皮肤期漆未分配全皮肤期漆未分配全皮肤期未分配全皮肤期间哦飞机哦脾气金佛怕",
                );
              } else if ((index > 0 && index < 4) ||
                  index == 5 ||
                  (index > 6 && index < 15)) {
                item = ListItemFactory.createRowSpaceBetweenItem(
                  leftText: "隐患来源",
                  rightText: "隐患排查",
                );
              } else if (index == 4 || index == 6) {
                item = ListItemFactory.createColumnTextItem(
                  topText: "存在风险",
                  bottomText: "哦IQ好然后前后hi前后哦i",
                );
              } else {
                item = ListItemFactory.createTextImageItem(
                  text: "隐患照片",
                  imageUrls: imgUrls,
                  onImageTapped: (index) {
                    present(
                      SingleImageViewer(imageUrl: imgUrls[index]),
                      context,
                    );
                  },
                );
              }

              // 给每个 item 单独加左右内边距
              return Padding(
                padding: const EdgeInsets.symmetric(
                  horizontal: 12,
                  vertical: 8,
                ),
                child: item,
              );
            },
          ),
        ],
      ),
    );
  }
}
