fazer a tela de jogo ta tudo no PlacarPage
This commit is contained in:
@@ -12,17 +12,9 @@ class GamePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _GamePageState extends State<GamePage> {
|
||||
// Criamos as instâncias dos controllers
|
||||
final GameController gameController = GameController();
|
||||
final TeamController teamController = TeamController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// É importante fechar os streams quando a página sai da memória
|
||||
gameController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -33,12 +25,17 @@ class _GamePageState extends State<GamePage> {
|
||||
elevation: 0,
|
||||
),
|
||||
body: StreamBuilder<List<Game>>(
|
||||
// LÊ DIRETAMENTE DO SUPABASE
|
||||
stream: gameController.gamesStream,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (snapshot.hasError) {
|
||||
return Center(child: Text("Erro: ${snapshot.error}"));
|
||||
}
|
||||
|
||||
if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
||||
return const Center(child: Text("Nenhum jogo registado."));
|
||||
}
|
||||
@@ -49,7 +46,6 @@ class _GamePageState extends State<GamePage> {
|
||||
itemBuilder: (context, index) {
|
||||
final game = snapshot.data![index];
|
||||
|
||||
// ATUALIZADO: Passamos o gameId para o card
|
||||
return GameResultCard(
|
||||
gameId: game.id,
|
||||
myTeam: game.myTeam,
|
||||
@@ -75,10 +71,8 @@ class _GamePageState extends State<GamePage> {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => CreateGameDialogManual(
|
||||
controller: teamController,
|
||||
onConfirm: (my, opp, sea) {
|
||||
gameController.addGame(my, opp, sea);
|
||||
},
|
||||
teamController: teamController,
|
||||
gameController: gameController, // Passamos o controller para fazer o insert
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user