28 lines
697 B
Dart
28 lines
697 B
Dart
import 'package:get/get.dart';
|
|
import 'package:firebase_auth/firebase_auth.dart';
|
|
import '../../../routes/app_pages.dart';
|
|
|
|
class SplashScreenController extends GetxController {
|
|
final FirebaseAuth _auth = FirebaseAuth.instance;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
_checkAuthStatus();
|
|
}
|
|
|
|
void _checkAuthStatus() async {
|
|
await Future.delayed(const Duration(seconds: 4));
|
|
|
|
// Cek apakah user sudah login
|
|
User? user = _auth.currentUser;
|
|
|
|
if (user != null) {
|
|
// User sudah login, langsung ke home/navbar
|
|
Get.offAllNamed(Routes.NAVBAR);
|
|
} else {
|
|
// User belum login, ke halaman login
|
|
Get.offAllNamed(Routes.LOGIN);
|
|
}
|
|
}
|
|
} |