import 'package:flutter/material.dart';
import 'package:vnoteapp/pages/check/models/form.dart';
import 'package:vnoteapp/pages/check/widgets/exam_configurable/exam_card.dart';

class ExamRadio extends StatelessWidget {
  const ExamRadio({
    super.key,
    required this.currentFormObject,
    required this.options,
    required this.selectRaidoChange,
    required this.currentSelected,
  });
  final FormObject currentFormObject;
  final List<Option> options;
  final Function selectRaidoChange;
  final String currentSelected;

  @override
  Widget build(BuildContext context) {
    return ExamCard(
      titleText: RichText(
        text: TextSpan(
          text: currentFormObject.label ?? '',
          style: const TextStyle(
            fontSize: 25,
            color: Colors.black,
          ),
          children: const [
            TextSpan(
              text: '（单选）',
              style: TextStyle(fontSize: 25, color: Colors.grey),
            )
          ],
        ),
      ),
      title: currentFormObject.label ?? '',
      content: Container(
        padding: const EdgeInsets.symmetric(
          horizontal: 5,
        ),
        alignment: currentFormObject.span == 24
            ? Alignment.centerLeft
            : Alignment.center,
        width: double.infinity,
        child: Wrap(
          children: options
              .map(
                (e) => Container(
                  padding: const EdgeInsets.all(7),
                  child: InkWell(
                    onTap: () => selectRaidoChange(e),
                    borderRadius: BorderRadius.circular(50),
                    child: Ink(
                      decoration: BoxDecoration(
                        border: Border.all(
                          color: currentSelected == e.value
                              ? Colors.blue
                              : Colors.black26,
                        ),
                        borderRadius: const BorderRadius.all(
                          Radius.circular(50),
                        ),
                        color: currentSelected == e.value
                            ? Colors.blue
                            : Colors.transparent,
                      ),
                      child: Container(
                        padding: const EdgeInsets.all(15),
                        alignment: Alignment.center,
                        width: 250,
                        child: FittedBox(
                          child: Text(
                            e.label ?? '',
                            style: TextStyle(
                              fontSize: 20,
                              color: currentSelected == e.value
                                  ? Colors.white
                                  : Colors.black54,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
              )
              .toList(),
        ),
      ),
    );
  }
}
