mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-19 18:12:04 +00:00
+
This commit is contained in:
parent
aa21f07b13
commit
f339e455f7
3 changed files with 125 additions and 5 deletions
|
|
@ -90,9 +90,28 @@ class ChapterListTileWidget extends ConsumerWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
subtitle: Text(
|
||||
chapters[finalIndex].dateUpload!,
|
||||
style: const TextStyle(fontSize: 11),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
Text(
|
||||
chapters[finalIndex].dateUpload!,
|
||||
style: const TextStyle(fontSize: 11),
|
||||
),
|
||||
if (chapters[finalIndex].lastPageRead.isNotEmpty &&
|
||||
chapters[finalIndex].lastPageRead != "1")
|
||||
Row(
|
||||
children: [
|
||||
const Text(' • '),
|
||||
Text(
|
||||
"Page ${chapters[finalIndex].lastPageRead}",
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isLight(context)
|
||||
? Colors.black.withOpacity(0.4)
|
||||
: Colors.white.withOpacity(0.3)),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
trailing: ref.watch(ChapterPageDownloadsProvider(
|
||||
index: reverse ? reverseIndex : finalIndex,
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ class _MangaChapterPageGalleryState
|
|||
late AnimationController _scaleAnimationController;
|
||||
late Animation<double> _animation;
|
||||
late int _currentIndex = widget.readerController.getPageIndex();
|
||||
late bool _isBookmarked = widget.readerController.getChapterBookmarked();
|
||||
@override
|
||||
void dispose() {
|
||||
_rebuildDetail.close();
|
||||
|
|
@ -171,6 +172,7 @@ class _MangaChapterPageGalleryState
|
|||
}
|
||||
}
|
||||
widget.readerController.setPageIndex(index);
|
||||
widget.readerController.setChapterPageLastRead(index);
|
||||
}
|
||||
|
||||
void _onAddButtonTapped(int index, bool isPrev, {bool isSlide = false}) {
|
||||
|
|
@ -256,6 +258,7 @@ class _MangaChapterPageGalleryState
|
|||
});
|
||||
}
|
||||
widget.readerController.setPageIndex(index);
|
||||
widget.readerController.setChapterPageLastRead(index);
|
||||
}
|
||||
|
||||
ReaderMode? _selectedValue;
|
||||
|
|
@ -373,11 +376,11 @@ class _MangaChapterPageGalleryState
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
height: _isView ? 90 : 0,
|
||||
height: _isView ? 80 : 0,
|
||||
curve: Curves.ease,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: PreferredSize(
|
||||
preferredSize: Size.fromHeight(_isView ? 90 : 0),
|
||||
preferredSize: Size.fromHeight(_isView ? 80 : 0),
|
||||
child: AppBar(
|
||||
leading: BackButton(
|
||||
color: Colors.white,
|
||||
|
|
@ -386,6 +389,7 @@ class _MangaChapterPageGalleryState
|
|||
},
|
||||
),
|
||||
title: ListTile(
|
||||
dense: true,
|
||||
title: SizedBox(
|
||||
width: mediaWidth(context, 0.7),
|
||||
child: Text(
|
||||
|
|
@ -408,6 +412,16 @@ class _MangaChapterPageGalleryState
|
|||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
widget.readerController.setChapterBookmarked();
|
||||
setState(() {
|
||||
_isBookmarked = !_isBookmarked;
|
||||
});
|
||||
},
|
||||
icon: Icon(_isBookmarked
|
||||
? Icons.bookmark
|
||||
: Icons.bookmark_border_outlined)),
|
||||
IconButton(
|
||||
onPressed: () {}, icon: const Icon(Icons.public)),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:mangayomi/models/manga_history.dart';
|
||||
import 'package:mangayomi/models/manga_reader.dart';
|
||||
import 'package:mangayomi/models/model_manga.dart';
|
||||
|
|
@ -108,6 +110,91 @@ class ReaderController extends _$ReaderController {
|
|||
}
|
||||
}
|
||||
|
||||
void setChapterPageLastRead(int pageIndex) {
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
List<ModelChapters> chap = [];
|
||||
for (var i = 0; i < getModelManga().chapters!.length; i++) {
|
||||
chap.add(ModelChapters(
|
||||
name: getModelManga().chapters![i].name,
|
||||
url: getModelManga().chapters![i].url,
|
||||
dateUpload: getModelManga().chapters![i].dateUpload,
|
||||
isBookmarked: getModelManga().chapters![i].isBookmarked,
|
||||
scanlator: getModelManga().chapters![i].scanlator,
|
||||
isRead: getModelManga().chapters![i].isRead,
|
||||
lastPageRead: getChapterIndex() == i
|
||||
? (pageIndex + 1).toString()
|
||||
: getModelManga().chapters![i].lastPageRead));
|
||||
}
|
||||
final model = ModelManga(
|
||||
imageUrl: getModelManga().imageUrl,
|
||||
name: getModelManga().name,
|
||||
genre: getModelManga().genre,
|
||||
author: getModelManga().author,
|
||||
description: getModelManga().description,
|
||||
status: getModelManga().status,
|
||||
favorite: getModelManga().favorite,
|
||||
link: getModelManga().link,
|
||||
source: getModelManga().source,
|
||||
lang: getModelManga().lang,
|
||||
dateAdded: getModelManga().dateAdded,
|
||||
lastUpdate: getModelManga().lastUpdate,
|
||||
chapters: chap,
|
||||
category: getModelManga().category,
|
||||
lastRead: getModelManga().lastRead);
|
||||
ref
|
||||
.watch(hiveBoxManga)
|
||||
.put('${getModelManga().lang}-${getModelManga().link}', model);
|
||||
}
|
||||
}
|
||||
|
||||
void setChapterBookmarked() {
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
final isBookmarked = getChapterBookmarked();
|
||||
List<ModelChapters> chap = [];
|
||||
for (var i = 0; i < getModelManga().chapters!.length; i++) {
|
||||
chap.add(ModelChapters(
|
||||
name: getModelManga().chapters![i].name,
|
||||
url: getModelManga().chapters![i].url,
|
||||
dateUpload: getModelManga().chapters![i].dateUpload,
|
||||
isBookmarked: getChapterIndex() == i
|
||||
? !isBookmarked
|
||||
: getModelManga().chapters![i].isBookmarked,
|
||||
scanlator: getModelManga().chapters![i].scanlator,
|
||||
isRead: getModelManga().chapters![i].isRead,
|
||||
lastPageRead: getModelManga().chapters![i].lastPageRead));
|
||||
}
|
||||
final model = ModelManga(
|
||||
imageUrl: getModelManga().imageUrl,
|
||||
name: getModelManga().name,
|
||||
genre: getModelManga().genre,
|
||||
author: getModelManga().author,
|
||||
description: getModelManga().description,
|
||||
status: getModelManga().status,
|
||||
favorite: getModelManga().favorite,
|
||||
link: getModelManga().link,
|
||||
source: getModelManga().source,
|
||||
lang: getModelManga().lang,
|
||||
dateAdded: getModelManga().dateAdded,
|
||||
lastUpdate: getModelManga().lastUpdate,
|
||||
chapters: chap,
|
||||
category: getModelManga().category,
|
||||
lastRead: getModelManga().lastRead);
|
||||
ref
|
||||
.watch(hiveBoxManga)
|
||||
.put('${getModelManga().lang}-${getModelManga().link}', model);
|
||||
}
|
||||
}
|
||||
|
||||
bool getChapterBookmarked() {
|
||||
return ref
|
||||
.watch(hiveBoxManga)
|
||||
.get('${getModelManga().lang}-${getModelManga().link}')!
|
||||
.chapters![getChapterIndex()]
|
||||
.isBookmarked;
|
||||
}
|
||||
|
||||
int getChapterIndex() {
|
||||
return mangaReaderModel.index;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue