import 'package:anyway/presentation/pages/start.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:anyway/core/constants.dart';
import 'package:shared_preferences/shared_preferences.dart';


/// The app entry point.
/// Initializes persistence, sets up dependency injection via ProviderScope,
/// and determines which screen (login or main app) to show based on auth state.
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // initialize local persistence (shared preferences)
  SharedPreferences prefs = await SharedPreferences.getInstance();

  //  the app wrapped in ProviderScope
  runApp(const ProviderScope(child: MyApp()));
}

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


  @override
  Widget build(BuildContext context, WidgetRef ref) {

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: APP_NAME,
      theme: APP_THEME,
      scaffoldMessengerKey: rootScaffoldMessengerKey,
      home: const StartPage()

      // TODO - set up routing
      // onGenerateRoute: AppRouter.onGenerateRoute,
    );
  }
}
