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

/// Wraps a widget with MaterialApp and localization support for testing
Widget createTestableWidget(Widget child) {
  return MaterialApp(
    localizationsDelegates: const [
      AppLocalizations.delegate,
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
      GlobalCupertinoLocalizations.delegate,
    ],
    supportedLocales: const [
      Locale('en'),
      Locale('de'),
    ],
    locale: const Locale('en'),
    home: Scaffold(body: child),
  );
}

/// Wraps a widget with MaterialApp for testing (no Scaffold)
Widget createTestableWidgetNoScaffold(Widget child) {
  return MaterialApp(
    localizationsDelegates: const [
      AppLocalizations.delegate,
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
      GlobalCupertinoLocalizations.delegate,
    ],
    supportedLocales: const [
      Locale('en'),
      Locale('de'),
    ],
    locale: const Locale('en'),
    home: child,
  );
}

/// Wraps a page widget with MaterialApp and navigation for testing
Widget createTestablePageWidget(Widget child) {
  return MaterialApp(
    localizationsDelegates: const [
      AppLocalizations.delegate,
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
      GlobalCupertinoLocalizations.delegate,
    ],
    supportedLocales: const [
      Locale('en'),
      Locale('de'),
    ],
    locale: const Locale('en'),
    home: child,
  );
}
