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

class ExamCheckBox extends StatelessWidget {
  const ExamCheckBox({
    super.key,
    required this.currentFormObject,
    required this.options,
    required this.selectCheckBoxChange,
    required this.currentSelectedCheckBox,
  });
  final FormObject currentFormObject;
  final List<Option> options;
  final Function selectCheckBoxChange;
  final List<String> currentSelectedCheckBox;
  @override
  Widget build(BuildContext context) {
    String label = currentFormObject.label ?? '';
    return ExamCard(
      titleText: RichText(
        text: TextSpan(
          text: label,
          style: const TextStyle(
            fontSize: 25,
            color: Colors.black,
          ),
          children: const [
            TextSpan(
              text: '（多选）',
              style: TextStyle(fontSize: 25, color: Colors.grey),
            )
          ],
        ),
      ),
      title: label,
      content: Center(
        child: Wrap(
          children: options
              .map(
                (e) => Container(
                  padding: const EdgeInsets.all(8),
                  child: InkWell(
                    onTap: () => selectCheckBoxChange(e),
                    borderRadius: GlobalStyles.borderRadius,
                    child: Ink(
                      decoration: BoxDecoration(
                        border: Border.all(
                          color: currentSelectedCheckBox.contains(e.value)
                              ? Colors.blue
                              : Colors.black26,
                        ),
                        borderRadius: const BorderRadius.all(
                          Radius.circular(16),
                        ),
                        color: currentSelectedCheckBox.contains(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: currentSelectedCheckBox.contains(e.value)
                                  ? Colors.white
                                  : Colors.black54,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
              )
              .toList(),
        ),
      ),
    );
  }
}
