import 'package:digiplug/core/navigation/navigator.dart';
import 'package:flutter/material.dart';

class SplashScreen extends StatefulWidget {
  const SplashScreen({super.key});

  @override
  State<SplashScreen> createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  @override
  void initState() {
    super.initState();
    _initializeApp();
  }

  Future<void> _initializeApp() async {
    // Memberi jeda 2 detik untuk menampilkan splash screen
    await Future.delayed(const Duration(seconds: 2));

    // Setelah jeda, langsung arahkan ke halaman login
    if (mounted) {
      AppNavigator.pushNamedAndClear(loginRoute);
    }
  }

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            CircularProgressIndicator(),
            SizedBox(height: 20),
            Text("Memuat aplikasi..."),
          ],
        ),
      ),
    );
  }
}
