Files
yogibook_aury_app/lib/screens/splash_page.dart
T

178 lines
5.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'dart:async';
import 'package:flutter/material.dart';
import 'login_page.dart';
class SplashPage extends StatefulWidget {
const SplashPage({super.key});
@override
State<SplashPage> createState() => _SplashPageState();
}
class _SplashPageState extends State<SplashPage> {
// rosso bordeaux ripreso dal cuore del logo YogaSoul
static const Color kRed = Color(0xFFB01E28);
Timer? _timer;
int _seconds = 5; // countdown iniziale
@override
void initState() {
super.initState();
// countdown 5 → 0, poi vai al login
_timer = Timer.periodic(const Duration(seconds: 1), (t) {
if (!mounted) return;
setState(() => _seconds--);
if (_seconds <= 0) {
t.cancel();
_goToLogin();
}
});
}
@override
void dispose() {
_timer?.cancel();
super.dispose();
}
void _goToLogin() {
if (!mounted) return;
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => const LoginPage()),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
// tocca lo schermo per saltare subito al login
body: GestureDetector(
onTap: _goToLogin,
child: Stack(
fit: StackFit.expand,
children: [
// ---- Foto di sfondo full-screen
Image.asset('assets/images/splash_bg.png', fit: BoxFit.cover),
// ---- Contenuto (logo + testo) in alto
SafeArea(
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 10, 24, 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 8),
// Logo YogaSoul
Image.asset(
'assets/images/yogasoul_logo.png',
height: 90,
fit: BoxFit.contain,
),
const SizedBox(height: 26),
// ---- Blocco testo su velo bianco morbido per leggibilità
Container(
padding: const EdgeInsets.symmetric(
horizontal: 18,
vertical: 16,
),
decoration: BoxDecoration(
// velo bianco semitrasparente: stacca il testo dal cielo
color: Colors.white.withOpacity(0.42),
borderRadius: BorderRadius.circular(20),
),
child: Column(
children: [
// Titolo riga 1 (scuro)
const Text(
'Il tuo spazio.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
height: 1.1,
fontWeight: FontWeight.w900,
color: Color(0xFF1F1F1F),
),
),
// Titolo riga 2 (rosso bordeaux)
const Text(
'La tua energia.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
height: 1.1,
fontWeight: FontWeight.w900,
color: kRed,
),
),
const SizedBox(height: 14),
// Sottotitolo
const Text(
'Ti diamo il benvenuto in YogiBook,\n'
'lapp della scuola YogaSoul — Seregno.\n'
'Ti accompagna nelle tue lezioni e nei tuoi pacchetti.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
height: 1.4,
fontWeight: FontWeight.w600,
color: Color(0xFF2A2A2A),
),
),
],
),
),
],
),
),
),
// ---- Logo YogiBook + countdown in basso
Positioned(
left: 0,
right: 0,
bottom: 30,
child: Column(
children: [
Image.asset(
'assets/images/yogibook_logo.png',
height: 40,
fit: BoxFit.contain,
),
const SizedBox(height: 14),
// Countdown numerico dentro un cerchio
Container(
width: 40,
height: 40,
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white.withValues(alpha: 0.25),
border: Border.all(color: Colors.white, width: 1.5),
),
child: Text(
'$_seconds',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w900,
fontSize: 18,
),
),
),
],
),
),
],
),
),
);
}
}