focar na tela de equipa

This commit is contained in:
2026-01-07 10:40:48 +00:00
parent 44937ca6d3
commit b7ca72ed19
12 changed files with 454 additions and 285 deletions

View File

@@ -0,0 +1,14 @@
class Team {
final String id;
final String name;
Team({required this.id, required this.name});
// Converte de Firebase para o Flutter
factory Team.fromFirestore(Map<String, dynamic> data, String id) {
return Team(
id: id,
name: data['name'] ?? '',
);
}
}

View File

@@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:playmaker/controllers/register_controller.dart';
import '../Controllers/register_controller.dart'; import '../Controllers/register_controller.dart';
import '../widgets/register_widgets.dart'; // Import dos novos widgets import '../widgets/register_widgets.dart';
import 'home.dart'; import 'home.dart';
class RegisterPage extends StatefulWidget { class RegisterPage extends StatefulWidget {
@@ -23,50 +22,54 @@ class _RegisterPageState extends State<RegisterPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(backgroundColor: Colors.white, elevation: 0, foregroundColor: Colors.black),
backgroundColor: Colors.white, backgroundColor: Colors.white,
// AppBar para poder voltar atrás
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
foregroundColor: Colors.black,
),
body: SafeArea( body: SafeArea(
child: ListenableBuilder( child: ListenableBuilder(
listenable: controller, listenable: controller,
builder: (context, child) { builder: (context, child) {
return Center( return LayoutBuilder(
child: SingleChildScrollView( // ... dentro do LayoutBuilder
padding: const EdgeInsets.all(32), builder: (context, constraints) {
child: Column( final screenWidth = constraints.maxWidth;
children: [
const RegisterHeader(), // Widget do Header return Center(
const SizedBox(height: 40), child: SingleChildScrollView(
child: Container(
RegisterFormFields(controller: controller), // Widget dos Campos
width: screenWidth * 0.6,
const SizedBox(height: 32), constraints: const BoxConstraints(minWidth: 320),
padding: const EdgeInsets.all(32),
// Botão de Finalizar child: Column(
SizedBox( mainAxisAlignment: MainAxisAlignment.center,
width: double.infinity, children: [
height: 60, const RegisterHeader(),
child: ElevatedButton( const SizedBox(height: 40),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFE74C3C), RegisterFormFields(controller: controller),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), const SizedBox(height: 32),
),
onPressed: controller.isLoading ? null : () async { RegisterButton(
final success = await controller.signUp(); controller: controller,
if (success && mounted) { onRegisterSuccess: () {
Navigator.pushReplacement( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute(builder: (context) => const HomeScreen()), MaterialPageRoute(builder: (context) => const HomeScreen()),
); (route) => false,
} );
}, },
child: controller.isLoading ),
? const CircularProgressIndicator(color: Colors.white) ],
: const Text("Criar Conta", style: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold)), ),
), ),
), ),
], );
), },
),
); );
}, },
), ),

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:playmaker/classe/home.config.dart'; import 'package:playmaker/classe/home.config.dart';
import 'package:playmaker/grafico%20de%20pizza/grafico.dart'; import 'package:playmaker/grafico%20de%20pizza/grafico.dart';
import 'package:playmaker/pages/teams_page.dart';
class HomeScreen extends StatefulWidget { class HomeScreen extends StatefulWidget {
const HomeScreen({super.key}); const HomeScreen({super.key});
@@ -11,35 +12,34 @@ class HomeScreen extends StatefulWidget {
class _HomeScreenState extends State<HomeScreen> { class _HomeScreenState extends State<HomeScreen> {
int _selectedIndex = 0; int _selectedIndex = 0;
// Lista de Widgets para cada aba
// O IndexedStack vai alternar entre estes 4 widgets
late final List<Widget> _pages;
@override
void initState() {
super.initState();
_pages = [
_buildHomeContent(), // Index 0
const Center(child: Text('Tela de Jogo')), // Index 1
const TeamsPage(), // Index 2 (TUA TELA DE EQUIPAS)
const Center(child: Text('Tela de Status')), // Index 3
];
}
void _onItemSelected(int index) { void _onItemSelected(int index) {
setState(() { setState(() {
_selectedIndex = index; _selectedIndex = index;
}); });
// Navegação entre telas
switch (index) {
case 0:
// Já está na Home
break;
case 1:
print('Navegar para tela de Jogo');
// Navigator.push(context, MaterialPageRoute(builder: (_) => GameScreen()));
break;
case 2:
print('Navegar para tela de Equipas');
// Navigator.push(context, MaterialPageRoute(builder: (_) => TeamsScreen()));
break;
case 3:
print('Navegar para tela de Status');
// Navigator.push(context, MaterialPageRoute(builder: (_) => StatusScreen()));
break;
}
} }
//home
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar( appBar: AppBar(
title: const Text('PlayMaker'), title: const Text('PlayMaker'),
backgroundColor: HomeConfig.primaryColor, backgroundColor: HomeConfig.primaryColor,
@@ -49,91 +49,13 @@ class _HomeScreenState extends State<HomeScreen> {
onPressed: () {}, onPressed: () {},
), ),
), ),
body: SingleChildScrollView(
child: Padding( // O IndexedStack mantém todas as páginas "vivas" mas só mostra uma
padding: const EdgeInsets.all(20.0), body: IndexedStack(
child: Column( index: _selectedIndex,
mainAxisAlignment: MainAxisAlignment.center, children: _pages,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Primeira linha com 2 cards
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Card 1 - Estatísticas de Basquete
_buildStatCard(
title: 'Mais Pontos',
playerName: 'Michael Jordan',
statValue: '34.5',
statLabel: 'PPG',
color: Colors.blue[800]!,
icon: Icons.sports_basketball,
isHighlighted: true,
),
SizedBox(width: 20),
// Card 2 - Estatísticas de Basquete (corrigido)
_buildStatCard(
title: 'Mais Assistências',
playerName: 'Magic Johnson',
statValue: '12.8',
statLabel: 'APG',
color: Colors.green[800]!,
icon: Icons.sports_basketball, // Corrigido para basquete
isHighlighted: false,
),
],
),
SizedBox(height: 20),
// Segunda linha com 2 cards
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Card 3 - Estatísticas de Basquete (corrigido)
_buildStatCard(
title: 'Mais Rebotes',
playerName: 'Dennis Rodman',
statValue: '15.3',
statLabel: 'RPG',
color: Colors.purple[800]!,
icon: Icons.sports_basketball, // Corrigido para basquete
isHighlighted: false,
),
SizedBox(width: 20),
// Card 4 - Gráfico
PieChartCard(
title: 'DESEMPENHO',
subtitle: 'Vitórias vs Derrotas',
backgroundColor: Colors.red[800]!,
onTap: () {
print('Gráfico clicado!');
},
),
],
),
SizedBox(height: 40),
Align(
alignment: Alignment.centerLeft,
child: Text(
'Histórico de Jogos',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.grey[800],
),
),
),
],
),
),
), ),
// ⬇️⬇️⬇️ NAVIGATION BAR AQUI ⬇️⬇️⬇️
bottomNavigationBar: NavigationBar( bottomNavigationBar: NavigationBar(
selectedIndex: _selectedIndex, selectedIndex: _selectedIndex,
onDestinationSelected: _onItemSelected, onDestinationSelected: _onItemSelected,
@@ -167,7 +89,76 @@ class _HomeScreenState extends State<HomeScreen> {
); );
} }
// Método para criar cards de estatísticas // --- WIDGETS DE CONTEÚDO ---
Widget _buildHomeContent() {
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildStatCard(
title: 'Mais Pontos',
playerName: 'Michael Jordan',
statValue: '34.5',
statLabel: 'PPG',
color: Colors.blue[800]!,
icon: Icons.sports_basketball,
isHighlighted: true,
),
const SizedBox(width: 20),
_buildStatCard(
title: 'Mais Assistências',
playerName: 'Magic Johnson',
statValue: '12.8',
statLabel: 'APG',
color: Colors.green[800]!,
icon: Icons.sports_basketball,
isHighlighted: false,
),
],
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildStatCard(
title: 'Mais Rebotes',
playerName: 'Dennis Rodman',
statValue: '15.3',
statLabel: 'RPG',
color: Colors.purple[800]!,
icon: Icons.sports_basketball,
isHighlighted: false,
),
const SizedBox(width: 20),
PieChartCard(
title: 'DESEMPENHO',
subtitle: 'Vitórias vs Derrotas',
backgroundColor: Colors.red[800]!,
onTap: () {},
),
],
),
const SizedBox(height: 40),
Text(
'Histórico de Jogos',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.grey[800],
),
),
],
),
),
);
}
Widget _buildStatCard({ Widget _buildStatCard({
required String title, required String title,
required String playerName, required String playerName,
@@ -177,7 +168,7 @@ class _HomeScreenState extends State<HomeScreen> {
required IconData icon, required IconData icon,
bool isHighlighted = false, bool isHighlighted = false,
}) { }) {
return Container( return SizedBox(
width: HomeConfig.cardwidthPadding, width: HomeConfig.cardwidthPadding,
height: HomeConfig.cardheightPadding, height: HomeConfig.cardheightPadding,
child: Card( child: Card(
@@ -185,7 +176,7 @@ class _HomeScreenState extends State<HomeScreen> {
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
side: isHighlighted side: isHighlighted
? BorderSide(color: Colors.amber, width: 2) ? const BorderSide(color: Colors.amber, width: 2)
: BorderSide.none, : BorderSide.none,
), ),
child: Container( child: Container(
@@ -194,10 +185,7 @@ class _HomeScreenState extends State<HomeScreen> {
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.topCenter, begin: Alignment.topCenter,
end: Alignment.bottomCenter, end: Alignment.bottomCenter,
colors: [ colors: [color.withOpacity(0.9), color.withOpacity(0.7)],
color.withOpacity(0.9),
color.withOpacity(0.7),
],
), ),
), ),
child: Padding( child: Padding(
@@ -205,7 +193,6 @@ class _HomeScreenState extends State<HomeScreen> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Cabeçalho com título e ícone
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@@ -213,111 +200,27 @@ class _HomeScreenState extends State<HomeScreen> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(title.toUpperCase(), style: const TextStyle(fontSize: 12, fontWeight: FontWeight.bold, color: Colors.white70)),
title.toUpperCase(), Text(playerName, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white)),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.white.withOpacity(0.9),
letterSpacing: 1.5,
),
),
SizedBox(height: 5),
Text(
playerName,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
], ],
), ),
), ),
if (isHighlighted) if (isHighlighted) const Icon(Icons.star, color: Colors.amber, size: 20),
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.amber,
shape: BoxShape.circle,
),
child: Icon(
Icons.star,
size: 20,
color: Colors.white,
),
),
], ],
), ),
const Spacer(),
SizedBox(height: 10),
// Ícone do esporte
Container(
width: 60,
height: 60,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
shape: BoxShape.circle,
),
child: Icon(
icon,
size: 30,
color: Colors.white,
),
),
Spacer(),
// Estatística central
Center( Center(
child: Column( child: Text(statValue, style: const TextStyle(fontSize: 38, fontWeight: FontWeight.bold, color: Colors.white)),
children: [
Text(
statValue,
style: TextStyle(
fontSize: 42,
fontWeight: FontWeight.bold,
color: Colors.white,
height: 1,
),
),
SizedBox(height: 5),
Text(
statLabel.toUpperCase(),
style: TextStyle(
fontSize: 14,
color: Colors.white.withOpacity(0.8),
letterSpacing: 2,
),
),
],
),
), ),
Center(
Spacer(), child: Text(statLabel, style: const TextStyle(fontSize: 12, color: Colors.white70)),
),
// Rodapé com botão const Spacer(),
Container( Container(
width: double.infinity, width: double.infinity,
padding: EdgeInsets.symmetric(vertical: 12), padding: const EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration( decoration: BoxDecoration(color: Colors.white24, borderRadius: BorderRadius.circular(10)),
color: Colors.white.withOpacity(0.2), child: const Center(child: Text('VER DETALHES', style: TextStyle(color: Colors.white, fontSize: 12))),
borderRadius: BorderRadius.circular(15),
),
child: Center(
child: Text(
'VER DETALHES',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 14,
letterSpacing: 1,
),
),
),
), ),
], ],
), ),
@@ -326,5 +229,4 @@ class _HomeScreenState extends State<HomeScreen> {
), ),
); );
} }
} }

View File

@@ -1,19 +1,19 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:playmaker/pages/home.dart'; import 'package:playmaker/pages/home.dart';
import '../widgets/login_widgets.dart'; import '../widgets/login_widgets.dart';
import '../../Controllers/login_controller.dart'; import '../../Controllers/login_controller.dart';
class LoginPage extends StatefulWidget { class LoginPage extends StatefulWidget {
const LoginPage({super.key}); const LoginPage({super.key});
@override @override
State<LoginPage> createState() => _LoginPageState(); State<LoginPage> createState() => _LoginPageState();
} }
class _LoginPageState extends State<LoginPage> { class _LoginPageState extends State<LoginPage> {
final LoginController controller = LoginController(); final LoginController controller = LoginController();
@override @override
void dispose() { void dispose() {
controller.dispose(); controller.dispose();
super.dispose(); super.dispose();
@@ -34,8 +34,10 @@
return Center( return Center(
child: SingleChildScrollView( child: SingleChildScrollView(
child: Container( child: Container(
width: screenWidth > 800 ? 600.0 : // AGORA: Ocupa 60% da largura da tela, igual ao Register
screenWidth > 600 ? 500.0 : 400.0, width: screenWidth * 0.6,
// Garante que em telemóveis não fique demasiado apertado
constraints: const BoxConstraints(minWidth: 340),
padding: const EdgeInsets.all(32), padding: const EdgeInsets.all(32),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,

94
lib/pages/teams_page.dart Normal file
View File

@@ -0,0 +1,94 @@
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import '../models/team_model.dart'; // Importa o teu modelo
class TeamsPage extends StatelessWidget {
const TeamsPage({super.key});
// Função para abrir o Pop-up
void _showCreateTeamDialog(BuildContext context) {
final TextEditingController _nameController = TextEditingController();
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Nova Equipa'),
content: TextField(
controller: _nameController,
decoration: const InputDecoration(hintText: 'Nome da Equipa'),
autofocus: true,
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancelar'),
),
ElevatedButton(
onPressed: () async {
if (_nameController.text.isNotEmpty) {
// Guarda no Firebase
await FirebaseFirestore.instance.collection('teams').add({
'name': _nameController.text,
'createdAt': FieldValue.serverTimestamp(),
});
Navigator.pop(context);
}
},
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFE74C3C)),
child: const Text('Criar', style: TextStyle(color: Colors.white)),
),
],
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
// Removi a AppBar porque a HomeScreen já tem uma, evita barra dupla
body: StreamBuilder<QuerySnapshot>(
// Escuta o Firebase em tempo real
stream: FirebaseFirestore.instance.collection('teams').orderBy('createdAt', descending: true).snapshots(),
builder: (context, snapshot) {
if (snapshot.hasError) return const Center(child: Text('Erro ao carregar'));
if (snapshot.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator());
final docs = snapshot.data!.docs;
if (docs.isEmpty) {
return const Center(child: Text('Nenhuma equipa criada.'));
}
return ListView.builder(
padding: const EdgeInsets.all(16),
itemCount: docs.length,
itemBuilder: (context, index) {
final team = Team.fromFirestore(docs[index].data() as Map<String, dynamic>, docs[index].id);
return Card(
elevation: 2,
margin: const EdgeInsets.only(bottom: 12),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: ListTile(
leading: const CircleAvatar(
backgroundColor: Color(0xFFE74C3C),
child: Icon(Icons.groups, color: Colors.white),
),
title: Text(team.name, style: const TextStyle(fontWeight: FontWeight.bold)),
trailing: const Icon(Icons.chevron_right),
onTap: () {
// Navegar para detalhes da equipa no futuro
},
),
);
},
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: () => _showCreateTeamDialog(context),
backgroundColor: const Color(0xFFE74C3C),
child: const Icon(Icons.add, color: Colors.white),
),
);
}
}

View File

@@ -12,7 +12,6 @@ class CustomNavBar extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// Usar NavigationBar (Material 3) ao invés de BottomNavigationBar
return NavigationBar( return NavigationBar(
selectedIndex: selectedIndex, selectedIndex: selectedIndex,
onDestinationSelected: onItemSelected, onDestinationSelected: onItemSelected,
@@ -21,25 +20,30 @@ class CustomNavBar extends StatelessWidget {
elevation: 1, elevation: 1,
height: 70, height: 70,
destinations: const [ destinations: const [
NavigationDestination( NavigationDestination(
icon: Icon(Icons.home_outlined), icon: Icon(Icons.home_outlined),
selectedIcon: Icon(Icons.home_filled), selectedIcon: Icon(Icons.home_filled),
label: 'Home', label: 'Home',
), ),
NavigationDestination( NavigationDestination(
icon: Icon(Icons.sports_soccer_outlined), icon: Icon(Icons.sports_soccer_outlined),
selectedIcon: Icon(Icons.sports_soccer), selectedIcon: Icon(Icons.sports_soccer),
label: 'Jogo', label: 'Jogo',
), ),
NavigationDestination( NavigationDestination(
icon: Icon(Icons.people_outline), icon: Icon(Icons.people_outline),
selectedIcon: Icon(Icons.people), selectedIcon: Icon(Icons.people),
label: 'Equipas', label: 'Equipas',
), ),
NavigationDestination( NavigationDestination(
icon: Icon(Icons.insights_outlined), icon: Icon(Icons.insights_outlined),
selectedIcon: Icon(Icons.insights), selectedIcon: Icon(Icons.insights),
label: 'Status', label: 'Status',
), ),
], ],
); );

View File

@@ -1,48 +1,110 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:playmaker/controllers/register_controller.dart'; import '../Controllers/register_controller.dart';
class RegisterFormFields extends StatelessWidget { class RegisterHeader extends StatelessWidget {
const RegisterHeader({super.key});
@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
// Mesma lógica de tamanhos do Login
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),
Text(
'Nova Conta',
style: TextStyle(
fontSize: titleFontSize,
fontWeight: FontWeight.bold,
color: Colors.grey[900],
),
),
const SizedBox(height: 5),
Text(
'Cria o teu perfil no BasketTrack',
style: TextStyle(
fontSize: subtitleFontSize,
color: Colors.grey[600],
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
],
);
}
}
class RegisterFormFields extends StatefulWidget {
final RegisterController controller; final RegisterController controller;
const RegisterFormFields({super.key, required this.controller}); const RegisterFormFields({super.key, required this.controller});
@override
State<RegisterFormFields> createState() => _RegisterFormFieldsState();
}
class _RegisterFormFieldsState extends State<RegisterFormFields> {
bool _obscurePassword = true;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final verticalPadding = MediaQuery.of(context).size.width > 600 ? 22.0 : 16.0; final screenWidth = MediaQuery.of(context).size.width;
// Padding vertical idêntico ao login
final verticalPadding = screenWidth > 600 ? 22.0 : 16.0;
return Column( return Column(
children: [ children: [
// Campo Email
TextField( TextField(
controller: controller.emailController, controller: widget.controller.emailController,
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'E-mail', labelText: 'E-mail',
prefixIcon: const Icon(Icons.email_outlined), prefixIcon: const Icon(Icons.email_outlined),
errorText: controller.emailError, // O erro agora vem diretamente do controller
errorText: widget.controller.emailError,
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)), border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
contentPadding: EdgeInsets.symmetric(vertical: verticalPadding, horizontal: 16),
), ),
keyboardType: TextInputType.emailAddress,
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
// Campo Password // Campo Password
TextField( TextField(
controller: controller.passwordController, controller: widget.controller.passwordController,
obscureText: true, obscureText: _obscurePassword,
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Palavra-passe', labelText: 'Palavra-passe',
prefixIcon: const Icon(Icons.lock_outlined), prefixIcon: const Icon(Icons.lock_outlined),
errorText: controller.passwordError, errorText: widget.controller.passwordError,
suffixIcon: IconButton(
icon: Icon(_obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined),
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)), border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
contentPadding: EdgeInsets.symmetric(vertical: verticalPadding, horizontal: 16),
), ),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
// NOVO: Campo Confirmar Password
// Campo Confirmar Password
TextField( TextField(
controller: controller.confirmPasswordController, controller: widget.controller.confirmPasswordController,
obscureText: true, obscureText: _obscurePassword,
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Confirmar Palavra-passe', labelText: 'Confirmar Palavra-passe',
prefixIcon: const Icon(Icons.lock_clock_outlined), prefixIcon: const Icon(Icons.lock_clock_outlined),
errorText: controller.confirmPasswordError, // Erro específico errorText: widget.controller.confirmPasswordError,
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)), border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
contentPadding: EdgeInsets.symmetric(vertical: verticalPadding, horizontal: 16), contentPadding: EdgeInsets.symmetric(vertical: verticalPadding, horizontal: 16),
), ),
@@ -50,4 +112,61 @@ class RegisterFormFields extends StatelessWidget {
], ],
); );
} }
}
class RegisterButton extends StatelessWidget {
final RegisterController controller;
final VoidCallback onRegisterSuccess;
const RegisterButton({
super.key,
required this.controller,
required this.onRegisterSuccess,
});
@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
// Mesmos tamanhos exatos do LoginButton
final buttonHeight = screenWidth > 600 ? 70.0 : 58.0;
final fontSize = screenWidth > 600 ? 22.0 : 18.0;
return SizedBox(
width: double.infinity,
height: buttonHeight,
child: ElevatedButton(
onPressed: controller.isLoading ? null : () async {
final success = await controller.signUp();
if (success) {
onRegisterSuccess();
}
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFE74C3C),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
elevation: 3,
),
child: controller.isLoading
? const SizedBox(
width: 28,
height: 28,
child: CircularProgressIndicator(
strokeWidth: 3,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
)
: Text(
'Criar Conta',
style: TextStyle(
fontSize: fontSize,
fontWeight: FontWeight.w700,
),
),
),
);
}
} }

View File

@@ -5,10 +5,12 @@
import FlutterMacOS import FlutterMacOS
import Foundation import Foundation
import cloud_firestore
import firebase_auth import firebase_auth
import firebase_core import firebase_core
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
} }

View File

@@ -5,10 +5,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: _flutterfire_internals name: _flutterfire_internals
sha256: "8a1f5f3020ef2a74fb93f7ab3ef127a8feea33a7a2276279113660784ee7516a" sha256: e4a1b612fd2955908e26116075b3a4baf10c353418ca645b4deae231c82bf144
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.64" version: "1.3.65"
async: async:
dependency: transitive dependency: transitive
description: description:
@@ -41,6 +41,30 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.2" version: "1.1.2"
cloud_firestore:
dependency: "direct main"
description:
name: cloud_firestore
sha256: "88abd6dc7786c23c8b5e434901bb0d79176414e52e9ab50a8e52552ff6148d7a"
url: "https://pub.dev"
source: hosted
version: "6.1.1"
cloud_firestore_platform_interface:
dependency: transitive
description:
name: cloud_firestore_platform_interface
sha256: "573d4b4ebc56ba573dc9bac88b65bdb991cc5b66a885a62c7ab8dd1e2eaa0944"
url: "https://pub.dev"
source: hosted
version: "7.0.5"
cloud_firestore_web:
dependency: transitive
description:
name: cloud_firestore_web
sha256: c1ef53308a09d475503f75b658b65fae32af24047d03bba0713098f882ed187f
url: "https://pub.dev"
source: hosted
version: "5.1.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
@@ -93,10 +117,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: firebase_core name: firebase_core
sha256: "1f2dfd9f535d81f8b06d7a50ecda6eac1e6922191ed42e09ca2c84bd2288927c" sha256: "29cfa93c771d8105484acac340b5ea0835be371672c91405a300303986f4eba9"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.2.1" version: "4.3.0"
firebase_core_platform_interface: firebase_core_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -109,10 +133,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: firebase_core_web name: firebase_core_web
sha256: ff18fabb0ad0ed3595d2f2c85007ecc794aadecdff5b3bb1460b7ee47cded398 sha256: a631bbfbfa26963d68046aed949df80b228964020e9155b086eff94f462bbf1f
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.0" version: "3.3.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter

View File

@@ -37,6 +37,7 @@ dependencies:
provider: ^6.1.5+1 provider: ^6.1.5+1
firebase_core: ^4.2.1 firebase_core: ^4.2.1
firebase_auth: ^6.1.2 firebase_auth: ^6.1.2
cloud_firestore: ^6.1.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

View File

@@ -6,10 +6,13 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <cloud_firestore/cloud_firestore_plugin_c_api.h>
#include <firebase_auth/firebase_auth_plugin_c_api.h> #include <firebase_auth/firebase_auth_plugin_c_api.h>
#include <firebase_core/firebase_core_plugin_c_api.h> #include <firebase_core/firebase_core_plugin_c_api.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
CloudFirestorePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("CloudFirestorePluginCApi"));
FirebaseAuthPluginCApiRegisterWithRegistrar( FirebaseAuthPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi"));
FirebaseCorePluginCApiRegisterWithRegistrar( FirebaseCorePluginCApiRegisterWithRegistrar(

View File

@@ -3,6 +3,7 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
cloud_firestore
firebase_auth firebase_auth
firebase_core firebase_core
) )