import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import 'common/settings/app_settings.dart';
import 'constants/colors.dart';
import 'common/routing/router.dart';

class App extends ConsumerWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    bool useMaterial3 = ref.watch(useMaterial3Provider);
    bool useDarkMode = ref.watch(useDarkModeProvider);
    bool showPerformanceOverlay = ref.watch(showPerformanceOverlayProvider);
    ColorSeed colorSeedSelected = ref.watch(colorSeedSelectedProvider);

    return MaterialApp.router(
      showPerformanceOverlay: showPerformanceOverlay,
      routerConfig: goRouter,
      debugShowCheckedModeBanner: false,
      title: 'eLinux',
      theme: ThemeData(
        colorSchemeSeed: colorSeedSelected.color,
        useMaterial3: useMaterial3,
        brightness: Brightness.light,
      ),
      darkTheme: ThemeData(
        colorSchemeSeed: colorSeedSelected.color,
        useMaterial3: useMaterial3,
        brightness: Brightness.dark,
      ),
      themeMode: useDarkMode ? ThemeMode.dark : ThemeMode.light,
    );
  }
}
