import 'package:flutter/material.dart';
import 'package:qhdkfq_regulatory_flutter/tools/my_appbar.dart';

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

  @override
  State<HelpRecordPage> createState() => _HelpRecordPageState();
}

class _HelpRecordPageState extends State<HelpRecordPage> {
  Widget _buildDynamicRadioRow({
    required List<String> options, // 选项文本数组
    required int? selectedValue, // 当前选中的值（索引）
    required ValueChanged<int?> onChanged, // 选项变更回调
  }) {
    return Wrap(
      spacing: 5, // 横向间距
      runSpacing: 5, // 纵向行距
      children: List.generate(options.length, (i) {
        return _buildRadioOption(
          isSelected: selectedValue == i,
          label: options[i],
          value: i,
          onChanged: onChanged,
        );
      }),
    );
  }

  /// 自定义Radio
  Widget _buildRadioOption({
    required bool isSelected,
    required String label,
    required int value,
    required ValueChanged<int?> onChanged,
  }) {
    return InkWell(
      onTap: () => onChanged(value),
      splashColor: Colors.blue,
      borderRadius: BorderRadius.circular(20),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          // 自定义单选按钮 - 带对勾样式
          SizedBox(
            child:
                isSelected
                    ? const Icon(
                      Icons.check_circle,
                      size: 22,
                      color: Colors.blue,
                    )
                    : const Icon(
                      Icons.circle_outlined,
                      size: 22,
                      color: Colors.grey,
                    ),
          ),
          SizedBox(width: 10),
          Text(
            label,
            style: TextStyle(
              fontSize: 15,
              color: isSelected ? Colors.blue : Colors.grey[700],
              fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
            ),
          ),
          SizedBox(width: 10),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    late List<String> radioTitles = ["日常检查","专项检查","总和检查","执法检查","举报检查"];

    /// 选择的radio
    late int? selectRadioIndex = 0;
    return Scaffold(
      appBar: MyAppbar(title: "帮扶记录"),
      body: SafeArea(
        child: Column(
          children: [
            Container(
              width: double.maxFinite,
              padding: EdgeInsets.all(15),
              color: Colors.white,
              child: _buildDynamicRadioRow(
                options: radioTitles,
                selectedValue: selectRadioIndex,
                onChanged: (val) {
                  setState(() {
                    selectRadioIndex = val;
                  });
                },
              ),
            ),
            SizedBox(height: 10,),
            ListView(
              children: [

              ],
            )
          ],
        ),
      ),
    );
  }
}
