JOGO
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import '../models/game_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:playmaker/pages/PlacarPage.dart';
|
||||
import 'package:playmaker/widgets/share_game_dialog.dart';
|
||||
import 'package:playmaker/classe/theme.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import '../controllers/team_controller.dart';
|
||||
import '../controllers/game_controller.dart';
|
||||
import '../controllers/game_sharing_controller.dart';
|
||||
import '../utils/size_extension.dart';
|
||||
|
||||
import 'pdf_export_service.dart';
|
||||
@@ -281,6 +282,7 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
late TextEditingController _seasonController;
|
||||
final TextEditingController _myTeamController = TextEditingController();
|
||||
final TextEditingController _opponentController = TextEditingController();
|
||||
final GameSharingController _sharingController = GameSharingController();
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
@@ -318,6 +320,7 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: Text('CANCELAR', style: TextStyle(fontSize: 14 * widget.sf, color: Colors.grey))),
|
||||
TextButton(onPressed: _isLoading ? null : () async => await _joinRoom(), child: Text('ENTRAR NA SALA', style: TextStyle(fontSize: 14 * widget.sf))),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: AppTheme.primaryRed, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10 * widget.sf)), padding: EdgeInsets.symmetric(horizontal: 16 * widget.sf, vertical: 10 * widget.sf)),
|
||||
onPressed: _isLoading ? null : () async {
|
||||
@@ -337,6 +340,40 @@ class _CreateGameDialogManualState extends State<CreateGameDialogManual> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _joinRoom() async {
|
||||
print("🚪 Abrindo diálogo para entrar na sala");
|
||||
final result = await showDialog<Map<String, dynamic>>(
|
||||
context: context,
|
||||
builder: (ctx) => JoinGameDialog(controller: _sharingController),
|
||||
);
|
||||
|
||||
print("📦 Resultado do diálogo: $result");
|
||||
if (result == null) {
|
||||
print("❌ Resultado nulo, cancelado");
|
||||
return;
|
||||
}
|
||||
final gameData = result['game'] as Map<String, dynamic>?;
|
||||
print("🎮 Game data: $gameData");
|
||||
if (gameData == null) {
|
||||
print("❌ Game data nula");
|
||||
return;
|
||||
}
|
||||
|
||||
final String gameId = gameData['id']?.toString() ?? '';
|
||||
final String myTeam = gameData['my_team']?.toString() ?? _myTeamController.text;
|
||||
final String opponentTeam = gameData['opponent_team']?.toString() ?? _opponentController.text;
|
||||
|
||||
print("🆔 Game ID: $gameId, My Team: $myTeam, Opponent: $opponentTeam");
|
||||
|
||||
if (gameId.isNotEmpty && context.mounted) {
|
||||
print("➡️ Navegando para PlacarPage");
|
||||
Navigator.pop(context);
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => PlacarPage(gameId: gameId, myTeam: myTeam, opponentTeam: opponentTeam)));
|
||||
} else {
|
||||
print("❌ Game ID vazio ou contexto não montado");
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildSearch(BuildContext context, String label, TextEditingController controller) {
|
||||
return StreamBuilder<List<Map<String, dynamic>>>(
|
||||
stream: widget.teamController.teamsStream,
|
||||
|
||||
Reference in New Issue
Block a user