83 lines
2.0 KiB
Dart
83 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:gamer_updater/db.dart';
|
|
import 'package:gamer_updater/game.dart';
|
|
|
|
void main() async {
|
|
await DB.init();
|
|
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Gamer Updater',
|
|
theme: ThemeData(
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
),
|
|
darkTheme: ThemeData(
|
|
brightness: Brightness.dark,
|
|
useMaterial3: true,
|
|
scaffoldBackgroundColor: Colors.black,
|
|
colorSchemeSeed: Colors.black,
|
|
highlightColor: Colors.deepPurple,
|
|
textTheme: TextTheme(
|
|
bodyLarge: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
|
|
bodyMedium: TextStyle(fontSize: 20),
|
|
bodySmall: TextStyle(fontSize: 16),
|
|
),
|
|
),
|
|
themeMode: ThemeMode.system,
|
|
home: const MyHomePage(title: 'Gamer Updater'),
|
|
);
|
|
}
|
|
}
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
const MyHomePage({super.key, required this.title});
|
|
final String title;
|
|
|
|
@override
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
}
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
|
late List<Game> games = [];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
GameRepository.getAll().then((games) {
|
|
setState(() {
|
|
this.games = games;
|
|
});
|
|
for (var e in games) {
|
|
e.updateActualVersion();
|
|
GameRepository.upsert(e);
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
title: Text(widget.title),
|
|
),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Text(games.map((e) => e.name).join('\n')),
|
|
Text(games.map((e) => e.actualVersion).join('\n')),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|