fazer vitoria e derrota
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/pages/PlacarPage.dart'; // Garante que o import está correto
|
||||
import 'package:playmaker/pages/PlacarPage.dart';
|
||||
import '../controllers/team_controller.dart';
|
||||
import '../controllers/game_controller.dart';
|
||||
|
||||
@@ -7,8 +7,9 @@ import '../controllers/game_controller.dart';
|
||||
class GameResultCard extends StatelessWidget {
|
||||
final String gameId;
|
||||
final String myTeam, opponentTeam, myScore, opponentScore, status, season;
|
||||
final String? myTeamLogo; // NOVA VARIÁVEL
|
||||
final String? opponentTeamLogo; // NOVA VARIÁVEL
|
||||
final String? myTeamLogo;
|
||||
final String? opponentTeamLogo;
|
||||
final double sf; // NOVA VARIÁVEL DE ESCALA
|
||||
|
||||
const GameResultCard({
|
||||
super.key,
|
||||
@@ -19,71 +20,70 @@ class GameResultCard extends StatelessWidget {
|
||||
required this.opponentScore,
|
||||
required this.status,
|
||||
required this.season,
|
||||
this.myTeamLogo, // ADICIONADO AO CONSTRUTOR
|
||||
this.opponentTeamLogo, // ADICIONADO AO CONSTRUTOR
|
||||
this.myTeamLogo,
|
||||
this.opponentTeamLogo,
|
||||
required this.sf, // OBRIGATÓRIO RECEBER A ESCALA
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.all(16),
|
||||
margin: EdgeInsets.only(bottom: 16 * sf),
|
||||
padding: EdgeInsets.all(16 * sf),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 10)],
|
||||
borderRadius: BorderRadius.circular(20 * sf),
|
||||
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 10 * sf)],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Passamos a imagem para a função
|
||||
Expanded(child: _buildTeamInfo(myTeam, const Color(0xFFE74C3C), myTeamLogo)),
|
||||
_buildScoreCenter(context, gameId),
|
||||
// Passamos a imagem para a função
|
||||
Expanded(child: _buildTeamInfo(opponentTeam, Colors.black87, opponentTeamLogo)),
|
||||
Expanded(child: _buildTeamInfo(myTeam, const Color(0xFFE74C3C), myTeamLogo, sf)),
|
||||
_buildScoreCenter(context, gameId, sf),
|
||||
Expanded(child: _buildTeamInfo(opponentTeam, Colors.black87, opponentTeamLogo, sf)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ATUALIZADO para desenhar a imagem
|
||||
Widget _buildTeamInfo(String name, Color color, String? logoUrl) {
|
||||
Widget _buildTeamInfo(String name, Color color, String? logoUrl, double sf) {
|
||||
return Column(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 24 * sf, // Ajuste do tamanho do logo
|
||||
backgroundColor: color,
|
||||
backgroundImage: (logoUrl != null && logoUrl.isNotEmpty)
|
||||
? NetworkImage(logoUrl)
|
||||
: null,
|
||||
child: (logoUrl == null || logoUrl.isEmpty)
|
||||
? const Icon(Icons.shield, color: Colors.white)
|
||||
? Icon(Icons.shield, color: Colors.white, size: 24 * sf)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
SizedBox(height: 6 * sf),
|
||||
Text(name,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 12),
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * sf),
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2, // Permite 2 linhas para nomes compridos não cortarem
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildScoreCenter(BuildContext context, String id) {
|
||||
Widget _buildScoreCenter(BuildContext context, String id, double sf) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_scoreBox(myScore, Colors.green),
|
||||
const Text(" : ", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20)),
|
||||
_scoreBox(opponentScore, Colors.grey),
|
||||
_scoreBox(myScore, Colors.green, sf),
|
||||
Text(" : ", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22 * sf)),
|
||||
_scoreBox(opponentScore, Colors.grey, sf),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: 10 * sf),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
// NAVEGAÇÃO PARA O PLACAR (Usando o ID real)
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
@@ -95,25 +95,25 @@ class GameResultCard extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.play_circle_fill, size: 16, color: Color(0xFFE74C3C)),
|
||||
label: const Text("RETORNAR", style: TextStyle(fontSize: 10, color: Color(0xFFE74C3C), fontWeight: FontWeight.bold)),
|
||||
icon: Icon(Icons.play_circle_fill, size: 18 * sf, color: const Color(0xFFE74C3C)),
|
||||
label: Text("RETORNAR", style: TextStyle(fontSize: 11 * sf, color: const Color(0xFFE74C3C), fontWeight: FontWeight.bold)),
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFE74C3C).withOpacity(0.1),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||
padding: EdgeInsets.symmetric(horizontal: 14 * sf, vertical: 8 * sf),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * sf)),
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(status, style: const TextStyle(fontSize: 10, color: Colors.blue, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 6 * sf),
|
||||
Text(status, style: TextStyle(fontSize: 12 * sf, color: Colors.blue, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _scoreBox(String pts, Color c) => Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(8)),
|
||||
child: Text(pts, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||
Widget _scoreBox(String pts, Color c, double sf) => Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12 * sf, vertical: 6 * sf),
|
||||
decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(8 * sf)),
|
||||
child: Text(pts, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16 * sf)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,11 +121,13 @@ class GameResultCard extends StatelessWidget {
|
||||
class CreateGameDialogManual extends StatefulWidget {
|
||||
final TeamController teamController;
|
||||
final GameController gameController;
|
||||
final double sf; // NOVA VARIÁVEL DE ESCALA
|
||||
|
||||
const CreateGameDialogManual({
|
||||
super.key,
|
||||
required this.teamController,
|
||||
required this.gameController
|
||||
required this.gameController,
|
||||
required this.sf,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -153,33 +155,46 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||
title: const Text('Configurar Partida', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * widget.sf)),
|
||||
title: Text('Configurar Partida', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18 * widget.sf)),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
controller: _seasonController,
|
||||
decoration: const InputDecoration(labelText: 'Temporada', border: OutlineInputBorder(), prefixIcon: Icon(Icons.calendar_today)),
|
||||
style: TextStyle(fontSize: 14 * widget.sf),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Temporada',
|
||||
labelStyle: TextStyle(fontSize: 14 * widget.sf),
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.calendar_today, size: 20 * widget.sf)
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
SizedBox(height: 15 * widget.sf),
|
||||
|
||||
_buildSearch(label: "Minha Equipa", controller: _myTeamController),
|
||||
_buildSearch(label: "Minha Equipa", controller: _myTeamController, sf: widget.sf),
|
||||
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 8), child: Text("VS", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey))),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10 * widget.sf),
|
||||
child: Text("VS", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 16 * widget.sf))
|
||||
),
|
||||
|
||||
_buildSearch(label: "Adversário", controller: _opponentController),
|
||||
_buildSearch(label: "Adversário", controller: _opponentController, sf: widget.sf),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: const Text('CANCELAR')),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text('CANCELAR', style: TextStyle(fontSize: 14 * widget.sf))
|
||||
),
|
||||
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFFE74C3C),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10 * widget.sf)),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16 * widget.sf, vertical: 10 * widget.sf)
|
||||
),
|
||||
onPressed: _isLoading ? null : () async {
|
||||
if (_myTeamController.text.isNotEmpty && _opponentController.text.isNotEmpty) {
|
||||
@@ -210,15 +225,14 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
}
|
||||
},
|
||||
child: _isLoading
|
||||
? const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||
: const Text('CRIAR', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||
? SizedBox(width: 20 * widget.sf, height: 20 * widget.sf, child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||
: Text('CRIAR', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14 * widget.sf)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ATUALIZADO para usar Map e mostrar a imagem na lista de pesquisa
|
||||
Widget _buildSearch({required String label, required TextEditingController controller}) {
|
||||
Widget _buildSearch({required String label, required TextEditingController controller, required double sf}) {
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: widget.teamController.teamsStream,
|
||||
builder: (context, snapshot) {
|
||||
@@ -242,10 +256,9 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
alignment: Alignment.topLeft,
|
||||
child: Material(
|
||||
elevation: 4.0,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: BorderRadius.circular(8 * sf),
|
||||
child: ConstrainedBox(
|
||||
// Ajuste do tamanho máximo do pop-up de sugestões
|
||||
constraints: BoxConstraints(maxHeight: 250, maxWidth: MediaQuery.of(context).size.width * 0.7),
|
||||
constraints: BoxConstraints(maxHeight: 250 * sf, maxWidth: MediaQuery.of(context).size.width * 0.7),
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
@@ -257,15 +270,16 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
radius: 20 * sf,
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
backgroundImage: (imageUrl != null && imageUrl.isNotEmpty)
|
||||
? NetworkImage(imageUrl)
|
||||
: null,
|
||||
child: (imageUrl == null || imageUrl.isEmpty)
|
||||
? const Icon(Icons.shield, color: Colors.grey)
|
||||
? Icon(Icons.shield, color: Colors.grey, size: 20 * sf)
|
||||
: null,
|
||||
),
|
||||
title: Text(name, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
title: Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14 * sf)),
|
||||
onTap: () {
|
||||
onSelected(option);
|
||||
},
|
||||
@@ -288,9 +302,11 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
return TextField(
|
||||
controller: txtCtrl,
|
||||
focusNode: node,
|
||||
style: TextStyle(fontSize: 14 * sf),
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
labelStyle: TextStyle(fontSize: 14 * sf),
|
||||
prefixIcon: Icon(Icons.search, size: 20 * sf),
|
||||
border: const OutlineInputBorder()
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user