login e register
This commit is contained in:
@@ -1,41 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../controllers/register_controller.dart'; // Garante que o caminho está certo
|
||||
import '../controllers/register_controller.dart';
|
||||
import '../utils/size_extension.dart'; // 👇 O NOSSO SUPERPODER!
|
||||
|
||||
class RegisterHeader extends StatelessWidget {
|
||||
const RegisterHeader({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
final logoSize = screenWidth > 600 ? 150.0 : 100.0;
|
||||
final titleFontSize = screenWidth > 600 ? 48.0 : 36.0;
|
||||
final subtitleFontSize = screenWidth > 600 ? 22.0 : 18.0;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.person_add_outlined,
|
||||
size: logoSize,
|
||||
color: const Color(0xFFE74C3C)
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Icon(Icons.person_add_outlined, size: 100 * context.sf, color: const Color(0xFFE74C3C)),
|
||||
SizedBox(height: 10 * context.sf),
|
||||
Text(
|
||||
'Nova Conta',
|
||||
style: TextStyle(
|
||||
fontSize: titleFontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey[900],
|
||||
),
|
||||
style: TextStyle(fontSize: 36 * context.sf, fontWeight: FontWeight.bold, color: Colors.grey[900]),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
SizedBox(height: 5 * context.sf),
|
||||
Text(
|
||||
'Cria o teu perfil no BasketTrack',
|
||||
style: TextStyle(
|
||||
fontSize: subtitleFontSize,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
style: TextStyle(fontSize: 16 * context.sf, color: Colors.grey[600], fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
@@ -45,7 +28,6 @@ class RegisterHeader extends StatelessWidget {
|
||||
|
||||
class RegisterFormFields extends StatefulWidget {
|
||||
final RegisterController controller;
|
||||
|
||||
const RegisterFormFields({super.key, required this.controller});
|
||||
|
||||
@override
|
||||
@@ -57,69 +39,68 @@ class _RegisterFormFieldsState extends State<RegisterFormFields> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final verticalPadding = screenWidth > 600 ? 22.0 : 16.0;
|
||||
|
||||
// IMPORTANTE: Envolvemos tudo num Form usando a chave do controller
|
||||
return Form(
|
||||
key: widget.controller.formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
// Campo Nome (Opcional, mas útil)
|
||||
TextFormField(
|
||||
controller: widget.controller.nameController,
|
||||
style: TextStyle(fontSize: 15 * context.sf),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Nome Completo',
|
||||
prefixIcon: const Icon(Icons.person_outline),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: verticalPadding, horizontal: 16),
|
||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||
prefixIcon: Icon(Icons.person_outline, size: 22 * context.sf),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(height: 20 * context.sf),
|
||||
|
||||
// Campo Email
|
||||
TextFormField(
|
||||
controller: widget.controller.emailController,
|
||||
// Validação automática ligada ao controller
|
||||
validator: widget.controller.validateEmail,
|
||||
style: TextStyle(fontSize: 15 * context.sf),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'E-mail',
|
||||
prefixIcon: const Icon(Icons.email_outlined),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: verticalPadding, horizontal: 16),
|
||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||
prefixIcon: Icon(Icons.email_outlined, size: 22 * context.sf),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
||||
),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(height: 20 * context.sf),
|
||||
|
||||
// Campo Password
|
||||
TextFormField(
|
||||
controller: widget.controller.passwordController,
|
||||
obscureText: _obscurePassword,
|
||||
validator: widget.controller.validatePassword,
|
||||
style: TextStyle(fontSize: 15 * context.sf),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Palavra-passe',
|
||||
prefixIcon: const Icon(Icons.lock_outlined),
|
||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||
prefixIcon: Icon(Icons.lock_outlined, size: 22 * context.sf),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined),
|
||||
icon: Icon(_obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined, size: 22 * context.sf),
|
||||
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
|
||||
),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: verticalPadding, horizontal: 16),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(height: 20 * context.sf),
|
||||
|
||||
// Campo Confirmar Password
|
||||
TextFormField(
|
||||
controller: widget.controller.confirmPasswordController,
|
||||
obscureText: _obscurePassword,
|
||||
validator: widget.controller.validateConfirmPassword,
|
||||
style: TextStyle(fontSize: 15 * context.sf),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Confirmar Palavra-passe',
|
||||
prefixIcon: const Icon(Icons.lock_clock_outlined),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: verticalPadding, horizontal: 16),
|
||||
labelStyle: TextStyle(fontSize: 15 * context.sf),
|
||||
prefixIcon: Icon(Icons.lock_clock_outlined, size: 22 * context.sf),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12 * context.sf)),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 18 * context.sf, horizontal: 16 * context.sf),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -130,49 +111,27 @@ class _RegisterFormFieldsState extends State<RegisterFormFields> {
|
||||
|
||||
class RegisterButton extends StatelessWidget {
|
||||
final RegisterController controller;
|
||||
|
||||
const RegisterButton({
|
||||
super.key,
|
||||
required this.controller,
|
||||
});
|
||||
const RegisterButton({super.key, required this.controller});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
final buttonHeight = screenWidth > 600 ? 70.0 : 58.0;
|
||||
final fontSize = screenWidth > 600 ? 22.0 : 18.0;
|
||||
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: buttonHeight,
|
||||
height: 58 * context.sf,
|
||||
child: ElevatedButton(
|
||||
// Passamos o context para o controller lidar com as SnackBars e Navegação
|
||||
onPressed: controller.isLoading ? null : () => controller.signUp(context),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFE74C3C),
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14 * context.sf)),
|
||||
elevation: 3,
|
||||
),
|
||||
child: controller.isLoading
|
||||
? const SizedBox(
|
||||
width: 28,
|
||||
height: 28,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 3,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
),
|
||||
? SizedBox(
|
||||
width: 28 * context.sf, height: 28 * context.sf,
|
||||
child: const CircularProgressIndicator(strokeWidth: 3, valueColor: AlwaysStoppedAnimation<Color>(Colors.white)),
|
||||
)
|
||||
: Text(
|
||||
'Criar Conta',
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
: Text('Criar Conta', style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user