import 'package:flutter/material.dart';
import 'package:qhdkfq_regulatory_flutter/Custom/dashed_line_text.dart';
import 'package:qhdkfq_regulatory_flutter/Custom/edit_list_items.dart';
import 'package:qhdkfq_regulatory_flutter/tools/h_colors.dart';
import 'package:qhdkfq_regulatory_flutter/tools/my_appbar.dart';

import '../../Custom/read_only_table.dart';

class HelpDetailPage extends StatefulWidget {
  const HelpDetailPage({super.key});

  @override
  State<HelpDetailPage> createState() => _HelpDetailPageState();
}

class _HelpDetailPageState extends State<HelpDetailPage> {
  final List<InfoModel> _infoList = [
    InfoModel("公司名称", "测试1"),
    InfoModel("地址", "测试2"),
    InfoModel("姓名", "测试3"),
    InfoModel("联系电话", "测试4"),
    InfoModel("编号", "测试5"),
    InfoModel("场所", "测试6"),
    InfoModel("类型", "测试7"),
    InfoModel("帮扶时间", "测试8"),
    InfoModel("现场照片", "测试9"),
  ];

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: MyAppbar(title: "帮扶记录详情"),
      body: SafeArea(
        child: ListView(
          padding: EdgeInsets.symmetric(horizontal: 15),
          children: [
            SizedBox(height: 20),
            DashedLineText(
              text: "基本信息",
              lineColor: h_mainBlueColor(),
              textStyle: TextStyle(fontSize: 16, color: h_mainBlueColor()),
            ),
            ListView.separated(
              shrinkWrap: true,
              physics: const ClampingScrollPhysics(), // 嵌套listview关闭回弹
              separatorBuilder:
                  (_, __) => const Divider(height: 0.5, color: Colors.black12),
              itemCount: _infoList.length,
              itemBuilder: (context, index) {
                final InfoModel item = _infoList[index];
                return EditListItems.createRowSpaceBetweenItem(
                  horizontalPadding: 10,
                  verticalPadding: 15,
                  leftText: item.title,
                  rightText: item.discript,
                );
              },
            ),
            DashedLineText(
              text: "帮扶内容",
              lineColor: h_mainBlueColor(),
              textStyle: TextStyle(fontSize: 16, color: h_mainBlueColor()),
            ),
            SizedBox(height: 20),

            ReadOnlyTable(
              headers: ['序号', '所属帮扶', '隐患描述', '操作'],
              columnWidths: [
                const FixedColumnWidth(50),
                const FlexColumnWidth(2),
                const FlexColumnWidth(3),
                const FlexColumnWidth(1.5),
              ],
              data: [
                ['1', '政府部门', '测试文本测，试文本测试文本测试文本，测试文本测试文本', '合格'],
                ['2', '社会组织', '试文本测试文本测试文本', '不合格'],
              ],
              onTapAction: (row) {
                print('点击操作：第\$row 行');
              },
            ),
            SizedBox(height: 20),
            DashedLineText(
              text: "帮扶隐患",
              lineColor: h_mainBlueColor(),
              textStyle: TextStyle(fontSize: 16, color: h_mainBlueColor()),
            ),
            SizedBox(height: 20),

            ReadOnlyTable(headers: ['序号', '来源', '内容', '操作'], data: []),
          ],
        ),
      ),
    );
  }



}

class InfoModel {
  final String title;
  final String discript;

  InfoModel(this.title, this.discript);
}
