login e register
This commit is contained in:
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/screens/team_stats_page.dart';
|
||||
import '../controllers/team_controller.dart';
|
||||
import '../models/team_model.dart';
|
||||
import 'dart:math' as math; // <-- IMPORTANTE: Adicionar para o cálculo
|
||||
import '../utils/size_extension.dart'; // 👇 IMPORTANTE: O TEU NOVO SUPERPODER
|
||||
|
||||
class TeamsPage extends StatefulWidget {
|
||||
const TeamsPage({super.key});
|
||||
@@ -25,8 +25,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// --- POPUP DE FILTROS ---
|
||||
void _showFilterDialog(BuildContext context, double sf) {
|
||||
void _showFilterDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
@@ -34,16 +33,13 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
builder: (context, setModalState) {
|
||||
return AlertDialog(
|
||||
backgroundColor: const Color(0xFF2C3E50),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * sf)),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * context.sf)),
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Filtros de pesquisa",
|
||||
style: TextStyle(color: Colors.white, fontSize: 18 * sf, fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text("Filtros de pesquisa", style: TextStyle(color: Colors.white, fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||
IconButton(
|
||||
icon: Icon(Icons.close, color: Colors.white, size: 20 * sf),
|
||||
icon: Icon(Icons.close, color: Colors.white, size: 20 * context.sf),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
)
|
||||
],
|
||||
@@ -52,31 +48,27 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Divider(color: Colors.white24),
|
||||
SizedBox(height: 16 * sf),
|
||||
SizedBox(height: 16 * context.sf),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Coluna Temporada
|
||||
Expanded(
|
||||
child: _buildPopupColumn(
|
||||
title: "TEMPORADA",
|
||||
options: ['Todas', '2023/24', '2024/25', '2025/26'],
|
||||
currentValue: _selectedSeason,
|
||||
sf: sf,
|
||||
onSelect: (val) {
|
||||
setState(() => _selectedSeason = val);
|
||||
setModalState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20 * sf),
|
||||
// Coluna Ordenar
|
||||
SizedBox(width: 20 * context.sf),
|
||||
Expanded(
|
||||
child: _buildPopupColumn(
|
||||
title: "ORDENAR POR",
|
||||
options: ['Recentes', 'Nome', 'Tamanho'],
|
||||
currentValue: _currentSort,
|
||||
sf: sf,
|
||||
onSelect: (val) {
|
||||
setState(() => _currentSort = val);
|
||||
setModalState(() {});
|
||||
@@ -90,7 +82,7 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text("CONCLUÍDO", style: TextStyle(color: const Color(0xFFE74C3C), fontWeight: FontWeight.bold, fontSize: 14 * sf)),
|
||||
child: Text("CONCLUÍDO", style: TextStyle(color: const Color(0xFFE74C3C), fontWeight: FontWeight.bold, fontSize: 14 * context.sf)),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -100,30 +92,24 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPopupColumn({
|
||||
required String title,
|
||||
required List<String> options,
|
||||
required String currentValue,
|
||||
required double sf,
|
||||
required Function(String) onSelect,
|
||||
}) {
|
||||
Widget _buildPopupColumn({required String title, required List<String> options, required String currentValue, required Function(String) onSelect}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title, style: TextStyle(color: Colors.grey, fontSize: 11 * sf, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 12 * sf),
|
||||
Text(title, style: TextStyle(color: Colors.grey, fontSize: 11 * context.sf, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 12 * context.sf),
|
||||
...options.map((opt) {
|
||||
final isSelected = currentValue == opt;
|
||||
return InkWell(
|
||||
onTap: () => onSelect(opt),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0 * sf),
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0 * context.sf),
|
||||
child: Text(
|
||||
opt,
|
||||
style: TextStyle(
|
||||
color: isSelected ? const Color(0xFFE74C3C) : Colors.white70,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
fontSize: 14 * sf,
|
||||
fontSize: 14 * context.sf,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -135,109 +121,84 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 👇 CÁLCULO DA ESCALA (sf) PARA SE ADAPTAR A QUALQUER ECRÃ 👇
|
||||
final double wScreen = MediaQuery.of(context).size.width;
|
||||
final double hScreen = MediaQuery.of(context).size.height;
|
||||
final double sf = math.min(wScreen, hScreen) / 400;
|
||||
|
||||
// 🔥 OLHA QUE LIMPEZA: Já não precisamos de calcular nada aqui!
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F7FA),
|
||||
appBar: AppBar(
|
||||
title: Text("Minhas Equipas", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20 * sf)),
|
||||
title: Text("Minhas Equipas", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20 * context.sf)),
|
||||
backgroundColor: const Color(0xFFF5F7FA),
|
||||
elevation: 0,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.filter_list, color: const Color(0xFFE74C3C), size: 24 * sf),
|
||||
onPressed: () => _showFilterDialog(context, sf),
|
||||
icon: Icon(Icons.filter_list, color: const Color(0xFFE74C3C), size: 24 * context.sf),
|
||||
onPressed: () => _showFilterDialog(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_buildSearchBar(sf),
|
||||
Expanded(child: _buildTeamsList(sf)),
|
||||
_buildSearchBar(),
|
||||
Expanded(child: _buildTeamsList()),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: const Color(0xFFE74C3C),
|
||||
child: Icon(Icons.add, color: Colors.white, size: 24 * sf),
|
||||
onPressed: () => _showCreateDialog(context, sf),
|
||||
child: Icon(Icons.add, color: Colors.white, size: 24 * context.sf),
|
||||
onPressed: () => _showCreateDialog(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSearchBar(double sf) {
|
||||
Widget _buildSearchBar() {
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(16.0 * sf),
|
||||
padding: EdgeInsets.all(16.0 * context.sf),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
onChanged: (v) => setState(() => _searchQuery = v.toLowerCase()),
|
||||
style: TextStyle(fontSize: 16 * sf),
|
||||
style: TextStyle(fontSize: 16 * context.sf),
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Pesquisar equipa...',
|
||||
hintStyle: TextStyle(fontSize: 16 * sf),
|
||||
prefixIcon: Icon(Icons.search, color: const Color(0xFFE74C3C), size: 22 * sf),
|
||||
hintStyle: TextStyle(fontSize: 16 * context.sf),
|
||||
prefixIcon: Icon(Icons.search, color: const Color(0xFFE74C3C), size: 22 * context.sf),
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(15 * sf), borderSide: BorderSide.none),
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(15 * context.sf), borderSide: BorderSide.none),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTeamsList(double sf) {
|
||||
Widget _buildTeamsList() {
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: controller.teamsStream,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
||||
return Center(child: Text("Nenhuma equipa encontrada.", style: TextStyle(fontSize: 16 * sf)));
|
||||
}
|
||||
if (snapshot.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator());
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) return Center(child: Text("Nenhuma equipa encontrada.", style: TextStyle(fontSize: 16 * context.sf)));
|
||||
|
||||
var data = List<Map<String, dynamic>>.from(snapshot.data!);
|
||||
|
||||
// --- 1. FILTROS ---
|
||||
if (_selectedSeason != 'Todas') {
|
||||
data = data.where((t) => t['season'] == _selectedSeason).toList();
|
||||
}
|
||||
if (_searchQuery.isNotEmpty) {
|
||||
data = data.where((t) => t['name'].toString().toLowerCase().contains(_searchQuery)).toList();
|
||||
}
|
||||
if (_selectedSeason != 'Todas') data = data.where((t) => t['season'] == _selectedSeason).toList();
|
||||
if (_searchQuery.isNotEmpty) data = data.where((t) => t['name'].toString().toLowerCase().contains(_searchQuery)).toList();
|
||||
|
||||
// --- 2. ORDENAÇÃO ---
|
||||
data.sort((a, b) {
|
||||
bool favA = a['is_favorite'] ?? false;
|
||||
bool favB = b['is_favorite'] ?? false;
|
||||
if (favA && !favB) return -1;
|
||||
if (!favA && favB) return 1;
|
||||
if (_currentSort == 'Nome') {
|
||||
return a['name'].toString().compareTo(b['name'].toString());
|
||||
} else {
|
||||
return (b['created_at'] ?? '').toString().compareTo((a['created_at'] ?? '').toString());
|
||||
}
|
||||
if (_currentSort == 'Nome') return a['name'].toString().compareTo(b['name'].toString());
|
||||
else return (b['created_at'] ?? '').toString().compareTo((a['created_at'] ?? '').toString());
|
||||
});
|
||||
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16 * sf),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16 * context.sf),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) {
|
||||
final team = Team.fromMap(data[index]);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => TeamStatsPage(team: team)),
|
||||
);
|
||||
},
|
||||
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context) => TeamStatsPage(team: team))),
|
||||
child: TeamCard(
|
||||
team: team,
|
||||
controller: controller,
|
||||
sf: sf, // Passar a escala para o Card
|
||||
onFavoriteTap: () => controller.toggleFavorite(team.id, team.isFavorite),
|
||||
),
|
||||
);
|
||||
@@ -247,14 +208,8 @@ class _TeamsPageState extends State<TeamsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void _showCreateDialog(BuildContext context, double sf) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => CreateTeamDialog(
|
||||
sf: sf,
|
||||
onConfirm: (name, season, imageUrl) => controller.createTeam(name, season, imageUrl),
|
||||
),
|
||||
);
|
||||
void _showCreateDialog(BuildContext context) {
|
||||
showDialog(context: context, builder: (context) => CreateTeamDialog(onConfirm: (name, season, imageUrl) => controller.createTeam(name, season, imageUrl)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,129 +218,58 @@ class TeamCard extends StatelessWidget {
|
||||
final Team team;
|
||||
final TeamController controller;
|
||||
final VoidCallback onFavoriteTap;
|
||||
final double sf; // <-- Variável de escala
|
||||
|
||||
const TeamCard({
|
||||
super.key,
|
||||
required this.team,
|
||||
required this.controller,
|
||||
required this.onFavoriteTap,
|
||||
required this.sf,
|
||||
});
|
||||
const TeamCard({super.key, required this.team, required this.controller, required this.onFavoriteTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: Colors.white,
|
||||
elevation: 3,
|
||||
margin: EdgeInsets.only(bottom: 12 * sf),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * sf)),
|
||||
color: Colors.white, elevation: 3, margin: EdgeInsets.only(bottom: 12 * context.sf),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * context.sf)),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16 * sf, vertical: 8 * sf),
|
||||
|
||||
// --- 1. IMAGEM + FAVORITO ---
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 8 * context.sf),
|
||||
leading: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 28 * sf,
|
||||
backgroundColor: Colors.grey[200],
|
||||
backgroundImage: (team.imageUrl.isNotEmpty && team.imageUrl.startsWith('http'))
|
||||
? NetworkImage(team.imageUrl)
|
||||
: null,
|
||||
child: (team.imageUrl.isEmpty || !team.imageUrl.startsWith('http'))
|
||||
? Text(
|
||||
team.imageUrl.isEmpty ? "🏀" : team.imageUrl,
|
||||
style: TextStyle(fontSize: 24 * sf),
|
||||
)
|
||||
: null,
|
||||
radius: 28 * context.sf, backgroundColor: Colors.grey[200],
|
||||
backgroundImage: (team.imageUrl.isNotEmpty && team.imageUrl.startsWith('http')) ? NetworkImage(team.imageUrl) : null,
|
||||
child: (team.imageUrl.isEmpty || !team.imageUrl.startsWith('http')) ? Text(team.imageUrl.isEmpty ? "🏀" : team.imageUrl, style: TextStyle(fontSize: 24 * context.sf)) : null,
|
||||
),
|
||||
Positioned(
|
||||
left: -15 * sf,
|
||||
top: -10 * sf,
|
||||
left: -15 * context.sf, top: -10 * context.sf,
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
team.isFavorite ? Icons.star : Icons.star_border,
|
||||
color: team.isFavorite ? Colors.amber : Colors.black.withOpacity(0.1),
|
||||
size: 28 * sf,
|
||||
shadows: [
|
||||
Shadow(
|
||||
color: Colors.black.withOpacity(team.isFavorite ? 0.3 : 0.1),
|
||||
blurRadius: 4 * sf,
|
||||
),
|
||||
],
|
||||
),
|
||||
icon: Icon(team.isFavorite ? Icons.star : Icons.star_border, color: team.isFavorite ? Colors.amber : Colors.black.withOpacity(0.1), size: 28 * context.sf, shadows: [Shadow(color: Colors.black.withOpacity(team.isFavorite ? 0.3 : 0.1), blurRadius: 4 * context.sf)]),
|
||||
onPressed: onFavoriteTap,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// --- 2. TÍTULO ---
|
||||
title: Text(
|
||||
team.name,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16 * sf),
|
||||
overflow: TextOverflow.ellipsis, // Previne overflows em nomes longos
|
||||
),
|
||||
|
||||
// --- 3. SUBTÍTULO (Contagem + Época em TEMPO REAL) ---
|
||||
title: Text(team.name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16 * context.sf), overflow: TextOverflow.ellipsis),
|
||||
subtitle: Padding(
|
||||
padding: EdgeInsets.only(top: 6.0 * sf),
|
||||
padding: EdgeInsets.only(top: 6.0 * context.sf),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.groups_outlined, size: 16 * sf, color: Colors.grey),
|
||||
SizedBox(width: 4 * sf),
|
||||
|
||||
// 👇 STREAMBUILDER EM VEZ DE FUTUREBUILDER 👇
|
||||
Icon(Icons.groups_outlined, size: 16 * context.sf, color: Colors.grey),
|
||||
SizedBox(width: 4 * context.sf),
|
||||
StreamBuilder<int>(
|
||||
stream: controller.getPlayerCountStream(team.id),
|
||||
initialData: 0,
|
||||
builder: (context, snapshot) {
|
||||
final count = snapshot.data ?? 0;
|
||||
return Text(
|
||||
"$count Jogs.",
|
||||
style: TextStyle(
|
||||
color: count > 0 ? Colors.green[700] : Colors.orange,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 13 * sf,
|
||||
),
|
||||
);
|
||||
return Text("$count Jogs.", style: TextStyle(color: count > 0 ? Colors.green[700] : Colors.orange, fontWeight: FontWeight.bold, fontSize: 13 * context.sf));
|
||||
},
|
||||
),
|
||||
|
||||
SizedBox(width: 8 * sf),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"| ${team.season}",
|
||||
style: TextStyle(color: Colors.grey, fontSize: 13 * sf),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8 * context.sf),
|
||||
Expanded(child: Text("| ${team.season}", style: TextStyle(color: Colors.grey, fontSize: 13 * context.sf), overflow: TextOverflow.ellipsis)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// --- 4. BOTÕES (Estatísticas e Apagar) ---
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min, // <-- ISTO RESOLVE O OVERFLOW DAS RISCAS AMARELAS
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
tooltip: 'Ver Estatísticas',
|
||||
icon: Icon(Icons.bar_chart_rounded, color: Colors.blue, size: 24 * sf),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TeamStatsPage(team: team),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'Eliminar Equipa',
|
||||
icon: Icon(Icons.delete_outline, color: const Color(0xFFE74C3C), size: 24 * sf),
|
||||
onPressed: () => _confirmDelete(context),
|
||||
),
|
||||
IconButton(tooltip: 'Ver Estatísticas', icon: Icon(Icons.bar_chart_rounded, color: Colors.blue, size: 24 * context.sf), onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => TeamStatsPage(team: team)))),
|
||||
IconButton(tooltip: 'Eliminar Equipa', icon: Icon(Icons.delete_outline, color: const Color(0xFFE74C3C), size: 24 * context.sf), onPressed: () => _confirmDelete(context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -396,20 +280,11 @@ class TeamCard extends StatelessWidget {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Eliminar Equipa?', style: TextStyle(fontSize: 18 * sf, fontWeight: FontWeight.bold)),
|
||||
content: Text('Tens a certeza que queres eliminar "${team.name}"?', style: TextStyle(fontSize: 14 * sf)),
|
||||
title: Text('Eliminar Equipa?', style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||
content: Text('Tens a certeza que queres eliminar "${team.name}"?', style: TextStyle(fontSize: 14 * context.sf)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text('Cancelar', style: TextStyle(fontSize: 14 * sf)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
controller.deleteTeam(team.id);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text('Eliminar', style: TextStyle(color: Colors.red, fontSize: 14 * sf)),
|
||||
),
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancelar', style: TextStyle(fontSize: 14 * context.sf))),
|
||||
TextButton(onPressed: () { controller.deleteTeam(team.id); Navigator.pop(context); }, child: Text('Eliminar', style: TextStyle(color: Colors.red, fontSize: 14 * context.sf))),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -419,9 +294,7 @@ class TeamCard extends StatelessWidget {
|
||||
// --- DIALOG DE CRIAÇÃO ---
|
||||
class CreateTeamDialog extends StatefulWidget {
|
||||
final Function(String name, String season, String imageUrl) onConfirm;
|
||||
final double sf; // Recebe a escala
|
||||
|
||||
const CreateTeamDialog({super.key, required this.onConfirm, required this.sf});
|
||||
const CreateTeamDialog({super.key, required this.onConfirm});
|
||||
|
||||
@override
|
||||
State<CreateTeamDialog> createState() => _CreateTeamDialogState();
|
||||
@@ -435,69 +308,31 @@ class _CreateTeamDialogState extends State<CreateTeamDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * widget.sf)),
|
||||
title: Text('Nova Equipa', style: TextStyle(fontSize: 18 * widget.sf, fontWeight: FontWeight.bold)),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15 * context.sf)),
|
||||
title: Text('Nova Equipa', style: TextStyle(fontSize: 18 * context.sf, fontWeight: FontWeight.bold)),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
controller: _nameController,
|
||||
style: TextStyle(fontSize: 14 * widget.sf),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Nome da Equipa',
|
||||
labelStyle: TextStyle(fontSize: 14 * widget.sf)
|
||||
),
|
||||
textCapitalization: TextCapitalization.words,
|
||||
),
|
||||
SizedBox(height: 15 * widget.sf),
|
||||
TextField(controller: _nameController, style: TextStyle(fontSize: 14 * context.sf), decoration: InputDecoration(labelText: 'Nome da Equipa', labelStyle: TextStyle(fontSize: 14 * context.sf)), textCapitalization: TextCapitalization.words),
|
||||
SizedBox(height: 15 * context.sf),
|
||||
DropdownButtonFormField<String>(
|
||||
value: _selectedSeason,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Temporada',
|
||||
labelStyle: TextStyle(fontSize: 14 * widget.sf)
|
||||
),
|
||||
style: TextStyle(fontSize: 14 * widget.sf, color: Colors.black87),
|
||||
items: ['2023/24', '2024/25', '2025/26']
|
||||
.map((s) => DropdownMenuItem(value: s, child: Text(s)))
|
||||
.toList(),
|
||||
value: _selectedSeason, decoration: InputDecoration(labelText: 'Temporada', labelStyle: TextStyle(fontSize: 14 * context.sf)),
|
||||
style: TextStyle(fontSize: 14 * context.sf, color: Colors.black87),
|
||||
items: ['2023/24', '2024/25', '2025/26'].map((s) => DropdownMenuItem(value: s, child: Text(s))).toList(),
|
||||
onChanged: (val) => setState(() => _selectedSeason = val!),
|
||||
),
|
||||
SizedBox(height: 15 * widget.sf),
|
||||
TextField(
|
||||
controller: _imageController,
|
||||
style: TextStyle(fontSize: 14 * widget.sf),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'URL Imagem ou Emoji',
|
||||
labelStyle: TextStyle(fontSize: 14 * widget.sf),
|
||||
hintText: 'Ex: 🏀 ou https://...',
|
||||
hintStyle: TextStyle(fontSize: 14 * widget.sf)
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15 * context.sf),
|
||||
TextField(controller: _imageController, style: TextStyle(fontSize: 14 * context.sf), decoration: InputDecoration(labelText: 'URL Imagem ou Emoji', labelStyle: TextStyle(fontSize: 14 * context.sf), hintText: 'Ex: 🏀 ou https://...', hintStyle: TextStyle(fontSize: 14 * context.sf))),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text('Cancelar', style: TextStyle(fontSize: 14 * widget.sf))
|
||||
),
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancelar', style: TextStyle(fontSize: 14 * context.sf))),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFE74C3C),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16 * widget.sf, vertical: 10 * widget.sf)
|
||||
),
|
||||
onPressed: () {
|
||||
if (_nameController.text.trim().isNotEmpty) {
|
||||
widget.onConfirm(
|
||||
_nameController.text.trim(),
|
||||
_selectedSeason,
|
||||
_imageController.text.trim(),
|
||||
);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
child: Text('Criar', style: TextStyle(color: Colors.white, fontSize: 14 * widget.sf)),
|
||||
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFE74C3C), padding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 10 * context.sf)),
|
||||
onPressed: () { if (_nameController.text.trim().isNotEmpty) { widget.onConfirm(_nameController.text.trim(), _selectedSeason, _imageController.text.trim()); Navigator.pop(context); } },
|
||||
child: Text('Criar', style: TextStyle(color: Colors.white, fontSize: 14 * context.sf)),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user