import 'package:flutter/material.dart'; import 'login.dart'; import 'screens/mobile_home_screen.dart'; import 'services/auth_service.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'SPK Rekomendasi', theme: ThemeData( colorScheme: ColorScheme.fromSeed( seedColor: Colors.blue, primary: Colors.blue, secondary: Colors.blue.shade700, surface: Colors.white, ), useMaterial3: true, ), home: const SplashScreen(), debugShowCheckedModeBanner: false, ); } } // Splash screen untuk check authentication class SplashScreen extends StatefulWidget { const SplashScreen({super.key}); @override State createState() => _SplashScreenState(); } class _SplashScreenState extends State { final _authService = AuthService(); @override void initState() { super.initState(); _checkAuth(); } Future _checkAuth() async { await _authService.loadToken(); // Delay untuk splash effect await Future.delayed(const Duration(milliseconds: 500)); if (!mounted) return; // Navigate based on auth status if (_authService.isAuthenticated) { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => const MobileHomeScreen()), ); } else { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => const LoginScreen()), ); } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: const Color(0xFF1565C0), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( padding: const EdgeInsets.all(24), decoration: const BoxDecoration( color: Colors.white, shape: BoxShape.circle, ), child: const Icon( Icons.home_work, size: 80, color: Color(0xFF1565C0), ), ), const SizedBox(height: 24), const Text( 'SPK Kontrakan', style: TextStyle( fontSize: 28, fontWeight: FontWeight.bold, color: Colors.white, ), ), const SizedBox(height: 8), const Text( 'Rekomendasi Kontrakan Terbaik', style: TextStyle(fontSize: 14, color: Colors.white70), ), const SizedBox(height: 32), const CircularProgressIndicator( valueColor: AlwaysStoppedAnimation(Colors.white), ), ], ), ), ); } }