Improve comic chapters.

This commit is contained in:
2025-02-20 13:08:55 +08:00
parent 2b3c7a8564
commit bd5d10e919
14 changed files with 324 additions and 97 deletions

View File

@@ -98,7 +98,7 @@ abstract mixin class _ComicPageActions {
void read([int? ep, int? page]) {
App.rootContext
.to(
() => Reader(
() => Reader(
type: comic.comicType,
cid: comic.id,
name: comic.title,
@@ -219,7 +219,7 @@ abstract mixin class _ComicPageActions {
isGettingLink = true;
});
var res =
await comicSource.archiveDownloader!.getDownloadUrl(
await comicSource.archiveDownloader!.getDownloadUrl(
comic.id,
archives![selected].id,
);
@@ -262,7 +262,7 @@ abstract mixin class _ComicPageActions {
if (localComic != null) {
for (int i = 0; i < comic.chapters!.length; i++) {
if (localComic.downloadedChapters
.contains(comic.chapters!.keys.elementAt(i))) {
.contains(comic.chapters!.ids.elementAt(i))) {
downloaded.add(i);
}
}
@@ -270,8 +270,8 @@ abstract mixin class _ComicPageActions {
await showSideBar(
App.rootContext,
_SelectDownloadChapter(
comic.chapters!.values.toList(),
(v) => selected = v,
comic.chapters!.titles.toList(),
(v) => selected = v,
downloaded,
),
);
@@ -281,7 +281,7 @@ abstract mixin class _ComicPageActions {
comicId: comic.id,
comic: comic,
chapters: selected!.map((i) {
return comic.chapters!.keys.elementAt(i);
return comic.chapters!.ids.elementAt(i);
}).toList(),
));
}
@@ -298,13 +298,13 @@ abstract mixin class _ComicPageActions {
var context = App.mainNavigatorKey!.currentContext!;
if (config['action'] == 'search') {
context.to(() => SearchResultPage(
text: config['keyword'] ?? '',
sourceKey: comicSource.key,
options: const [],
));
text: config['keyword'] ?? '',
sourceKey: comicSource.key,
options: const [],
));
} else if (config['action'] == 'category') {
context.to(
() => CategoryComicsPage(
() => CategoryComicsPage(
category: config['keyword'] ?? '',
categoryKey: comicSource.categoryData!.key,
param: config['param'],
@@ -432,4 +432,4 @@ abstract mixin class _ComicPageActions {
),
);
}
}
}

View File

@@ -33,7 +33,7 @@ class _NormalComicChaptersState extends State<_NormalComicChapters> {
late History? history;
late Map<String, String> chapters;
late ComicChapters chapters;
@override
void initState() {
@@ -101,7 +101,7 @@ class _NormalComicChaptersState extends State<_NormalComicChapters> {
if (reverse) {
i = chapters.length - i - 1;
}
var key = chapters.keys.elementAt(i);
var key = chapters.ids.elementAt(i);
var value = chapters[key]!;
bool visited = (history?.readEpisode ?? {}).contains(i + 1);
return Padding(
@@ -182,7 +182,7 @@ class _GroupedComicChaptersState extends State<_GroupedComicChapters>
late History? history;
late Map<String, Map<String, String>> chapters;
late ComicChapters chapters;
late TabController tabController;
@@ -197,9 +197,9 @@ class _GroupedComicChaptersState extends State<_GroupedComicChapters>
@override
void didChangeDependencies() {
state = context.findAncestorStateOfType<_ComicPageState>()!;
chapters = state.comic.groupedChapters!;
chapters = state.comic.chapters!;
tabController = TabController(
length: chapters.keys.length,
length: chapters.ids.length,
vsync: this,
);
tabController.addListener(onTabChange);
@@ -226,7 +226,7 @@ class _GroupedComicChaptersState extends State<_GroupedComicChapters>
Widget build(BuildContext context) {
return SliverLayoutBuilder(
builder: (context, constrains) {
var group = chapters.values.elementAt(index);
var group = chapters.getGroupByIndex(index);
int length = group.length;
bool canShowAll = showAll;
if (!showAll) {
@@ -265,7 +265,7 @@ class _GroupedComicChaptersState extends State<_GroupedComicChapters>
child: AppTabBar(
withUnderLine: false,
controller: tabController,
tabs: chapters.keys.map((e) => Tab(text: e)).toList(),
tabs: chapters.groups.map((e) => Tab(text: e)).toList(),
),
),
SliverPadding(padding: const EdgeInsets.only(top: 8)),
@@ -279,12 +279,12 @@ class _GroupedComicChaptersState extends State<_GroupedComicChapters>
var key = group.keys.elementAt(i);
var value = group[key]!;
var chapterIndex = 0;
for (var j = 0; j < chapters.length; j++) {
for (var j = 0; j < chapters.groupCount; j++) {
if (j == index) {
chapterIndex += i;
break;
}
chapterIndex += chapters.values.elementAt(j).length;
chapterIndex += chapters.getGroupByIndex(j).length;
}
bool visited =
(history?.readEpisode ?? {}).contains(chapterIndex + 1);

View File

@@ -386,7 +386,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
String text;
if (haveChapter) {
text = "Last Reading: @epName Page @page".tlParams({
'epName': comic.chapters!.values.elementAt(
'epName': comic.chapters!.titles.elementAt(
math.min(ep - 1, comic.chapters!.length - 1)),
'page': page,
});
@@ -610,7 +610,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
}
return _ComicChapters(
history: history,
groupedMode: comic.groupedChapters != null,
groupedMode: comic.chapters!.isGrouped,
);
}