Files
CheckTheethKids/lib/home_screen.dart
Carlos Correia d24cb3242a Documentação
2026-05-03 23:31:31 +01:00

191 lines
6.1 KiB
Dart

import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'login_register/login_sheet.dart';
import 'login_register/register_sheet.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
bool _paused = false;
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.sizeOf(context);
return IgnorePointer(
ignoring: _paused,
child: Scaffold(
body: SafeArea(
child: Stack(
clipBehavior: Clip.none,
children: [
Positioned.fill(
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFFFFE6F1),
Color(0xFFFFC9DF),
],
),
),
),
),
Positioned(
left: -size.width * 0.38,
bottom: -size.width * 0.38,
child: IgnorePointer(
child: SizedBox(
width: size.width * 1.05,
height: size.width * 1.05,
child: Transform.rotate(
angle: 35 * math.pi / 180,
child: Opacity(
opacity: 0.95,
child: Lottie.asset(
'lottie/Liquid waves.json',
fit: BoxFit.cover,
repeat: true,
),
),
),
),
),
),
Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'Check-Teeth Kids',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w800,
color: Color(0xFFFF55A7),
height: 1.0,
),
),
const SizedBox(height: 22),
SizedBox(
width: size.width * 0.78,
child: _PrimaryButton(
label: 'Cadastrar',
onPressed: _openRegister,
),
),
const SizedBox(height: 14),
SizedBox(
width: size.width * 0.78,
child: _PrimaryButton(
label: 'Entrar',
onPressed: _openLogin,
),
),
const SizedBox(height: 24),
RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: TextStyle(
fontSize: 14.0,
height: 1.25,
color: Colors.black.withValues(alpha: 0.55),
fontWeight: FontWeight.w600,
),
children: const [
TextSpan(
text: 'Cuidar do sorriso começa aqui.\n',
style: TextStyle(
color: Color(0xFF2F9E94),
fontWeight: FontWeight.w900,
),
),
TextSpan(
text:
'Acompanhe a saúde oral do seu filho com\ninformação segura e prevenção inteligente.',
),
],
),
),
],
),
),
),
],
),
),
),
);
}
Future<void> _openLogin() async {
setState(() => _paused = true);
try {
await showLoginSheet(context);
} finally {
if (mounted) setState(() => _paused = false);
}
}
Future<void> _openRegister() async {
setState(() => _paused = true);
try {
await showRegisterSheet(context);
} finally {
if (mounted) setState(() => _paused = false);
}
}
}
class _PrimaryButton extends StatelessWidget {
const _PrimaryButton({required this.label, required this.onPressed});
final String label;
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
final Color teal = const Color(0xFF2F9E94);
return SizedBox(
height: 44,
child: FilledButton(
style: FilledButton.styleFrom(
backgroundColor: teal,
foregroundColor: Colors.white,
shape: const StadiumBorder(),
textStyle: const TextStyle(fontWeight: FontWeight.w800, fontSize: 15),
).copyWith(
animationDuration: const Duration(milliseconds: 180),
splashFactory: InkSparkle.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>(
(states) {
if (states.contains(WidgetState.pressed)) {
return Colors.white.withValues(alpha: 0.14);
}
if (states.contains(WidgetState.hovered) || states.contains(WidgetState.focused)) {
return Colors.white.withValues(alpha: 0.08);
}
return null;
},
),
),
onPressed: onPressed,
child: Text(label),
),
);
}
}