import 'package:flutter/material.dart'; /// Toggle button representing the current user's registration state for an /// event. Local-state only for now — a future revision will wire this to /// Firestore via the events repository. class RegistrationButton extends StatefulWidget { const RegistrationButton({ super.key, this.initiallyRegistered = false, this.enabled = true, this.fullWidth = false, this.onChanged, }); final bool initiallyRegistered; final bool enabled; final bool fullWidth; final ValueChanged? onChanged; @override State createState() => _RegistrationButtonState(); } class _RegistrationButtonState extends State { late bool _registered; @override void initState() { super.initState(); _registered = widget.initiallyRegistered; } void _toggle() { setState(() => _registered = !_registered); widget.onChanged?.call(_registered); } @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; final child = _registered ? OutlinedButton.icon( onPressed: widget.enabled ? _toggle : null, icon: Icon(Icons.check_circle, color: scheme.primary), label: const Text('Registered'), style: OutlinedButton.styleFrom( foregroundColor: scheme.primary, side: BorderSide(color: scheme.primary), padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 14, ), ), ) : FilledButton.icon( onPressed: widget.enabled ? _toggle : null, icon: const Icon(Icons.how_to_reg), label: const Text('Register'), style: FilledButton.styleFrom( padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 14, ), ), ); if (widget.fullWidth) { return SizedBox(width: double.infinity, child: child); } return child; } }