import 'dart:async';
import 'package:flutter/material.dart';
// import 'package:video_player/video_player.dart';
import 'welcome_screen.dart';
import 'home_screen.dart';

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

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

class _SplashScreenState extends State<SplashScreen> {
  // Mock login history flag
  final bool hasLoginHistory = true;

  @override
  void initState() {
    super.initState();
    _checkLoginHistory();
  }

  Future<void> _checkLoginHistory() async {
    // Simulate loading time (e.g. 2 seconds)
    await Future.delayed(const Duration(seconds: 2));

    if (!mounted) return;

    if (hasLoginHistory) {
      Navigator.pushReplacement(
        context,
        MaterialPageRoute(builder: (context) => const HomeScreen()),
      );
    } else {
      Navigator.pushReplacement(
        context,
        MaterialPageRoute(builder: (context) => const WelcomeScreen()),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFFFF7500),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset('assets/img/maindog.png', width: 150, height: 150),
            const SizedBox(height: 20),
            const Text(
              'RUP',
              style: TextStyle(
                fontFamily: 'SCDream',
                fontWeight: FontWeight.bold,
                fontSize: 32,
                color: Colors.white,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
