import 'package:get/get.dart';
import 'package:sigap/src/features/auth/data/repositories/authentication_repository.dart';

class SplashController extends GetxController {
  final authRepository = Get.find<AuthenticationRepository>();

  // Variable to track if authentication is ready
  final RxBool isAuthReady = false.obs;

  @override
  void onInit() {
    super.onInit();
    // Wait for 3 seconds (matching AnimatedSplashScreen's duration)
    // before handling authentication
    Future.delayed(const Duration(seconds: 3), () {
      isAuthReady.value = true;
      handleAuthentication();
    });
  }

  void handleAuthentication() {
    // Let the AuthenticationRepository handle the screen redirection
    authRepository.screenRedirect();
  }
}
