Compare commits
2 Commits
1c1ac3385b
...
795060a05b
Author | SHA1 | Date | |
---|---|---|---|
795060a05b | |||
bbd3583939 |
@@ -102,7 +102,7 @@ last_updated = excluded.last_updated
|
|||||||
static Future<Map<String, Game>> getAll() async {
|
static Future<Map<String, Game>> getAll() async {
|
||||||
final db = DB.db;
|
final db = DB.db;
|
||||||
final games = await db.rawQuery(
|
final games = await db.rawQuery(
|
||||||
'SELECT name, actual_version, last_played, rss_feed_url, version_regex, last_updated, image_data FROM games',
|
'SELECT name, actual_version, last_played, rss_feed_url, version_regex, last_updated, image_data FROM games ORDER BY name',
|
||||||
);
|
);
|
||||||
return games
|
return games
|
||||||
.map((e) => Game.fromMap(e))
|
.map((e) => Game.fromMap(e))
|
||||||
|
@@ -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
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user