Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
336cb87a06 | |||
795060a05b | |||
bbd3583939 | |||
1c1ac3385b |
57
README.md
57
README.md
@@ -1,16 +1,53 @@
|
||||
# gamer_updater
|
||||
# Gamer Updater
|
||||
|
||||
A new Flutter project.
|
||||
A Flutter application for tracking game version updates via RSS feeds.<br>
|
||||
The idea is to track updates to games you might have previously played<br>
|
||||
To simply know how much you might be missing and whether you would have new content to look forward to
|
||||
|
||||
## Getting Started
|
||||

|
||||
|
||||
This project is a starting point for a Flutter application.
|
||||
## Features
|
||||
|
||||
A few resources to get you started if this is your first Flutter project:
|
||||
- Game version tracking
|
||||
- Automatic version checking through RSS feeds
|
||||
- Last played date tracking
|
||||
- Custom version regex patterns
|
||||
- Thumbnails!
|
||||
|
||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
||||
## Setup
|
||||
|
||||
For help getting started with Flutter development, view the
|
||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
1. Clone repository
|
||||
2. Install Flutter
|
||||
3. Run `flutter pub get`
|
||||
4. Run `flutter run`
|
||||
|
||||
## Usage
|
||||
|
||||
Add games by providing:
|
||||
- Name
|
||||
- RSS feed URL
|
||||
- Version regex pattern
|
||||
- Optional game image
|
||||
|
||||
## Example
|
||||
|
||||
If we wanted to track the versions of Rimworld we would enter the rss feed as:
|
||||
https://store.steampowered.com/feeds/news/app/294100/?cc=HR&l=english
|
||||
|
||||
And the version regex pattern as:
|
||||
`Update (\d+\.\d+\.\d+)`
|
||||
|
||||
Seeing as their posts usually follow this convention:
|
||||
Update 1.5.4104 released
|
||||
...
|
||||
Update 1.4.3704 released
|
||||
|
||||
In theory the rss link can be any link at all and the version regex can be anything at all<br>
|
||||
The regex is simply ran on the entirety of the contents of the get request to the rss link<br>
|
||||
Which means we can also simply search html<br>
|
||||
But it is not as reliable as the rss because of all the additional shit
|
||||
|
||||
Currently the thumbnails must be manually added
|
||||
|
||||
They can also be any image at all but the cards are designed to fit the thumbnails from the game update pages:
|
||||

|
||||
|
BIN
git_static/screenshot.jpg
Normal file
BIN
git_static/screenshot.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 299 KiB |
BIN
git_static/thumbnails.png
Normal file
BIN
git_static/thumbnails.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 662 KiB |
@@ -55,10 +55,17 @@ class Game {
|
||||
throw Exception('No version found for $name');
|
||||
}
|
||||
actualVersion = version;
|
||||
try {
|
||||
// Some sites use weird ass dogshit fucking formats
|
||||
// We cannot really reliably parse every single one of them
|
||||
// So - fuck it
|
||||
lastUpdated =
|
||||
parseRfc822Date(
|
||||
response.headers['last-modified'] ?? '',
|
||||
).toIso8601String();
|
||||
} catch (e) {
|
||||
lastUpdated = DateTime.now().toIso8601String();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +109,7 @@ last_updated = excluded.last_updated
|
||||
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, 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
|
||||
.map((e) => Game.fromMap(e))
|
||||
|
130
lib/main.dart
130
lib/main.dart
@@ -3,6 +3,7 @@ import 'package:gamer_updater/db.dart';
|
||||
import 'package:gamer_updater/game.dart';
|
||||
import 'package:gamer_updater/widgets/new_game_card.dart';
|
||||
import 'package:gamer_updater/widgets/game_card.dart';
|
||||
import 'dart:async';
|
||||
|
||||
void main() async {
|
||||
await DB.init();
|
||||
@@ -54,6 +55,9 @@ class MyHomePage extends StatefulWidget {
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
late Map<String, Game> games = {};
|
||||
String searchQuery = "";
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
Timer? _debounce;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -61,13 +65,20 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
_refreshGames();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
_debounce?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _refreshGames() async {
|
||||
final games = await GameRepository.getAll();
|
||||
games.forEach((key, game) {
|
||||
game.updateActualVersion().then((_) {
|
||||
GameRepository.upsert(game);
|
||||
setState(() {
|
||||
games[game.name] = game;
|
||||
this.games[game.name] = game;
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -76,6 +87,24 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
});
|
||||
}
|
||||
|
||||
List<Game> get filteredGames {
|
||||
if (searchQuery.isEmpty) {
|
||||
return games.values.toList();
|
||||
}
|
||||
return games.values.where((game) =>
|
||||
game.name.toLowerCase().contains(searchQuery.toLowerCase())
|
||||
).toList();
|
||||
}
|
||||
|
||||
void _onSearchChanged(String value) {
|
||||
if (_debounce?.isActive ?? false) _debounce!.cancel();
|
||||
_debounce = Timer(const Duration(milliseconds: 100), () {
|
||||
setState(() {
|
||||
searchQuery = value;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -86,23 +115,49 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
IconButton(icon: const Icon(Icons.refresh), onPressed: _refreshGames),
|
||||
],
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
body: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Search games...',
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
suffixIcon: searchQuery.isNotEmpty
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
_searchController.clear();
|
||||
setState(() {
|
||||
searchQuery = "";
|
||||
});
|
||||
},
|
||||
)
|
||||
: null,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
onChanged: _onSearchChanged,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: _refreshGames,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
for (var i = 0; i < games.length + 1; i += 2)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child:
|
||||
i < games.length
|
||||
? GameCard(
|
||||
game: games.values.elementAt(i),
|
||||
...filteredGames.map(
|
||||
(game) => SizedBox(
|
||||
key: ValueKey(game.name),
|
||||
width: (MediaQuery.of(context).size.width - 24) / 2,
|
||||
child: GameCard(
|
||||
key: ValueKey('card_${game.name}'),
|
||||
game: game,
|
||||
onGameUpdated: (game) async {
|
||||
game = await GameRepository.upsert(game);
|
||||
setState(() {
|
||||
@@ -110,17 +165,17 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
});
|
||||
},
|
||||
onDelete: () async {
|
||||
await GameRepository.delete(
|
||||
games.values.elementAt(i),
|
||||
);
|
||||
await GameRepository.delete(game);
|
||||
setState(() {
|
||||
games.remove(
|
||||
games.values.elementAt(i).name,
|
||||
);
|
||||
games.remove(game.name);
|
||||
});
|
||||
},
|
||||
)
|
||||
: NewGameCard(
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: (MediaQuery.of(context).size.width - 24) / 2,
|
||||
child: NewGameCard(
|
||||
onGameCreated: (game) async {
|
||||
game = await GameRepository.upsert(game);
|
||||
setState(() {
|
||||
@@ -129,38 +184,13 @@ 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