mangayomi/lib/modules/manga/reader/providers/push_router.dart
2023-12-21 17:17:06 +01:00

46 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:isar/isar.dart';
import 'package:mangayomi/main.dart';
import 'package:mangayomi/models/chapter.dart';
import 'package:mangayomi/models/source.dart';
import 'package:mangayomi/sources/source_test.dart';
pushMangaReaderView({
required BuildContext context,
required Chapter chapter,
}) {
final sourceExist = isar.sources
.filter()
.langContains(chapter.manga.value!.lang!, caseSensitive: false)
.and()
.nameContains(chapter.manga.value!.source!, caseSensitive: false)
.and()
.idIsNotNull()
.and()
.isActiveEqualTo(true)
.and()
.isAddedEqualTo(true)
.findAllSync()
.isNotEmpty;
if (sourceExist ||
useTestSourceCode ||
chapter.manga.value!.isLocalArchive!) {
if (chapter.manga.value!.isManga!) {
context.push('/mangareaderview', extra: chapter);
} else {
context.push('/animePlayerView', extra: chapter);
}
}
}
pushReplacementMangaReaderView({
required BuildContext context,
required Chapter chapter,
}) {
if (chapter.manga.value!.isManga!) {
context.pushReplacement('/mangareaderview', extra: chapter);
} else {
context.pushReplacement('/animePlayerView', extra: chapter);
}
}