import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:slrpg_app/src/core/theme/app_theme.dart';
import '../../../../l10n/app_localizations.dart';

class ConsentCheckbox extends StatelessWidget {
  final bool value;
  final ValueChanged<bool> onChanged;

  const ConsentCheckbox({
    super.key,
    required this.value,
    required this.onChanged,
  });

  @override
  Widget build(BuildContext context) {
    final l10n = AppLocalizations.of(context)!;

    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Checkbox(
          value: value,
          onChanged: (v) => onChanged(v ?? false),
          activeColor: AppTheme.primaryColor,
        ),
        Expanded(
          child: GestureDetector(
            onTap: () {
              onChanged(!value);
            },
            child: Wrap(
              crossAxisAlignment: WrapCrossAlignment.center,
              children: [
                Text("${l10n.consentAcceptPrefix} "),
                GestureDetector(
                  onTap: () {
                    context.push('/privacy-policy');
                  },
                  child: Text(
                    l10n.consentTermsOfService,
                    style: TextStyle(
                      color: AppTheme.secondaryColor,
                      decoration: TextDecoration.underline,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }
}
