login-page/lib/screens/splash_screen.dart
2025-05-17 21:43:57 +03:00

111 lines
4.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; // For hiding system UI
import 'login_screen.dart'; // Make sure this import path is correct
class SplashScreen extends StatefulWidget {
const SplashScreen({super.key});
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
super.initState();
// Hide system UI (status bar and bottom navigation bar)
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
// Navigate to Login Screen after 3 seconds
Future.delayed(const Duration(seconds: 3), () {
Navigator.pushReplacement(
// ignore: use_build_context_synchronously
context,
MaterialPageRoute(builder: (context) => const LoginScreen()),
);
});
}
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.dark.copyWith(
statusBarColor: Colors.white, // Transparent or match background
systemNavigationBarColor: Colors.white,
),
child: Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
child: Column(
children: [
// Main content in the middle (with Expanded to take available space)
Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Animated Logo
TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 1.0, end: 1.2),
duration: const Duration(milliseconds: 700),
curve: Curves.easeInOut,
builder: (context, scale, child) {
return Transform.scale(scale: scale, child: child);
},
child: Image.asset(
'assets/logo.png',
width: 200,
height: 50,
fit: BoxFit.contain,
),
),
const SizedBox(height: 40),
// Loading Text
const Text(
"Just a moment...",
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 16),
// Animated GIF
TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0.8, end: 1.0),
duration: const Duration(milliseconds: 600),
curve: Curves.easeInOut,
builder: (context, scale, child) =>
Transform.scale(scale: scale, child: child),
child: Image.asset(
'assets/wi-fi.gif',
width: 100,
height: 100,
fit: BoxFit.contain,
),
),
const SizedBox(height: 16),
// Info Text
const Text(
"Hang on as we redirect you to the WiFi Portal...",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: Colors.grey),
),
],
),
),
),
),
// Footer at the bottom
Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: Text(
"© Lence Amazons Ltd All rights reserved.",
style: TextStyle(fontSize: 12, color: Colors.grey),
),
),
],
),
),
),
);
}
}