HomeView Mock-Daten entfernen #51

Merged
sneeex merged 7 commits from enhancement/46-homeview-mockdaten-entfernen into development 2025-11-23 18:19:54 +00:00
Showing only changes of commit 2616f7c113 - Show all commits

View File

@@ -138,29 +138,40 @@ class _HomeViewState extends State<HomeView> {
padding: const EdgeInsets.symmetric(horizontal: 40.0),
child: FutureBuilder(
future: _recentGamesFuture,
builder: (context, snapshot) {
builder:
(
BuildContext context,
AsyncSnapshot<List<Game>> snapshot,
) {
if (snapshot.hasError) {
return const Center(
heightFactor: 4,
child: Text('Error while loading recent games.'),
child: Text(
'Error while loading recent games.',
),
);
}
if (snapshot.connectionState ==
ConnectionState.done &&
(!snapshot.hasData || snapshot.data!.isEmpty)) {
(!snapshot.hasData ||
sneeex marked this conversation as resolved Outdated

Fehler taucht auf, wenn man die App startet. Könnte an dieser Zeile liegen. Ggf. die Skeleton Daten in der gleichen Variable wie die reelen Daten speichern und dann überhscreiben, wenn diese geladen sind

grafik.png

Fehler taucht auf, wenn man die App startet. Könnte an dieser Zeile liegen. Ggf. die Skeleton Daten in der gleichen Variable wie die reelen Daten speichern und dann überhscreiben, wenn diese geladen sind ![grafik.png](/attachments/c5f0c078-7338-480e-9c90-457afca0237c)
285 KiB
snapshot.data!.isEmpty)) {
return const Center(
heightFactor: 4,
child: Text('No recent games available.'),
);
}
final List<Game> games =
(isLoading ? skeletonData : (snapshot.data ?? [])
(isLoading
? skeletonData
: (snapshot.data ?? [])
..sort(
(a, b) =>
b.createdAt.compareTo(a.createdAt),
(a, b) => b.createdAt.compareTo(
a.createdAt,
),
))
.take(2)
.toList();
if (games.length > 0)
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -175,10 +186,12 @@ class _HomeViewState extends State<HomeView> {
: games[0].winner!.name,
),
const Padding(
sneeex marked this conversation as resolved Outdated

Lieber sowas wie Game in Progress oder so

Lieber sowas wie `Game in Progress` oder so
padding: EdgeInsets.symmetric(vertical: 8.0),
padding: EdgeInsets.symmetric(
vertical: 8.0,
),
child: Divider(),
),
if (games.length >= 2) ...[
if (games.length > 1) ...[
GameTile(
gameTitle: games[1].name,
gameType: 'Winner',
@@ -192,11 +205,18 @@ class _HomeViewState extends State<HomeView> {
] else ...[
const Center(
heightFactor: 4,
child: Text('No second game available.'),
child: Text(
'No second game available.',
),
),
],
],
);
else
return const Center(
heightFactor: 4,
child: Text('No recent games available.'),
);
},
),
),