144 lines
4.6 KiB
Dart
144 lines
4.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mobile_monitoring/core/constants/constants.dart';
|
|
|
|
class SplashScreen extends StatefulWidget {
|
|
const SplashScreen({
|
|
super.key,
|
|
this.duration = const Duration(seconds: 5),
|
|
this.nextRouteName,
|
|
this.nextPage,
|
|
this.brandTitle = AppStrings.appName,
|
|
this.brandSubtitle = AppStrings.appTagline,
|
|
this.backgroundGradient,
|
|
this.showProgress = false,
|
|
});
|
|
|
|
final Duration duration;
|
|
final String? nextRouteName;
|
|
final Widget? nextPage;
|
|
final String brandTitle;
|
|
final String brandSubtitle;
|
|
final Gradient? backgroundGradient;
|
|
final bool showProgress;
|
|
|
|
@override
|
|
State<SplashScreen> createState() => _SplashScreenState();
|
|
}
|
|
|
|
class _SplashScreenState extends State<SplashScreen> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_goNext();
|
|
}
|
|
|
|
Future<void> _goNext() async {
|
|
await Future<void>.delayed(widget.duration);
|
|
if (!mounted) return;
|
|
|
|
if (widget.nextPage != null) {
|
|
Navigator.of(
|
|
context,
|
|
).pushReplacement(MaterialPageRoute(builder: (_) => widget.nextPage!));
|
|
} else if (widget.nextRouteName != null) {
|
|
Navigator.of(context).pushReplacementNamed(widget.nextRouteName!);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final background = Stack(
|
|
fit: StackFit.expand,
|
|
children: [
|
|
Image.asset('assets/images/bg-splashscreen.png', fit: BoxFit.cover),
|
|
Container(color: Colors.black.withValues(alpha: 0.35)),
|
|
],
|
|
);
|
|
|
|
return Scaffold(
|
|
body: Stack(
|
|
fit: StackFit.expand,
|
|
children: [
|
|
background,
|
|
SafeArea(
|
|
child: Column(
|
|
children: [
|
|
const Spacer(),
|
|
Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Stack(
|
|
children: [
|
|
Text(
|
|
AppStrings.appName,
|
|
textAlign: TextAlign.center,
|
|
style: theme.textTheme.displayMedium?.copyWith(
|
|
foreground: Paint()
|
|
..style = PaintingStyle.stroke
|
|
..strokeWidth = 2.5
|
|
..color = Colors.black,
|
|
fontWeight: FontWeight.bold,
|
|
letterSpacing: 0.5,
|
|
),
|
|
),
|
|
Text(
|
|
AppStrings.appName,
|
|
textAlign: TextAlign.center,
|
|
style: theme.textTheme.displayMedium?.copyWith(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
letterSpacing: 0.5,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
Stack(
|
|
children: [
|
|
Text(
|
|
AppStrings.appTagline,
|
|
textAlign: TextAlign.center,
|
|
style: theme.textTheme.titleLarge?.copyWith(
|
|
foreground: Paint()
|
|
..style = PaintingStyle.stroke
|
|
..strokeWidth = 0.5
|
|
..color = Colors.black,
|
|
fontWeight: FontWeight.w400,
|
|
letterSpacing: 1.2,
|
|
),
|
|
),
|
|
Text(
|
|
AppStrings.appTagline,
|
|
textAlign: TextAlign.center,
|
|
style: theme.textTheme.titleLarge?.copyWith(
|
|
color: Colors.white.withValues(alpha: 0.95),
|
|
fontWeight: FontWeight.w400,
|
|
letterSpacing: 1.2,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
const Spacer(),
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 24.0),
|
|
child: Text(
|
|
'Inovasi Mahasiswa Polije.',
|
|
textAlign: TextAlign.center,
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
color: Colors.white.withValues(alpha: 0.7),
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|