Import formatting
This commit is contained in:
@@ -5,12 +5,10 @@ import 'package:game_tracker/data/dto/game.dart';
|
|||||||
import 'package:game_tracker/data/dto/group.dart';
|
import 'package:game_tracker/data/dto/group.dart';
|
||||||
import 'package:game_tracker/data/dto/player.dart';
|
import 'package:game_tracker/data/dto/player.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/create_group_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/create_group_view.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/tiles/game_history_tile.dart';
|
|
||||||
import 'package:game_tracker/presentation/views/main_menu/create_game/create_game_view.dart';
|
|
||||||
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
|
||||||
import 'package:game_tracker/presentation/widgets/top_centered_message.dart';
|
|
||||||
import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
|
import 'package:game_tracker/presentation/widgets/app_skeleton.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/tiles/game_history_tile.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/top_centered_message.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class GameHistoryView extends StatefulWidget {
|
class GameHistoryView extends StatefulWidget {
|
||||||
@@ -40,9 +38,7 @@ class _GameHistoryViewState extends State<GameHistoryView> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
winner: Player(name: 'Skeleton Player 1'),
|
winner: Player(name: 'Skeleton Player 1'),
|
||||||
players: [
|
players: [Player(name: 'Skeleton Player 6')],
|
||||||
Player(name: 'Skeleton Player 6')
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -69,49 +65,53 @@ class _GameHistoryViewState extends State<GameHistoryView> {
|
|||||||
children: [
|
children: [
|
||||||
FutureBuilder<List<Game>>(
|
FutureBuilder<List<Game>>(
|
||||||
future: _gameListFuture,
|
future: _gameListFuture,
|
||||||
builder: (BuildContext context, AsyncSnapshot<List<Game>> snapshot) {
|
builder:
|
||||||
if (snapshot.hasError) {
|
(BuildContext context, AsyncSnapshot<List<Game>> snapshot) {
|
||||||
return const Center(
|
if (snapshot.hasError) {
|
||||||
child: TopCenteredMessage(
|
return const Center(
|
||||||
icon: Icons.report,
|
child: TopCenteredMessage(
|
||||||
title: 'Error',
|
icon: Icons.report,
|
||||||
message: 'Game data could not be loaded',
|
title: 'Error',
|
||||||
),
|
message: 'Game data could not be loaded',
|
||||||
);
|
),
|
||||||
}
|
);
|
||||||
if (snapshot.connectionState == ConnectionState.done &&
|
}
|
||||||
(!snapshot.hasData || snapshot.data!.isEmpty)) {
|
if (snapshot.connectionState == ConnectionState.done &&
|
||||||
return const Center(
|
(!snapshot.hasData || snapshot.data!.isEmpty)) {
|
||||||
child: TopCenteredMessage(
|
return const Center(
|
||||||
icon: Icons.report,
|
child: TopCenteredMessage(
|
||||||
title: 'Error',
|
icon: Icons.report,
|
||||||
message: 'No Games Available',
|
title: 'Error',
|
||||||
),
|
message: 'No Games Available',
|
||||||
);
|
),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final List<Game> games = (isLoading
|
final List<Game> games =
|
||||||
? skeletonData
|
(isLoading ? skeletonData : (snapshot.data ?? [])
|
||||||
: (snapshot.data ?? [])
|
..sort(
|
||||||
..sort((a, b) => b.createdAt.compareTo(a.createdAt)))
|
(a, b) => b.createdAt.compareTo(a.createdAt),
|
||||||
.toList();
|
))
|
||||||
|
.toList();
|
||||||
|
|
||||||
return AppSkeleton(
|
return AppSkeleton(
|
||||||
enabled: isLoading,
|
enabled: isLoading,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
padding: const EdgeInsets.only(bottom: 85),
|
padding: const EdgeInsets.only(bottom: 85),
|
||||||
itemCount: games.length + 1,
|
itemCount: games.length + 1,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
if (index == games.length) {
|
if (index == games.length) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: MediaQuery.paddingOf(context).bottom - 80,
|
height: MediaQuery.paddingOf(context).bottom - 80,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return GameHistoryTile(game: games[index]); // Placeholder
|
return GameHistoryTile(
|
||||||
},
|
game: games[index],
|
||||||
),
|
); // Placeholder
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: MediaQuery.paddingOf(context).bottom,
|
bottom: MediaQuery.paddingOf(context).bottom,
|
||||||
@@ -137,4 +137,4 @@ class _GameHistoryViewState extends State<GameHistoryView> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user