import 'package:flutter/material.dart';

import '../../../../../customWidget/ItemWidgetFactory.dart';
import '../../../../../customWidget/photo_picker_row.dart';


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

  @override
  State<DangerAcceptance> createState() => _DangerAcceptanceState();
}

class _DangerAcceptanceState extends State<DangerAcceptance> {
  late bool _isQualified = true;
  final dangerDiscripController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 0),
      child: DecoratedBox(
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(5),
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            // 标题
            ListItemFactory.createBuildSimpleSection("隐患验收"),
            const Divider(height: 1),
            ListItemFactory.createYesNoSection(
              title: "是否合格",
              yesLabel: "是",
              noLabel: "否",
              groupValue: _isQualified,
              onChanged: (val) {
                setState(() {
                  _isQualified = val;
                });
              },
            ),
            if (_isQualified)
            // 修复信息 summary 区域
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 12),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Divider(),
                    ListItemFactory.createBuildMultilineInput(
                        "验收描述", "请对隐患进行详细描述",
                        dangerDiscripController),
                    Divider(height: 10,),
                    // const SizedBox(height: 10),
                    GestureDetector(
                      onTap: () {

                      },
                      child: ListItemFactory.createRowSpaceBetweenItem(
                          leftText: "验收日期",
                          rightText: "请选择",
                          isRight: true)
                      ,
                    ),
                    Divider(),
                    RepairedPhotoSection(
                      horizontalPadding: 0,
                      title: "验收图片",
                      maxCount: 4,
                      mediaType: MediaType.image,
                      onChanged: (files) {
                        // 上传 files 到服务器
                      },
                      onAiIdentify: () {},
                    ),
                  ],
                ),
              ),
          ],
        ),
      ),
    );
  }
}
