Fix grid a fucking gain

This commit is contained in:
2025-02-22 18:13:09 +01:00
parent bbd3583939
commit 795060a05b

View File

@@ -90,73 +90,41 @@ class _MyHomePageState extends State<MyHomePage> {
onRefresh: _refreshGames, onRefresh: _refreshGames,
child: SingleChildScrollView( child: SingleChildScrollView(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Column( child: Wrap(
spacing: 8,
runSpacing: 8,
children: [ children: [
for (var i = 0; i < games.length + 1; i += 2) ...games.values.map(
Padding( (game) => SizedBox(
padding: const EdgeInsets.only(bottom: 8), width: (MediaQuery.of(context).size.width - 24) / 2,
child: Row( child: GameCard(
crossAxisAlignment: CrossAxisAlignment.start, game: game,
children: [ onGameUpdated: (game) async {
Expanded( game = await GameRepository.upsert(game);
child: setState(() {
i < games.length games[game.name] = game;
? GameCard( });
game: games.values.elementAt(i), },
onGameUpdated: (game) async { onDelete: () async {
game = await GameRepository.upsert(game); await GameRepository.delete(game);
setState(() { setState(() {
games[game.name] = game; games.remove(game.name);
}); });
}, },
onDelete: () async {
await GameRepository.delete(
games.values.elementAt(i),
);
setState(() {
games.remove(
games.values.elementAt(i).name,
);
});
},
)
: NewGameCard(
onGameCreated: (game) async {
game = await GameRepository.upsert(game);
setState(() {
games[game.name] = game;
});
},
),
),
const SizedBox(width: 8),
Expanded(
child:
i + 1 < games.length
? GameCard(
game: games.values.elementAt(i + 1),
onGameUpdated: (game) async {
game = await GameRepository.upsert(game);
setState(() {
games[game.name] = game;
});
},
onDelete: () async {
await GameRepository.delete(
games.values.elementAt(i + 1),
);
setState(() {
games.remove(
games.values.elementAt(i + 1).name,
);
});
},
)
: const SizedBox(), // Empty space for odd number of items
),
],
), ),
), ),
),
SizedBox(
width: (MediaQuery.of(context).size.width - 24) / 2,
child: NewGameCard(
onGameCreated: (game) async {
game = await GameRepository.upsert(game);
setState(() {
games[game.name] = game;
});
},
),
),
], ],
), ),
), ),