import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/material.dart';
import 'package:lasertag_app/l10n/app_localizations.dart';
import 'package:provider/provider.dart';

import 'providers/device_provider.dart';
import 'ui/screens/device_selection_screen.dart';

void main() {
  runApp(
    ChangeNotifierProvider(
      create: (context) => DeviceProvider(),
      child: const LasertagApp(),
    ),
  );
}

class LasertagApp extends StatelessWidget {
  const LasertagApp({super.key});

  @override
  Widget build(BuildContext context) {
    return DynamicColorBuilder(
      builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
        return MaterialApp(
          debugShowCheckedModeBanner: false,
          localizationsDelegates: AppLocalizations.localizationsDelegates,
          supportedLocales: AppLocalizations.supportedLocales,
          locale: const Locale('de'),
          theme: ThemeData(
            colorScheme: lightDynamic ?? ColorScheme.fromSeed(seedColor: Colors.blue),
            useMaterial3: true,
          ),
          darkTheme: ThemeData(
            colorScheme: darkDynamic ?? ColorScheme.fromSeed(
              seedColor: Colors.blue, 
              brightness: Brightness.dark
            ),
            useMaterial3: true,
          ),
          themeMode: ThemeMode.system,
          home: const DeviceSelectionScreen(),
        );
      },
    );
  }
}