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,19 +90,15 @@ 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: [
Expanded(
child:
i < games.length
? GameCard(
game: games.values.elementAt(i),
onGameUpdated: (game) async { onGameUpdated: (game) async {
game = await GameRepository.upsert(game); game = await GameRepository.upsert(game);
setState(() { setState(() {
@@ -110,17 +106,17 @@ class _MyHomePageState extends State<MyHomePage> {
}); });
}, },
onDelete: () async { onDelete: () async {
await GameRepository.delete( await GameRepository.delete(game);
games.values.elementAt(i),
);
setState(() { setState(() {
games.remove( games.remove(game.name);
games.values.elementAt(i).name,
);
}); });
}, },
) ),
: NewGameCard( ),
),
SizedBox(
width: (MediaQuery.of(context).size.width - 24) / 2,
child: NewGameCard(
onGameCreated: (game) async { onGameCreated: (game) async {
game = await GameRepository.upsert(game); game = await GameRepository.upsert(game);
setState(() { setState(() {
@@ -129,34 +125,6 @@ class _MyHomePageState extends State<MyHomePage> {
}, },
), ),
), ),
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
),
],
),
),
], ],
), ),
), ),