import 'package:fforte/enums/databases.dart'; import 'package:fforte/screens/excursion/excursion_main.dart'; import 'package:fforte/screens/addCam/add_cam_main.dart'; import 'package:fforte/screens/intro_screen.dart'; import 'package:fforte/screens/settings.dart'; import 'package:fforte/screens/viewEntries/view_cams.dart'; import 'package:flutter/material.dart'; import 'package:flex_color_scheme/flex_color_scheme.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'l10n/app_localizations.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'home.dart'; import 'l10n/l10n.dart'; // * Main entry point of the LUPUS app // * Configures the app's: // * - Theme and appearance // * - Localization // * - Navigation routes // * - Initial settings /// Initialize the app and configure default settings void main() async { WidgetsFlutterBinding.ensureInitialized(); // Initialize SharedPreferences for app settings SharedPreferences prefs = await SharedPreferences.getInstance(); // Check if this is the first app launch bool isFirstLaunch = prefs.getBool('isFirstLaunch') ?? true; // Set default control periods if not already configured if (prefs.getString("kTage1")?.isEmpty ?? true) await prefs.setString('kTage1', "28"); if (prefs.getString("kTage2")?.isEmpty ?? true) await prefs.setString('kTage2', "48"); // Commented out API addresses for testing purposes if (prefs.getString("fotofallenApiAddress")?.isEmpty ?? true) await prefs.setString('fotofallenApiAddress', 'https://data.dbb-wolf.de/app24.php'); if (prefs.getString("exkursionenApiAddress")?.isEmpty ?? true) await prefs.setString('exkursionenApiAddress', 'https://data.dbb-wolf.de/api_exkursion.php'); runApp(MyApp(isFirstLaunch: isFirstLaunch)); } /// Main app widget that configures the app's theme and routing class MyApp extends StatelessWidget { final bool isFirstLaunch; const MyApp({super.key, required this.isFirstLaunch}); @override Widget build(BuildContext context) { return MaterialApp( title: 'LUPUS', // Configure light theme with gold color scheme theme: FlexThemeData.light(scheme: FlexScheme.gold, useMaterial3: true), // Configure dark theme with green M3 color scheme darkTheme: FlexThemeData.dark(scheme: FlexScheme.greenM3, useMaterial3: true), themeMode: ThemeMode.system, // Use system theme preference // Show intro screen on first launch, otherwise go to home initialRoute: isFirstLaunch ? '/introScreen' : '/home', // Configure localization support supportedLocales: L10n.all, localizationsDelegates: const [ AppLocalizations.delegate, GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], // Define app navigation routes routes: { '/home': (context) => const HomePage(), '/addCamMain': (context) => const AddCamMain(), '/viewCams': (context) => const ViewEntries(dbType: DatabasesEnum.place,), '/viewExcursionen': (context) => const ViewEntries(dbType: DatabasesEnum.excursion,), '/introScreen': (context) => const IntroScreen(), '/settings': (context) => const Settings(), '/excursion': (context) => const ExcursionMain(), }, ); } }