import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../../../data/bean/option_select_config.dart';
import '../../../../../data/bean/option_select_item.dart';
import '../../../widget/option_select_widget.dart';

/// 选择时回调
typedef OnSelectOptionCallback =
    void Function(OptionSelectConfig rowConfig, OptionSelectItem optionItem);

/// 回复语气选项列表
class ReplyToneOptionList extends StatelessWidget {
  /// 回复语气选项列表
  final List<OptionSelectConfig> replyToneOptionSelectConfigList;

  /// 选择回调
  final OnSelectOptionCallback onSelectOptionCallback;

  const ReplyToneOptionList({
    super.key,
    required this.replyToneOptionSelectConfigList,
    required this.onSelectOptionCallback,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        // 添加选项行
        for (var optionConfig in replyToneOptionSelectConfigList)
          _buildOptionRow(optionConfig),
      ],
    );
  }

  /// 构建一行选择选项行
  Widget _buildOptionRow(OptionSelectConfig config) {
    return Column(
      children: [
        // 选择项
        OptionSelectWidget(
          optionSelect: config,
          optionSelectCallback: (
            OptionSelectConfig rowConfig,
            OptionSelectItem optionItem,
          ) {
            onSelectOptionCallback(rowConfig, optionItem);
          },
        ),
        SizedBox(height: 20.h),
      ],
    );
  }
}
