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(
|
title: Text(
|
||||||
source.name!,
|
source.name!,
|
||||||
),
|
),
|
||||||
content: Text("Uninstall ${source.name} extension ?"),
|
content: Text(l10n.uninstall_extension(source.name!)),
|
||||||
actions: [
|
actions: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
|
@ -105,8 +105,12 @@ class ExtensionDetail extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
isar.writeTxnSync(() =>
|
isar.writeTxnSync(
|
||||||
isar.sources.deleteSync(source.id!));
|
() => isar.sources.putSync(source
|
||||||
|
..sourceCode = ""
|
||||||
|
..isAdded = false
|
||||||
|
..isPinned = false
|
||||||
|
..isNsfw = false));
|
||||||
Navigator.pop(ctx);
|
Navigator.pop(ctx);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
|
|
@ -118,7 +122,7 @@ class ExtensionDetail extends ConsumerWidget {
|
||||||
});
|
});
|
||||||
// if (res != null && res == true) {}
|
// 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/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.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/manga_details_view.dart';
|
||||||
import 'package:mangayomi/modules/manga/detail/providers/update_manga_detail_providers.dart';
|
import 'package:mangayomi/modules/manga/detail/providers/update_manga_detail_providers.dart';
|
||||||
import 'package:mangayomi/modules/manga/detail/providers/isar_providers.dart';
|
import 'package:mangayomi/modules/manga/detail/providers/isar_providers.dart';
|
||||||
|
|
@ -41,29 +44,45 @@ class _MangaReaderDetailState extends ConsumerState<MangaReaderDetail> {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: manga.when(
|
body: manga.when(
|
||||||
data: (manga) {
|
data: (manga) {
|
||||||
return RefreshIndicator(
|
return StreamBuilder(
|
||||||
onRefresh: () async {
|
stream: isar.sources
|
||||||
await ref.read(
|
.filter()
|
||||||
updateMangaDetailProvider(mangaId: manga.id, isInit: false)
|
.langContains(manga!.lang!, caseSensitive: false)
|
||||||
.future);
|
.and()
|
||||||
},
|
.nameContains(manga.source!, caseSensitive: false)
|
||||||
child: Stack(
|
.and()
|
||||||
children: [
|
.idIsNotNull()
|
||||||
MangaDetailsView(
|
.and()
|
||||||
manga: manga!,
|
.isActiveEqualTo(true)
|
||||||
),
|
.and()
|
||||||
if (_isLoading)
|
.isAddedEqualTo(true)
|
||||||
const Positioned(
|
.watch(fireImmediately: true),
|
||||||
top: 0,
|
builder: (context, snapshot) {
|
||||||
bottom: 0,
|
final sourceExist = snapshot.hasData && snapshot.data!.isNotEmpty;
|
||||||
left: 0,
|
return RefreshIndicator(
|
||||||
right: 0,
|
onRefresh: () async {
|
||||||
child: Center(
|
if (sourceExist) {
|
||||||
child: CircularProgressIndicator(),
|
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) {
|
error: (Object error, StackTrace stackTrace) {
|
||||||
return ErrorText(error);
|
return ErrorText(error);
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,14 @@ class MangaDetailView extends ConsumerStatefulWidget {
|
||||||
final List<Color>? backButtonColors;
|
final List<Color>? backButtonColors;
|
||||||
final Widget? action;
|
final Widget? action;
|
||||||
final Manga? manga;
|
final Manga? manga;
|
||||||
|
final bool sourceExist;
|
||||||
const MangaDetailView({
|
const MangaDetailView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.isExtended,
|
required this.isExtended,
|
||||||
this.titleDescription,
|
this.titleDescription,
|
||||||
this.backButtonColors,
|
this.backButtonColors,
|
||||||
this.action,
|
this.action,
|
||||||
|
required this.sourceExist,
|
||||||
required this.manga,
|
required this.manga,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -510,6 +512,7 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
||||||
return ChapterListTileWidget(
|
return ChapterListTileWidget(
|
||||||
chapter: chapters[indexx],
|
chapter: chapters[indexx],
|
||||||
chapterList: chapterList,
|
chapterList: chapterList,
|
||||||
|
sourceExist: widget.sourceExist,
|
||||||
);
|
);
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,10 @@ import 'package:mangayomi/modules/widgets/progress_center.dart';
|
||||||
|
|
||||||
class MangaDetailsView extends ConsumerStatefulWidget {
|
class MangaDetailsView extends ConsumerStatefulWidget {
|
||||||
final Manga manga;
|
final Manga manga;
|
||||||
|
final bool sourceExist;
|
||||||
const MangaDetailsView({
|
const MangaDetailsView({
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.sourceExist,
|
||||||
required this.manga,
|
required this.manga,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -119,7 +121,16 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
||||||
Text(getMangaStatusName(widget.manga.status, context)),
|
Text(getMangaStatusName(widget.manga.status, context)),
|
||||||
const Text(' • '),
|
const Text(' • '),
|
||||||
Text(widget.manga.source!),
|
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) {
|
isExtended: (value) {
|
||||||
ref.read(isExtendedStateProvider.notifier).update(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 {
|
class ChapterListTileWidget extends ConsumerWidget {
|
||||||
final Chapter chapter;
|
final Chapter chapter;
|
||||||
final List<Chapter> chapterList;
|
final List<Chapter> chapterList;
|
||||||
|
final bool sourceExist;
|
||||||
const ChapterListTileWidget({
|
const ChapterListTileWidget({
|
||||||
required this.chapterList,
|
required this.chapterList,
|
||||||
required this.chapter,
|
required this.chapter,
|
||||||
|
required this.sourceExist,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -123,7 +125,7 @@ class ChapterListTileWidget extends ConsumerWidget {
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
trailing: chapter.manga.value!.isLocalArchive ?? false
|
trailing: !sourceExist || (chapter.manga.value!.isLocalArchive ?? false)
|
||||||
? null
|
? null
|
||||||
: ChapterPageDownload(chapter: chapter),
|
: ChapterPageDownload(chapter: chapter),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,33 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.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/chapter.dart';
|
||||||
|
import 'package:mangayomi/models/source.dart';
|
||||||
|
|
||||||
pushMangaReaderView({
|
pushMangaReaderView({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required Chapter chapter,
|
required Chapter chapter,
|
||||||
}) {
|
}) {
|
||||||
if (chapter.manga.value!.isManga!) {
|
final sourceExist = isar.sources
|
||||||
context.push('/mangareaderview', extra: chapter);
|
.filter()
|
||||||
} else {
|
.langContains(chapter.manga.value!.lang!, caseSensitive: false)
|
||||||
context.push('/animestreamview', extra: chapter);
|
.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