import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:nutriplant/app/routes/app_pages.dart';

class SplashScreenController extends GetxController {
  final GetStorage storage = GetStorage(); // Tambahkan GetStorage

  @override
  void onInit() {
    super.onInit();
    
    Future.delayed(const Duration(seconds: 3), () {
      // **Cek apakah user sudah login sebelumnya**
      bool isLoggedIn = storage.read("isLoggedIn") ?? false;

      if (isLoggedIn) {
        Get.offAllNamed(Routes.NAVBAR); // Jika sudah login, langsung ke halaman utama
      } else {
        Get.offAllNamed(Routes.LOGIN); // Jika belum, ke halaman login
      }
    });
  }
}
