tamanho da tela
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:playmaker/controllers/placar_controller.dart';
|
||||
import 'package:playmaker/widgets/placar_widgets.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
class PlacarPage extends StatefulWidget {
|
||||
final String gameId, myTeam, opponentTeam;
|
||||
@@ -17,7 +18,10 @@ class _PlacarPageState extends State<PlacarPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft]);
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.landscapeRight,
|
||||
DeviceOrientation.landscapeLeft,
|
||||
]);
|
||||
|
||||
_controller = PlacarController(
|
||||
gameId: widget.gameId,
|
||||
@@ -37,8 +41,8 @@ class _PlacarPageState extends State<PlacarPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// Função auxiliar para criar o botão de arrastar faltas que não está no painel inferior
|
||||
Widget _buildFloatingFoulBtn(String label, Color color, String action, IconData icon, double left, double right, double top, double h) {
|
||||
// --- BOTÕES FLUTUANTES DE FALTA (MUITO MAIS PEQUENOS AQUI 👇) ---
|
||||
Widget _buildFloatingFoulBtn(String label, Color color, String action, IconData icon, double left, double right, double top, double sf) {
|
||||
return Positioned(
|
||||
top: top,
|
||||
left: left > 0 ? left : null,
|
||||
@@ -47,160 +51,216 @@ class _PlacarPageState extends State<PlacarPage> {
|
||||
data: action,
|
||||
feedback: Material(
|
||||
color: Colors.transparent,
|
||||
child: CircleAvatar(radius: 30, backgroundColor: color.withOpacity(0.8), child: Icon(icon, color: Colors.white)),
|
||||
child: CircleAvatar(
|
||||
radius: 25 * sf, // Era 35
|
||||
backgroundColor: color.withOpacity(0.8),
|
||||
child: Icon(icon, color: Colors.white, size: 25 * sf) // Era 35
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 25,
|
||||
radius: 22 * sf, // Era 30
|
||||
backgroundColor: color,
|
||||
child: Icon(icon, color: Colors.white, size: 30),
|
||||
child: Icon(icon, color: Colors.white, size: 26 * sf), // Era 35
|
||||
),
|
||||
Text(label, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12)),
|
||||
SizedBox(height: 4 * sf),
|
||||
Text(label, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 11 * sf)), // Era 14
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// --- BOTÕES LATERAIS QUADRADOS ---
|
||||
Widget _buildCornerBtn({required String heroTag, required IconData icon, required Color color, required VoidCallback onTap, required double size, bool isLoading = false}) {
|
||||
return SizedBox(
|
||||
width: size,
|
||||
height: size,
|
||||
child: FloatingActionButton(
|
||||
heroTag: heroTag,
|
||||
backgroundColor: color,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12 * (size / 50))),
|
||||
elevation: 4,
|
||||
onPressed: isLoading ? null : onTap,
|
||||
child: isLoading
|
||||
? SizedBox(width: size*0.4, height: size*0.4, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||
: Icon(icon, color: Colors.white, size: size * 0.5),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double wScreen = MediaQuery.of(context).size.width;
|
||||
final double hScreen = MediaQuery.of(context).size.height;
|
||||
final double sf = math.min(wScreen / 1280, hScreen / 800);
|
||||
|
||||
final double cornerBtnSize = 50 * sf;
|
||||
|
||||
if (_controller.isLoading) {
|
||||
return const Scaffold(
|
||||
backgroundColor: Color(0xFF266174),
|
||||
body: Center(child: CircularProgressIndicator(color: Colors.white)),
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF16202C),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("PREPARANDO O PAVILHÃO", style: TextStyle(color: Colors.white24, fontSize: 40 * sf, fontWeight: FontWeight.bold, letterSpacing: 2)),
|
||||
SizedBox(height: 30 * sf),
|
||||
StreamBuilder(
|
||||
stream: Stream.periodic(const Duration(seconds: 3)),
|
||||
builder: (context, snapshot) {
|
||||
List<String> frases = [
|
||||
"O Treinador está a desenhar a tática...",
|
||||
"A encher as bolas com ar de campeão...",
|
||||
"O árbitro está a testar o apito...",
|
||||
"A verificar se o cesto está nivelado...",
|
||||
"Os jogadores estão a terminar o aquecimento..."
|
||||
];
|
||||
String frase = frases[DateTime.now().second % frases.length];
|
||||
return Text(frase, style: TextStyle(color: Colors.orange.withOpacity(0.7), fontSize: 24 * sf, fontStyle: FontStyle.italic));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF266174),
|
||||
body: Stack(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 60, right: 60, bottom: 50),
|
||||
decoration: BoxDecoration(border: Border.all(color: Colors.white, width: 2.0)),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final w = constraints.maxWidth;
|
||||
final h = constraints.maxHeight;
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
// --- O CAMPO ---
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 60 * sf, right: 60 * sf, bottom: 50 * sf),
|
||||
decoration: BoxDecoration(border: Border.all(color: Colors.white, width: 2.0)),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final w = constraints.maxWidth;
|
||||
final h = constraints.maxHeight;
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
// --- MAPA DO CAMPO ---
|
||||
GestureDetector(
|
||||
onTapDown: (details) {
|
||||
if (_controller.isSelectingShotLocation) _controller.registerShotLocation(details.localPosition);
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(image: AssetImage('assets/campo.png'), fit: BoxFit.cover, alignment: Alignment(0.0, 0.2)),
|
||||
),
|
||||
child: Stack(
|
||||
children: _controller.matchShots.map((shot) => Positioned(
|
||||
left: shot.position.dx - 8, top: shot.position.dy - 8,
|
||||
child: CircleAvatar(radius: 8, backgroundColor: shot.isMake ? Colors.green : Colors.red, child: Icon(shot.isMake ? Icons.check : Icons.close, size: 10, color: Colors.white)),
|
||||
)).toList(),
|
||||
return Stack(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTapDown: (details) {
|
||||
if (_controller.isSelectingShotLocation) {
|
||||
_controller.registerShotLocation(context, details.localPosition, Size(w, h));
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(image: AssetImage('assets/campo.png'), fit: BoxFit.cover, alignment: Alignment(0.0, 0.2)),
|
||||
),
|
||||
child: Stack(
|
||||
children: _controller.matchShots.map((shot) => Positioned(
|
||||
left: shot.position.dx - (8 * sf), top: shot.position.dy - (8 * sf),
|
||||
child: CircleAvatar(radius: 8 * sf, backgroundColor: shot.isMake ? Colors.green : Colors.red, child: Icon(shot.isMake ? Icons.check : Icons.close, size: 10 * sf, color: Colors.white)),
|
||||
)).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// --- JOGADORES EM CAMPO ---
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
Positioned(top: h * 0.25, left: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[0], isOpponent: false)),
|
||||
Positioned(top: h * 0.68, left: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[1], isOpponent: false)),
|
||||
Positioned(top: h * 0.45, left: w * 0.25, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[2], isOpponent: false)),
|
||||
Positioned(top: h * 0.15, left: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[3], isOpponent: false)),
|
||||
Positioned(top: h * 0.80, left: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[4], isOpponent: false)),
|
||||
// --- JOGADORES ---
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
Positioned(top: h * 0.25, left: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[0], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.68, left: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[1], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.45, left: w * 0.25, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[2], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.15, left: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[3], isOpponent: false, sf: sf)),
|
||||
Positioned(top: h * 0.80, left: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.myCourt[4], isOpponent: false, sf: sf)),
|
||||
|
||||
Positioned(top: h * 0.25, right: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[0], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.68, right: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[1], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.45, right: w * 0.25, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[2], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.15, right: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[3], isOpponent: true, sf: sf)),
|
||||
Positioned(top: h * 0.80, right: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[4], isOpponent: true, sf: sf)),
|
||||
],
|
||||
|
||||
// --- BOTÕES DE FALTAS ---
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
_buildFloatingFoulBtn("FALTA +", Colors.orange, "add_foul", Icons.sports, w * 0.38, 0.0, h * 0.30, sf),
|
||||
_buildFloatingFoulBtn("FALTA -", Colors.redAccent, "sub_foul", Icons.block, 0.0, w * 0.38, h * 0.30, sf),
|
||||
],
|
||||
|
||||
// --- BOTÃO PLAY/PAUSE ---
|
||||
if (!_controller.isSelectingShotLocation)
|
||||
Positioned(
|
||||
top: (h * 0.30) + (100 * sf), left: 0, right: 0,
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: () => _controller.toggleTimer(context),
|
||||
child: CircleAvatar(radius: 60 * sf, backgroundColor: Colors.grey.withOpacity(0.5), child: Icon(_controller.isRunning ? Icons.pause : Icons.play_arrow, color: Colors.white, size: 50 * sf)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// --- PLACAR NO TOPO ---
|
||||
Positioned(top: 0, left: 0, right: 0, child: Center(child: TopScoreboard(controller: _controller, sf: sf))),
|
||||
|
||||
Positioned(top: h * 0.25, right: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[0], isOpponent: true)),
|
||||
Positioned(top: h * 0.68, right: w * 0.02, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[1], isOpponent: true)),
|
||||
Positioned(top: h * 0.45, right: w * 0.25, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[2], isOpponent: true)),
|
||||
Positioned(top: h * 0.15, right: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[3], isOpponent: true)),
|
||||
Positioned(top: h * 0.80, right: w * 0.20, child: PlayerCourtCard(controller: _controller, name: _controller.oppCourt[4], isOpponent: true)),
|
||||
],
|
||||
// --- BOTÕES DE AÇÃO ---
|
||||
if (!_controller.isSelectingShotLocation) Positioned(bottom: 10 * sf, left: 0, right: 0, child: ActionButtonsPanel(controller: _controller, sf: sf)),
|
||||
|
||||
// --- BOTÕES DE FALTA (FLUTUANTES) ---
|
||||
// Estes são os botões que você pediu, posicionados em relação ao centro
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
_buildFloatingFoulBtn("FALTA +", Colors.orange, "add_foul", Icons.sports, w * 0.38, 0, h * 0.30, h),
|
||||
_buildFloatingFoulBtn("FALTA -", Colors.redAccent, "sub_foul", Icons.block, 0, w * 0.38, h * 0.30, h),
|
||||
],
|
||||
|
||||
// --- BOTÃO CENTRAL DO TEMPO ---
|
||||
if (!_controller.isSelectingShotLocation)
|
||||
Positioned(
|
||||
top: (h * 0.30) + 70, left: 0, right: 0,
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: () => _controller.toggleTimer(context),
|
||||
child: CircleAvatar(radius: 60, backgroundColor: Colors.grey.withOpacity(0.5), child: Icon(_controller.isRunning ? Icons.pause : Icons.play_arrow, color: Colors.white, size: 50)),
|
||||
// --- OVERLAY LANÇAMENTO ---
|
||||
if (_controller.isSelectingShotLocation)
|
||||
Positioned(
|
||||
top: h * 0.4, left: 0, right: 0,
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 30 * sf, vertical: 15 * sf),
|
||||
decoration: BoxDecoration(color: Colors.black87, borderRadius: BorderRadius.circular(10 * sf), border: Border.all(color: Colors.white)),
|
||||
child: Text("TOQUE NO CAMPO PARA MARCAR O LOCAL DO LANÇAMENTO", style: TextStyle(color: Colors.white, fontSize: 24 * sf, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// --- PLACAR E BOTÕES DE AÇÃO ---
|
||||
Positioned(top: 0, left: 0, right: 0, child: Center(child: TopScoreboard(controller: _controller))),
|
||||
if (!_controller.isSelectingShotLocation) Positioned(bottom: 10, left: 0, right: 0, child: ActionButtonsPanel(controller: _controller)),
|
||||
|
||||
// --- OVERLAY DE MARCAÇÃO DE LANÇAMENTO ---
|
||||
if (_controller.isSelectingShotLocation)
|
||||
Positioned(
|
||||
top: h * 0.4, left: 0, right: 0,
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
decoration: BoxDecoration(color: Colors.black87, borderRadius: BorderRadius.circular(10), border: Border.all(color: Colors.white)),
|
||||
child: const Text("TOQUE NO CAMPO PARA MARCAR O LOCAL DO LANÇAMENTO", style: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
),
|
||||
),
|
||||
// --- BOTÕES LATERAIS ---
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
// Topo Esquerdo: Guardar e Sair
|
||||
Positioned(
|
||||
top: 20 * sf, left: 10 * sf,
|
||||
child: Column(
|
||||
children: [
|
||||
_buildCornerBtn(heroTag: 'btn_save', icon: Icons.save, color: const Color(0xFF16202C), size: cornerBtnSize, isLoading: _controller.isSaving, onTap: () => _controller.saveGameStats(context)),
|
||||
SizedBox(height: 15 * sf),
|
||||
_buildCornerBtn(heroTag: 'btn_exit', icon: Icons.exit_to_app, color: const Color(0xFFD92C2C), size: cornerBtnSize, onTap: () => Navigator.pop(context)),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// --- MENUS LATERAIS E BANCOS DE SUPLENTES ---
|
||||
if (!_controller.isSelectingShotLocation) ...[
|
||||
Positioned(
|
||||
top: 20, left: 10,
|
||||
child: FloatingActionButton(
|
||||
heroTag: 'btn_save',
|
||||
backgroundColor: const Color(0xFF16202C),
|
||||
mini: true,
|
||||
onPressed: _controller.isSaving ? null : () => _controller.saveGameStats(context),
|
||||
child: _controller.isSaving
|
||||
? const SizedBox(width: 15, height: 15, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||
: const Icon(Icons.save, color: Colors.white)
|
||||
)
|
||||
),
|
||||
Positioned(top: 70, left: 10, child: FloatingActionButton(heroTag: 'btn_exit', backgroundColor: const Color(0xFFD92C2C), mini: true, onPressed: () => Navigator.pop(context), child: const Icon(Icons.exit_to_app, color: Colors.white))),
|
||||
|
||||
Positioned(
|
||||
bottom: 50, left: 10,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_controller.showMyBench) BenchPlayersList(controller: _controller, isOpponent: false),
|
||||
const SizedBox(height: 10),
|
||||
FloatingActionButton(heroTag: 'btn_sub_home', backgroundColor: const Color(0xFF1E5BB2), mini: true, onPressed: () { _controller.showMyBench = !_controller.showMyBench; _controller.onUpdate(); }, child: const Icon(Icons.swap_horiz, color: Colors.white)),
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: 50, right: 10,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_controller.showOppBench) BenchPlayersList(controller: _controller, isOpponent: true),
|
||||
const SizedBox(height: 10),
|
||||
FloatingActionButton(heroTag: 'btn_sub_away', backgroundColor: const Color(0xFFD92C2C), mini: true, onPressed: () { _controller.showOppBench = !_controller.showOppBench; _controller.onUpdate(); }, child: const Icon(Icons.swap_horiz, color: Colors.white)),
|
||||
],
|
||||
// Base Esquerda: Banco Casa
|
||||
Positioned(
|
||||
bottom: 50 * sf, left: 10 * sf,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_controller.showMyBench) BenchPlayersList(controller: _controller, isOpponent: false, sf: sf),
|
||||
SizedBox(height: 10 * sf),
|
||||
_buildCornerBtn(heroTag: 'btn_sub_home', icon: Icons.swap_horiz, color: const Color(0xFF1E5BB2), size: cornerBtnSize, onTap: () { _controller.showMyBench = !_controller.showMyBench; _controller.onUpdate(); })
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Base Direita: Banco Visitante
|
||||
Positioned(
|
||||
bottom: 50 * sf, right: 10 * sf,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (_controller.showOppBench) BenchPlayersList(controller: _controller, isOpponent: true, sf: sf),
|
||||
SizedBox(height: 10 * sf),
|
||||
_buildCornerBtn(heroTag: 'btn_sub_away', icon: Icons.swap_horiz, color: const Color(0xFFD92C2C), size: cornerBtnSize, onTap: () { _controller.showOppBench = !_controller.showOppBench; _controller.onUpdate(); })
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user