Add background images for games
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:gamer_updater/db.dart';
|
||||
import 'package:gamer_updater/utils.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:typed_data';
|
||||
|
||||
class Game {
|
||||
final String name;
|
||||
@@ -10,6 +11,7 @@ class Game {
|
||||
String actualVersion;
|
||||
String lastUpdated;
|
||||
final String rssFeedUrl;
|
||||
final Uint8List? imageData;
|
||||
|
||||
Game({
|
||||
required this.name,
|
||||
@@ -18,6 +20,7 @@ class Game {
|
||||
this.actualVersion = '',
|
||||
required this.rssFeedUrl,
|
||||
this.lastUpdated = '',
|
||||
this.imageData,
|
||||
}) : _internalVersionRegex = RegExp(versionRegex);
|
||||
|
||||
factory Game.fromMap(Map<String, dynamic> map) {
|
||||
@@ -28,6 +31,7 @@ class Game {
|
||||
rssFeedUrl: map['rss_feed_url'],
|
||||
actualVersion: map['actual_version'],
|
||||
lastUpdated: map['last_updated'],
|
||||
imageData: map['image_data'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,10 +90,19 @@ last_updated = excluded.last_updated
|
||||
return game;
|
||||
}
|
||||
|
||||
static Future<Game> updateImage(Game game) async {
|
||||
final db = DB.db;
|
||||
await db.rawUpdate('UPDATE games SET image_data = ? WHERE name = ?', [
|
||||
game.imageData,
|
||||
game.name,
|
||||
]);
|
||||
return game;
|
||||
}
|
||||
|
||||
static Future<Map<String, Game>> getAll() async {
|
||||
final db = DB.db;
|
||||
final games = await db.rawQuery(
|
||||
'SELECT name, actual_version, last_played, rss_feed_url, version_regex, last_updated FROM games',
|
||||
'SELECT name, actual_version, last_played, rss_feed_url, version_regex, last_updated, image_data FROM games',
|
||||
);
|
||||
return games
|
||||
.map((e) => Game.fromMap(e))
|
||||
|
Reference in New Issue
Block a user