79 lines
1.9 KiB
Dart
79 lines
1.9 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:firebase_auth/firebase_auth.dart';
|
|
|
|
import '../screens/login_page.dart';
|
|
import '../screens/dashboard_page.dart';
|
|
|
|
class SplashPage extends StatefulWidget {
|
|
const SplashPage({super.key});
|
|
|
|
@override
|
|
State<SplashPage> createState() => _SplashPageState();
|
|
}
|
|
|
|
class _SplashPageState extends State<SplashPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_checkLogin();
|
|
}
|
|
|
|
void _checkLogin() {
|
|
Timer(const Duration(seconds: 2), () {
|
|
final user = FirebaseAuth.instance.currentUser;
|
|
|
|
if (user != null) {
|
|
Navigator.pushReplacement(
|
|
context,
|
|
MaterialPageRoute(builder: (_) => const DashboardPage()),
|
|
);
|
|
} else {
|
|
Navigator.pushReplacement(
|
|
context,
|
|
MaterialPageRoute(builder: (_) => const LoginPage()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.green,
|
|
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(Icons.air, size: 100, color: Colors.white),
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
const Text(
|
|
'Smart Air Quality',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 26,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
const Text(
|
|
'Monitoring Kualitas Udara',
|
|
style: TextStyle(color: Colors.white70, fontSize: 14),
|
|
),
|
|
|
|
const SizedBox(height: 50),
|
|
|
|
const CircularProgressIndicator(color: Colors.white),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|