import 'package:flutter/material.dart';
import '../models/download_models.dart';
import '../i18n/strings.g.dart';

class DeletionProgressDialog extends StatelessWidget {
  final DeletionProgress progress;

  const DeletionProgressDialog({super.key, required this.progress});

  @override
  Widget build(BuildContext context) {
    final t = Translations.of(context);

    return PopScope(
      canPop: false, // Prevent back button dismissal
      child: AlertDialog(
        content: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const SizedBox(width: 48, height: 48, child: CircularProgressIndicator()),

            const SizedBox(height: 24),

            Text(
              t.downloads.deletingWithProgress(
                title: progress.itemTitle,
                current: progress.currentItem,
                total: progress.totalItems,
              ),
              style: Theme.of(context).textTheme.titleMedium,
              textAlign: TextAlign.center,
            ),

            const SizedBox(height: 16),

            LinearProgressIndicator(value: progress.progressPercent),

            const SizedBox(height: 8),

            Text('${progress.progressPercentInt}%', style: Theme.of(context).textTheme.bodySmall),

            if (progress.currentOperation != null) ...[
              const SizedBox(height: 8),
              Text(
                progress.currentOperation!,
                style: Theme.of(context).textTheme.bodySmall?.copyWith(
                  color: Theme.of(context).textTheme.bodySmall?.color?.withValues(alpha: 0.7),
                ),
                textAlign: TextAlign.center,
              ),
            ],
          ],
        ),
      ),
    );
  }
}
