mirror of
https://github.com/lichess-org/mobile.git
synced 2026-05-26 13:50:52 +00:00
improve pgn loading speeds (#3188)
This commit is contained in:
@@ -24,9 +24,9 @@ typedef _GameData = ({
|
||||
class PgnGamesListScreen extends StatefulWidget {
|
||||
const PgnGamesListScreen({required this.games, super.key});
|
||||
|
||||
final IList<PgnGame> games;
|
||||
final IList<PgnLazyGame> games;
|
||||
|
||||
static Route<dynamic> buildRoute(IList<PgnGame> games) {
|
||||
static Route<dynamic> buildRoute(IList<PgnLazyGame> games) {
|
||||
return buildScreenRoute(screen: PgnGamesListScreen(games: games));
|
||||
}
|
||||
|
||||
@@ -113,22 +113,22 @@ class _PgnGamesListScreenState extends State<PgnGamesListScreen> {
|
||||
separatorBuilder: (context, index) =>
|
||||
const Divider(height: 1, thickness: 1, indent: 16, endIndent: 16),
|
||||
itemBuilder: (context, index) {
|
||||
final game = widget.games[filteredIndices[index]];
|
||||
final gameData = _gameData[filteredIndices[index]];
|
||||
return ListTile(
|
||||
title: Text(gameData.title, maxLines: 2, overflow: .ellipsis),
|
||||
subtitle: Text(gameData.subtitle, overflow: .ellipsis, maxLines: 1),
|
||||
onTap: () {
|
||||
final game = widget.games[filteredIndices[index]];
|
||||
Navigator.of(context, rootNavigator: true).push(
|
||||
AnalysisScreen.buildRoute(
|
||||
AnalysisOptions.pgn(
|
||||
// TODO generate unique id for each game, maybe based on the PGN headers?
|
||||
id: const StringId('pgn_import_game'),
|
||||
orientation: .white,
|
||||
pgn: game.makePgn(),
|
||||
pgn: game.rawPgn,
|
||||
variant: gameData.variant,
|
||||
isComputerAnalysisAllowed: true,
|
||||
initialMoveCursor: game.moves.mainline().isEmpty ? 0 : 1,
|
||||
initialMoveCursor: 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -148,7 +148,7 @@ bool _matchesSearchQuery(_GameData gameData, String query) {
|
||||
gameData.subtitle.toLowerCase().contains(lowerQuery);
|
||||
}
|
||||
|
||||
String _buildGameSubtitle(PgnGame game) {
|
||||
String _buildGameSubtitle(PgnLazyGame game) {
|
||||
final event = game.headers['Event'];
|
||||
final round = game.headers['Round'];
|
||||
final site = game.headers['Site'];
|
||||
|
||||
@@ -31,7 +31,7 @@ class ImportPgnScreen extends StatelessWidget {
|
||||
|
||||
static void handlePgnText(BuildContext context, String text) {
|
||||
try {
|
||||
final games = PgnGame.parseMultiGamePgn(text);
|
||||
final games = PgnGame.parseMultiGameLazy(text);
|
||||
|
||||
if (games.isEmpty) {
|
||||
showSnackBar(context, context.l10n.invalidPgn, type: .error);
|
||||
@@ -49,7 +49,7 @@ class ImportPgnScreen extends StatelessWidget {
|
||||
orientation: .white,
|
||||
pgn: text,
|
||||
isComputerAnalysisAllowed: true,
|
||||
initialMoveCursor: game.moves.mainline().isEmpty ? 0 : 1,
|
||||
initialMoveCursor: 1,
|
||||
variant: rule != null ? Variant.fromRule(rule) : .standard,
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user