import 'package:flutter/material.dart'; class AnswerOption extends StatelessWidget { final String text; final bool isSelected; final VoidCallback onTap; final bool? isCorrect; final bool isMultipleChoice; const AnswerOption({ super.key, required this.text, required this.isSelected, required this.onTap, this.isCorrect, this.isMultipleChoice = false, }); @override Widget build(BuildContext context) { Color? backgroundColor; Color? borderColor; IconData? icon; if (isCorrect != null) { if (isCorrect == true) { backgroundColor = Colors.green.withValues(alpha: 0.1); borderColor = Colors.green; icon = Icons.check_circle; } else { backgroundColor = Colors.red.withValues(alpha: 0.1); borderColor = Colors.red; icon = Icons.cancel; } } else if (isSelected) { backgroundColor = Theme.of(context).colorScheme.primaryContainer; borderColor = Theme.of(context).colorScheme.primary; } return Card( color: backgroundColor, elevation: isSelected ? 4 : 1, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), side: borderColor != null ? BorderSide(color: borderColor, width: 2) : BorderSide.none, ), child: InkWell( onTap: onTap, borderRadius: BorderRadius.circular(12), child: Padding( padding: const EdgeInsets.all(16), child: Row( children: [ if (icon != null) ...[ Icon(icon, color: borderColor), const SizedBox(width: 12), ], Expanded( child: Text( text, style: Theme.of(context).textTheme.bodyLarge, ), ), if (isSelected && icon == null) Icon( isMultipleChoice ? Icons.check_box : Icons.radio_button_checked, color: Theme.of(context).colorScheme.primary, ) else if (!isSelected) Icon( isMultipleChoice ? Icons.check_box_outline_blank : Icons.radio_button_unchecked, color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.5), ), ], ), ), ), ); } }