melhorar o sensor de calor
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/pages/PlacarPage.dart';
|
||||
import 'package:playmaker/pages/PlacarPage.dart';
|
||||
import '../controllers/game_controller.dart';
|
||||
import '../controllers/team_controller.dart';
|
||||
import '../models/game_model.dart';
|
||||
import '../utils/size_extension.dart'; // 👇 NOVO SUPERPODER AQUI TAMBÉM!
|
||||
import '../utils/size_extension.dart';
|
||||
import 'dart:math' as math; // 👇 IMPORTANTE PARA O TRAVÃO DE MÃO
|
||||
|
||||
// --- CARD DE EXIBIÇÃO DO JOGO ---
|
||||
class GameResultCard extends StatelessWidget {
|
||||
@@ -18,59 +19,61 @@ class GameResultCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double safeSf = math.min(context.sf, 1.15); // TRAVÃO DO TABLET
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 16 * context.sf),
|
||||
padding: EdgeInsets.all(16 * context.sf),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(20 * context.sf), boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 10 * context.sf)]),
|
||||
margin: EdgeInsets.only(bottom: 16 * safeSf),
|
||||
padding: EdgeInsets.all(16 * safeSf),
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(20 * safeSf), boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 10 * safeSf)]),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: _buildTeamInfo(context, myTeam, const Color(0xFFE74C3C), myTeamLogo)),
|
||||
_buildScoreCenter(context, gameId),
|
||||
Expanded(child: _buildTeamInfo(context, opponentTeam, Colors.black87, opponentTeamLogo)),
|
||||
Expanded(child: _buildTeamInfo(myTeam, const Color(0xFFE74C3C), myTeamLogo, safeSf)),
|
||||
_buildScoreCenter(context, gameId, safeSf),
|
||||
Expanded(child: _buildTeamInfo(opponentTeam, Colors.black87, opponentTeamLogo, safeSf)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTeamInfo(BuildContext context, String name, Color color, String? logoUrl) {
|
||||
Widget _buildTeamInfo(String name, Color color, String? logoUrl, double safeSf) {
|
||||
return Column(
|
||||
children: [
|
||||
CircleAvatar(radius: 24 * context.sf, backgroundColor: color, backgroundImage: (logoUrl != null && logoUrl.isNotEmpty) ? NetworkImage(logoUrl) : null, child: (logoUrl == null || logoUrl.isEmpty) ? Icon(Icons.shield, color: Colors.white, size: 24 * context.sf) : null),
|
||||
SizedBox(height: 6 * context.sf),
|
||||
Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * context.sf), textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, maxLines: 2),
|
||||
CircleAvatar(radius: 24 * safeSf, backgroundColor: color, backgroundImage: (logoUrl != null && logoUrl.isNotEmpty) ? NetworkImage(logoUrl) : null, child: (logoUrl == null || logoUrl.isEmpty) ? Icon(Icons.shield, color: Colors.white, size: 24 * safeSf) : null),
|
||||
SizedBox(height: 6 * safeSf),
|
||||
Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13 * safeSf), textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, maxLines: 2),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildScoreCenter(BuildContext context, String id) {
|
||||
Widget _buildScoreCenter(BuildContext context, String id, double safeSf) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_scoreBox(context, myScore, Colors.green),
|
||||
Text(" : ", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22 * context.sf)),
|
||||
_scoreBox(context, opponentScore, Colors.grey),
|
||||
_scoreBox(myScore, Colors.green, safeSf),
|
||||
Text(" : ", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22 * safeSf)),
|
||||
_scoreBox(opponentScore, Colors.grey, safeSf),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10 * context.sf),
|
||||
SizedBox(height: 10 * safeSf),
|
||||
TextButton.icon(
|
||||
onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => PlacarPage(gameId: id, myTeam: myTeam, opponentTeam: opponentTeam))),
|
||||
icon: Icon(Icons.play_circle_fill, size: 18 * context.sf, color: const Color(0xFFE74C3C)),
|
||||
label: Text("RETORNAR", style: TextStyle(fontSize: 11 * context.sf, color: const Color(0xFFE74C3C), fontWeight: FontWeight.bold)),
|
||||
style: TextButton.styleFrom(backgroundColor: const Color(0xFFE74C3C).withOpacity(0.1), padding: EdgeInsets.symmetric(horizontal: 14 * context.sf, vertical: 8 * context.sf), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * context.sf)), visualDensity: VisualDensity.compact),
|
||||
icon: Icon(Icons.play_circle_fill, size: 18 * safeSf, color: const Color(0xFFE74C3C)),
|
||||
label: Text("RETORNAR", style: TextStyle(fontSize: 11 * safeSf, color: const Color(0xFFE74C3C), fontWeight: FontWeight.bold)),
|
||||
style: TextButton.styleFrom(backgroundColor: const Color(0xFFE74C3C).withOpacity(0.1), padding: EdgeInsets.symmetric(horizontal: 14 * safeSf, vertical: 8 * safeSf), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * safeSf)), visualDensity: VisualDensity.compact),
|
||||
),
|
||||
SizedBox(height: 6 * context.sf),
|
||||
Text(status, style: TextStyle(fontSize: 12 * context.sf, color: Colors.blue, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 6 * safeSf),
|
||||
Text(status, style: TextStyle(fontSize: 12 * safeSf, color: Colors.blue, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _scoreBox(BuildContext context, String pts, Color c) => Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12 * context.sf, vertical: 6 * context.sf),
|
||||
decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(8 * context.sf)),
|
||||
child: Text(pts, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16 * context.sf)),
|
||||
Widget _scoreBox(String pts, Color c, double safeSf) => Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12 * safeSf, vertical: 6 * safeSf),
|
||||
decoration: BoxDecoration(color: c, borderRadius: BorderRadius.circular(8 * safeSf)),
|
||||
child: Text(pts, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16 * safeSf)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,25 +107,30 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double safeSf = math.min(context.sf, 1.15); // TRAVÃO DO TABLET
|
||||
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * context.sf)),
|
||||
title: Text('Configurar Partida', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18 * context.sf)),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20 * safeSf)),
|
||||
title: Text('Configurar Partida', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18 * safeSf)),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(controller: _seasonController, style: TextStyle(fontSize: 14 * context.sf), decoration: InputDecoration(labelText: 'Temporada', labelStyle: TextStyle(fontSize: 14 * context.sf), border: const OutlineInputBorder(), prefixIcon: Icon(Icons.calendar_today, size: 20 * context.sf))),
|
||||
SizedBox(height: 15 * context.sf),
|
||||
_buildSearch(context, "Minha Equipa", _myTeamController),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 10 * context.sf), child: Text("VS", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 16 * context.sf))),
|
||||
_buildSearch(context, "Adversário", _opponentController),
|
||||
],
|
||||
child: Container(
|
||||
constraints: BoxConstraints(maxWidth: 450 * safeSf), // LIMITA A LARGURA NO TABLET
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(controller: _seasonController, style: TextStyle(fontSize: 14 * safeSf), decoration: InputDecoration(labelText: 'Temporada', labelStyle: TextStyle(fontSize: 14 * safeSf), border: const OutlineInputBorder(), prefixIcon: Icon(Icons.calendar_today, size: 20 * safeSf))),
|
||||
SizedBox(height: 15 * safeSf),
|
||||
_buildSearch(label: "Minha Equipa", controller: _myTeamController, safeSf: safeSf),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 10 * safeSf), child: Text("VS", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 16 * safeSf))),
|
||||
_buildSearch(label: "Adversário", controller: _opponentController, safeSf: safeSf),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('CANCELAR', style: TextStyle(fontSize: 14 * context.sf))),
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('CANCELAR', style: TextStyle(fontSize: 14 * safeSf))),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFE74C3C), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10 * context.sf)), padding: EdgeInsets.symmetric(horizontal: 16 * context.sf, vertical: 10 * context.sf)),
|
||||
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFE74C3C), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10 * safeSf)), padding: EdgeInsets.symmetric(horizontal: 16 * safeSf, vertical: 10 * safeSf)),
|
||||
onPressed: _isLoading ? null : () async {
|
||||
if (_myTeamController.text.isNotEmpty && _opponentController.text.isNotEmpty) {
|
||||
setState(() => _isLoading = true);
|
||||
@@ -134,13 +142,13 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
}
|
||||
}
|
||||
},
|
||||
child: _isLoading ? SizedBox(width: 20 * context.sf, height: 20 * context.sf, child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2)) : Text('CRIAR', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14 * context.sf)),
|
||||
child: _isLoading ? SizedBox(width: 20 * safeSf, height: 20 * safeSf, child: const CircularProgressIndicator(color: Colors.white, strokeWidth: 2)) : Text('CRIAR', style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14 * safeSf)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSearch(BuildContext context, String label, TextEditingController controller) {
|
||||
Widget _buildSearch({required String label, required TextEditingController controller, required double safeSf}) {
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: widget.teamController.teamsStream,
|
||||
builder: (context, snapshot) {
|
||||
@@ -156,9 +164,9 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Material(
|
||||
elevation: 4.0, borderRadius: BorderRadius.circular(8 * context.sf),
|
||||
elevation: 4.0, borderRadius: BorderRadius.circular(8 * safeSf),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: 250 * context.sf, maxWidth: MediaQuery.of(context).size.width * 0.7),
|
||||
constraints: BoxConstraints(maxHeight: 250 * safeSf, maxWidth: 400 * safeSf), // Limita também o dropdown
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero, shrinkWrap: true, itemCount: options.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
@@ -166,8 +174,8 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
final String name = option['name'].toString();
|
||||
final String? imageUrl = option['image_url'];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(radius: 20 * context.sf, backgroundColor: Colors.grey.shade200, backgroundImage: (imageUrl != null && imageUrl.isNotEmpty) ? NetworkImage(imageUrl) : null, child: (imageUrl == null || imageUrl.isEmpty) ? Icon(Icons.shield, color: Colors.grey, size: 20 * context.sf) : null),
|
||||
title: Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14 * context.sf)),
|
||||
leading: CircleAvatar(radius: 20 * safeSf, backgroundColor: Colors.grey.shade200, backgroundImage: (imageUrl != null && imageUrl.isNotEmpty) ? NetworkImage(imageUrl) : null, child: (imageUrl == null || imageUrl.isEmpty) ? Icon(Icons.shield, color: Colors.grey, size: 20 * safeSf) : null),
|
||||
title: Text(name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14 * safeSf)),
|
||||
onTap: () { onSelected(option); },
|
||||
);
|
||||
},
|
||||
@@ -180,8 +188,8 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
if (txtCtrl.text.isEmpty && controller.text.isNotEmpty) txtCtrl.text = controller.text;
|
||||
txtCtrl.addListener(() { controller.text = txtCtrl.text; });
|
||||
return TextField(
|
||||
controller: txtCtrl, focusNode: node, style: TextStyle(fontSize: 14 * context.sf),
|
||||
decoration: InputDecoration(labelText: label, labelStyle: TextStyle(fontSize: 14 * context.sf), prefixIcon: Icon(Icons.search, size: 20 * context.sf), border: const OutlineInputBorder()),
|
||||
controller: txtCtrl, focusNode: node, style: TextStyle(fontSize: 14 * safeSf),
|
||||
decoration: InputDecoration(labelText: label, labelStyle: TextStyle(fontSize: 14 * safeSf), prefixIcon: Icon(Icons.search, size: 20 * safeSf), border: const OutlineInputBorder()),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -190,6 +198,8 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
}
|
||||
}
|
||||
|
||||
// (O RESTO DA CLASSE GamePage CONTINUA IGUAL, o sf nativo já estava protegido lá dentro)
|
||||
|
||||
// --- PÁGINA PRINCIPAL DOS JOGOS ---
|
||||
class GamePage extends StatefulWidget {
|
||||
const GamePage({super.key});
|
||||
|
||||
Reference in New Issue
Block a user