added: verrify if source exist before reading manga or watching anime
This commit is contained in:
parent
1bc92f530d
commit
7193f4e9e5
6 changed files with 91 additions and 33 deletions
|
|
@ -90,7 +90,7 @@ class ExtensionDetail extends ConsumerWidget {
|
|||
title: Text(
|
||||
source.name!,
|
||||
),
|
||||
content: Text("Uninstall ${source.name} extension ?"),
|
||||
content: Text(l10n.uninstall_extension(source.name!)),
|
||||
actions: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
|
|
@ -105,8 +105,12 @@ class ExtensionDetail extends ConsumerWidget {
|
|||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
isar.writeTxnSync(() =>
|
||||
isar.sources.deleteSync(source.id!));
|
||||
isar.writeTxnSync(
|
||||
() => isar.sources.putSync(source
|
||||
..sourceCode = ""
|
||||
..isAdded = false
|
||||
..isPinned = false
|
||||
..isNsfw = false));
|
||||
Navigator.pop(ctx);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
|
|
@ -118,7 +122,7 @@ class ExtensionDetail extends ConsumerWidget {
|
|||
});
|
||||
// if (res != null && res == true) {}
|
||||
},
|
||||
child: const Text("Uninstall"))
|
||||
child: Text(l10n.uninstall))
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/source.dart';
|
||||
import 'package:mangayomi/modules/manga/detail/manga_details_view.dart';
|
||||
import 'package:mangayomi/modules/manga/detail/providers/update_manga_detail_providers.dart';
|
||||
import 'package:mangayomi/modules/manga/detail/providers/isar_providers.dart';
|
||||
|
|
@ -41,29 +44,45 @@ class _MangaReaderDetailState extends ConsumerState<MangaReaderDetail> {
|
|||
return Scaffold(
|
||||
body: manga.when(
|
||||
data: (manga) {
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await ref.read(
|
||||
updateMangaDetailProvider(mangaId: manga.id, isInit: false)
|
||||
.future);
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
MangaDetailsView(
|
||||
manga: manga!,
|
||||
),
|
||||
if (_isLoading)
|
||||
const Positioned(
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
return StreamBuilder(
|
||||
stream: isar.sources
|
||||
.filter()
|
||||
.langContains(manga!.lang!, caseSensitive: false)
|
||||
.and()
|
||||
.nameContains(manga.source!, caseSensitive: false)
|
||||
.and()
|
||||
.idIsNotNull()
|
||||
.and()
|
||||
.isActiveEqualTo(true)
|
||||
.and()
|
||||
.isAddedEqualTo(true)
|
||||
.watch(fireImmediately: true),
|
||||
builder: (context, snapshot) {
|
||||
final sourceExist = snapshot.hasData && snapshot.data!.isNotEmpty;
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
if (sourceExist) {
|
||||
await ref.read(updateMangaDetailProvider(
|
||||
mangaId: manga.id, isInit: false)
|
||||
.future);
|
||||
}
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
MangaDetailsView(manga: manga, sourceExist: sourceExist),
|
||||
if (_isLoading)
|
||||
const Positioned(
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
error: (Object error, StackTrace stackTrace) {
|
||||
return ErrorText(error);
|
||||
|
|
|
|||
|
|
@ -49,12 +49,14 @@ class MangaDetailView extends ConsumerStatefulWidget {
|
|||
final List<Color>? backButtonColors;
|
||||
final Widget? action;
|
||||
final Manga? manga;
|
||||
final bool sourceExist;
|
||||
const MangaDetailView({
|
||||
super.key,
|
||||
required this.isExtended,
|
||||
this.titleDescription,
|
||||
this.backButtonColors,
|
||||
this.action,
|
||||
required this.sourceExist,
|
||||
required this.manga,
|
||||
});
|
||||
|
||||
|
|
@ -510,6 +512,7 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
return ChapterListTileWidget(
|
||||
chapter: chapters[indexx],
|
||||
chapterList: chapterList,
|
||||
sourceExist: widget.sourceExist,
|
||||
);
|
||||
})),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ import 'package:mangayomi/modules/widgets/progress_center.dart';
|
|||
|
||||
class MangaDetailsView extends ConsumerStatefulWidget {
|
||||
final Manga manga;
|
||||
final bool sourceExist;
|
||||
const MangaDetailsView({
|
||||
super.key,
|
||||
required this.sourceExist,
|
||||
required this.manga,
|
||||
});
|
||||
|
||||
|
|
@ -119,7 +121,16 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
Text(getMangaStatusName(widget.manga.status, context)),
|
||||
const Text(' • '),
|
||||
Text(widget.manga.source!),
|
||||
Text(' (${widget.manga.lang!.toUpperCase()})')
|
||||
Text(' (${widget.manga.lang!.toUpperCase()})'),
|
||||
if (!widget.sourceExist)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(3),
|
||||
child: Icon(
|
||||
Icons.warning_amber,
|
||||
color: Colors.deepOrangeAccent,
|
||||
size: 14,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
@ -202,6 +213,7 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
isExtended: (value) {
|
||||
ref.read(isExtendedStateProvider.notifier).update(value);
|
||||
},
|
||||
sourceExist: widget.sourceExist,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,11 @@ import 'package:mangayomi/modules/manga/download/download_page_widget.dart';
|
|||
class ChapterListTileWidget extends ConsumerWidget {
|
||||
final Chapter chapter;
|
||||
final List<Chapter> chapterList;
|
||||
final bool sourceExist;
|
||||
const ChapterListTileWidget({
|
||||
required this.chapterList,
|
||||
required this.chapter,
|
||||
required this.sourceExist,
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
|
@ -123,7 +125,7 @@ class ChapterListTileWidget extends ConsumerWidget {
|
|||
)
|
||||
],
|
||||
),
|
||||
trailing: chapter.manga.value!.isLocalArchive ?? false
|
||||
trailing: !sourceExist || (chapter.manga.value!.isLocalArchive ?? false)
|
||||
? null
|
||||
: ChapterPageDownload(chapter: chapter),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,15 +1,33 @@
|
|||
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';
|
||||
|
||||
pushMangaReaderView({
|
||||
required BuildContext context,
|
||||
required Chapter chapter,
|
||||
}) {
|
||||
if (chapter.manga.value!.isManga!) {
|
||||
context.push('/mangareaderview', extra: chapter);
|
||||
} else {
|
||||
context.push('/animestreamview', extra: 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) {
|
||||
if (chapter.manga.value!.isManga!) {
|
||||
context.push('/mangareaderview', extra: chapter);
|
||||
} else {
|
||||
context.push('/animestreamview', extra: chapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue