feat: Added button for download next n chapters

This commit is contained in:
kodjomoustapha 2024-02-08 17:18:59 +01:00
parent bdf6ce6a9b
commit fc2e80f31e
14 changed files with 173 additions and 25 deletions

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "مهلة زر", "aniskip_button_timeout": "مهلة زر",
"fullscreen": "شاشة كاملة", "fullscreen": "شاشة كاملة",
"update_library": "تحديث المكتبة", "update_library": "تحديث المكتبة",
"updating_library": "جاري تحديث المكتبة" "updating_library": "جاري تحديث المكتبة",
"next_chapter": "الفصل التالي",
"next_5_chapters": "الفصول الخمسة التالية",
"next_10_chapters": "الفصول العشرة التالية",
"next_25_chapters": "الفصول الخمسة والعشرون التالية"
} }

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "Timeout für Taste", "aniskip_button_timeout": "Timeout für Taste",
"fullscreen": "Vollbild", "fullscreen": "Vollbild",
"update_library": "Bibliothek aktualisieren", "update_library": "Bibliothek aktualisieren",
"updating_library": "Bibliothek wird aktualisiert" "updating_library": "Bibliothek wird aktualisiert",
"next_chapter": "Nächstes Kapitel",
"next_5_chapters": "Nächsten 5 Kapitel",
"next_10_chapters": "Nächsten 10 Kapitel",
"next_25_chapters": "Nächsten 25 Kapitel"
} }

View file

@ -285,5 +285,9 @@
"skip_ending": "Skip ending", "skip_ending": "Skip ending",
"fullscreen": "Fullscreen", "fullscreen": "Fullscreen",
"update_library": "Update library", "update_library": "Update library",
"updating_library": "Updating library" "updating_library": "Updating library",
"next_chapter": "Next chapter",
"next_5_chapters": "Next 5 chapters",
"next_10_chapters": "Next 10 chapters",
"next_25_chapters": "Next 25 chapters"
} }

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "Tiempo de espera del botón", "aniskip_button_timeout": "Tiempo de espera del botón",
"fullscreen": "Pantalla completa", "fullscreen": "Pantalla completa",
"update_library": "Actualizar biblioteca", "update_library": "Actualizar biblioteca",
"updating_library": "Actualizando biblioteca" "updating_library": "Actualizando biblioteca",
"next_chapter": "Próximo capítulo",
"next_5_chapters": "Próximos 5 capítulos",
"next_10_chapters": "Próximos 10 capítulos",
"next_25_chapters": "Próximos 25 capítulos"
} }

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "Tiempo de espera del botón", "aniskip_button_timeout": "Tiempo de espera del botón",
"fullscreen": "Pantalla completa", "fullscreen": "Pantalla completa",
"update_library": "Actualizar biblioteca", "update_library": "Actualizar biblioteca",
"updating_library": "Actualizando biblioteca" "updating_library": "Actualizando biblioteca",
"next_chapter": "Siguiente capítulo",
"next_5_chapters": "Siguientes 5 capítulos",
"next_10_chapters": "Siguientes 10 capítulos",
"next_25_chapters": "Siguientes 25 capítulos"
} }

View file

@ -284,5 +284,9 @@
"skip_opening": "Passer l'opening", "skip_opening": "Passer l'opening",
"skip_ending": "Passer l'ending", "skip_ending": "Passer l'ending",
"update_library": "Mettre à jour la bibliothèque", "update_library": "Mettre à jour la bibliothèque",
"updating_library": "Mise à jour de la bibliothèque" "updating_library": "Mise à jour de la bibliothèque",
"next_chapter": "Chapitre suivant",
"next_5_chapters": "5 chapitres suivants",
"next_10_chapters": "10 chapitres suivants",
"next_25_chapters": "25 chapitres suivants"
} }

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "Timeout tombol", "aniskip_button_timeout": "Timeout tombol",
"fullscreen": "Layar Penuh", "fullscreen": "Layar Penuh",
"update_library": "Perbarui perpustakaan", "update_library": "Perbarui perpustakaan",
"updating_library": "Memperbarui perpustakaan" "updating_library": "Memperbarui perpustakaan",
"next_chapter": "Berikutnya bab",
"next_5_chapters": "5 bab berikutnya",
"next_10_chapters": "10 bab berikutnya",
"next_25_chapters": "25 bab berikutnya"
} }

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "Timeout del pulsante", "aniskip_button_timeout": "Timeout del pulsante",
"fullscreen": "Schermo intero", "fullscreen": "Schermo intero",
"update_library": "Aggiorna libreria", "update_library": "Aggiorna libreria",
"updating_library": "Aggiornamento della libreria" "updating_library": "Aggiornamento della libreria",
"next_chapter": "Capitolo successivo",
"next_5_chapters": "Prossimi 5 capitoli",
"next_10_chapters": "Prossimi 10 capitoli",
"next_25_chapters": "Prossimi 25 capitoli"
} }

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "Tempo limite do botão", "aniskip_button_timeout": "Tempo limite do botão",
"fullscreen": "Tela cheia", "fullscreen": "Tela cheia",
"update_library": "Atualizar biblioteca", "update_library": "Atualizar biblioteca",
"updating_library": "Atualizando biblioteca" "updating_library": "Atualizando biblioteca",
"next_chapter": "Próximo capítulo",
"next_5_chapters": "Próximos 5 capítulos",
"next_10_chapters": "Próximos 10 capítulos",
"next_25_chapters": "Próximos 25 capítulos"
} }

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "Timeout do botão", "aniskip_button_timeout": "Timeout do botão",
"fullscreen": "Tela cheia", "fullscreen": "Tela cheia",
"update_library": "Atualizar biblioteca", "update_library": "Atualizar biblioteca",
"updating_library": "Atualizando biblioteca" "updating_library": "Atualizando biblioteca",
"next_chapter": "Próximo capítulo",
"next_5_chapters": "Próximos 5 capítulos",
"next_10_chapters": "Próximos 10 capítulos",
"next_25_chapters": "Próximos 25 capítulos"
} }

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "Тайм-аут кнопки", "aniskip_button_timeout": "Тайм-аут кнопки",
"fullscreen": "Полноэкранный режим", "fullscreen": "Полноэкранный режим",
"update_library": "Обновить библиотеку", "update_library": "Обновить библиотеку",
"updating_library": "Обновление библиотеки" "updating_library": "Обновление библиотеки",
"next_chapter": "Следующая глава",
"next_5_chapters": "Следующие 5 глав",
"next_10_chapters": "Следующие 10 глав",
"next_25_chapters": "Следующие 25 глав"
} }

View file

@ -283,5 +283,9 @@
"aniskip_button_timeout": "Düğme Zaman Aşımı", "aniskip_button_timeout": "Düğme Zaman Aşımı",
"fullscreen": "Tam ekran", "fullscreen": "Tam ekran",
"update_library": "Kütüphaneyi güncelle", "update_library": "Kütüphaneyi güncelle",
"updating_library": "Kütüphaneyi güncelleme" "updating_library": "Kütüphaneyi güncelleme",
"next_chapter": "Sonraki bölüm",
"next_5_chapters": "Sonraki 5 bölüm",
"next_10_chapters": "Sonraki 10 bölüm",
"next_25_chapters": "Sonraki 25 bölüm"
} }

View file

@ -285,5 +285,9 @@
"skip_ending": "跳过结尾", "skip_ending": "跳过结尾",
"fullscreen": "全屏", "fullscreen": "全屏",
"update_library": "更新库", "update_library": "更新库",
"updating_library": "正在更新库" "updating_library": "正在更新库",
"next_chapter": "下一章",
"next_5_chapters": "下5章",
"next_10_chapters": "下10章",
"next_25_chapters": "下25章"
} }

View file

@ -361,15 +361,109 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
? Colors.transparent ? Colors.transparent
: Theme.of(context).scaffoldBackgroundColor, : Theme.of(context).scaffoldBackgroundColor,
actions: [ actions: [
if (!isLocalArchive) if (!isLocalArchive) ...[
IconButton( PopupMenuButton(
splashRadius: 20, icon: const Icon(Icons.download_outlined),
onPressed: () { itemBuilder: (context) {
widget.checkForUpdate(true); return [
PopupMenuItem<int>(
value: 0,
child: Text(
context.l10n.next_chapter)),
PopupMenuItem<int>(
value: 1,
child: Text(
context.l10n.next_5_chapters)),
PopupMenuItem<int>(
value: 2,
child: Text(
context.l10n.next_10_chapters)),
PopupMenuItem<int>(
value: 3,
child: Text(
context.l10n.next_25_chapters)),
PopupMenuItem<int>(
value: 4,
child: Text(context.l10n.unread)),
];
}, },
icon: const Icon( onSelected: (value) {
Icons.refresh, final chapters = isar.chapters
)), .filter()
.idIsNotNull()
.mangaIdEqualTo(widget.manga!.id!)
.findAllSync();
if (value == 0 ||
value == 1 ||
value == 2 ||
value == 3) {
final lastChapterReadIndex =
chapters.lastIndexWhere((element) =>
element.isRead == true);
if (lastChapterReadIndex == -1 ||
chapters.length == 1) {
final chapter = chapters.first;
final entry = isar.downloads
.filter()
.idIsNotNull()
.chapterIdEqualTo(chapter.id)
.findFirstSync();
if (entry == null ||
!entry.isDownload!) {
ref.watch(downloadChapterProvider(
chapter: chapter));
}
} else {
final length = switch (value) {
0 => 1,
1 => 5,
2 => 10,
_ => 25,
};
for (var i = 1; i < length + 1; i++) {
if (chapters.length > 1 &&
chapters.elementAtOrNull(
lastChapterReadIndex +
i) !=
null) {
final chapter = chapters[
lastChapterReadIndex + i];
final entry = isar.downloads
.filter()
.idIsNotNull()
.chapterIdEqualTo(chapter.id)
.findFirstSync();
if (entry == null ||
!entry.isDownload!) {
ref.watch(
downloadChapterProvider(
chapter: chapter));
}
}
}
}
} else if (value == 4) {
final unreadChapters = isar.chapters
.filter()
.idIsNotNull()
.mangaIdEqualTo(widget.manga!.id!)
.isReadEqualTo(false)
.findAllSync();
for (var chapter in unreadChapters) {
final entry = isar.downloads
.filter()
.idIsNotNull()
.chapterIdEqualTo(chapter.id)
.findFirstSync();
if (entry == null ||
!entry.isDownload!) {
ref.watch(downloadChapterProvider(
chapter: chapter));
}
}
}
}),
],
IconButton( IconButton(
splashRadius: 20, splashRadius: 20,
onPressed: () { onPressed: () {
@ -382,19 +476,21 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
)), )),
PopupMenuButton(itemBuilder: (context) { PopupMenuButton(itemBuilder: (context) {
return [ return [
if (!isLocalArchive)
PopupMenuItem<int>(
value: 3, child: Text(l10n.refresh)),
if (widget.manga!.favorite!) if (widget.manga!.favorite!)
PopupMenuItem<int>( PopupMenuItem<int>(
value: 0, value: 0,
child: Text(l10n.edit_categories)), child: Text(l10n.edit_categories)),
// if (!isLocalArchive)
// if (widget.manga!.favorite!)
// PopupMenuItem<int>(
// value: 1, child: Text(l10n.migrate)),
if (!isLocalArchive) if (!isLocalArchive)
PopupMenuItem<int>( PopupMenuItem<int>(
value: 2, child: Text(l10n.share)), value: 2, child: Text(l10n.share)),
]; ];
}, onSelected: (value) { }, onSelected: (value) {
if (value == 3) {
widget.checkForUpdate(true);
}
if (value == 0) { if (value == 0) {
context.push("/categories", extra: ( context.push("/categories", extra: (
true, true,