import 'package:flutter/material.dart';
import 'package:planb_logistic/l10n/app_localizations.dart';

class NavigationTermsAndConditionsDialog extends StatelessWidget {
  final VoidCallback onAccept;
  final VoidCallback? onDecline;

  const NavigationTermsAndConditionsDialog({
    Key? key,
    required this.onAccept,
    this.onDecline,
  }) : super(key: key);

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

    return AlertDialog(
      title: Text(
        l10n.navigationTcTitle,
        style: Theme.of(context).textTheme.headlineSmall?.copyWith(
              color: colorScheme.onSurface,
            ),
      ),
      content: SingleChildScrollView(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              l10n.navigationTcDescription,
              style: Theme.of(context).textTheme.bodyMedium?.copyWith(
                    color: colorScheme.onSurface,
                  ),
            ),
            const SizedBox(height: 16),
            Text(
              l10n.navigationTcAttribution,
              style: Theme.of(context).textTheme.bodySmall?.copyWith(
                    color: colorScheme.onSurfaceVariant,
              ),
            ),
            const SizedBox(height: 12),
            Text(
              l10n.navigationTcTerms,
              style: Theme.of(context).textTheme.bodySmall?.copyWith(
                    color: colorScheme.onSurfaceVariant,
              ),
            ),
          ],
        ),
      ),
      actions: [
        if (onDecline != null)
          TextButton(
            onPressed: () {
              Navigator.of(context).pop();
              onDecline!();
            },
            child: Text(
              l10n.decline,
              style: TextStyle(color: colorScheme.error),
            ),
          ),
        TextButton(
          onPressed: () {
            Navigator.of(context).pop();
            onAccept();
          },
          child: Text(
            l10n.accept,
            style: TextStyle(color: colorScheme.primary),
          ),
        ),
      ],
    );
  }
}
