mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-20 15:02:07 +00:00
refactoring
This commit is contained in:
parent
088514dc17
commit
d9dd709b5b
18 changed files with 324 additions and 682 deletions
|
|
@ -6,7 +6,6 @@ import 'package:mangayomi/utils/constant.dart';
|
|||
|
||||
Future<dom.Document?> cloudflareBypassDom(
|
||||
{required String url,
|
||||
required bool bypass,
|
||||
required String source,
|
||||
required bool useUserAgent}) async {
|
||||
// log(source);
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ Future<dynamic> httpGet(
|
|||
Document? dom;
|
||||
if (isCloudflaree) {
|
||||
dom = await cloudflareBypassDom(
|
||||
url: url,
|
||||
bypass: isCloudflaree,
|
||||
source: source,
|
||||
useUserAgent: useUserAgent);
|
||||
url: url, source: source, useUserAgent: useUserAgent);
|
||||
} else {
|
||||
dom = await httpResToDom(url: url, headers: headers(source));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
Color generalColor(BuildContext context) {
|
||||
return Theme.of(context).toggleButtonsTheme.color!;
|
||||
Color primaryColor(BuildContext context) {
|
||||
return Theme.of(context).primaryColor;
|
||||
}
|
||||
|
||||
Color secondaryColor(BuildContext context) {
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ Map<String, String> headers(String source) {
|
|||
source = source.toLowerCase();
|
||||
final cookie = Hive.box(HiveConstant.hiveBoxAppSettings)
|
||||
.get("$source-cookie", defaultValue: "");
|
||||
// log(cookie);
|
||||
final userAgent = Hive.box(HiveConstant.hiveBoxAppSettings)
|
||||
.get("ua", defaultValue: defaultUserAgent);
|
||||
return source == 'mangakawaii'
|
||||
? {
|
||||
'Referer': 'https://www.mangakawaii.io/',
|
||||
'User-Agent': userAgent,
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/8\$userAgentRandomizer1.0.4\$userAgentRandomizer3.1\$userAgentRandomizer2 Safari/537.36',
|
||||
'Accept-Language': 'fr'
|
||||
}
|
||||
: source == 'mangahere'
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class _GeneralScreenState extends State<GeneralScreen> {
|
|||
: 0,
|
||||
curve: Curves.easeIn,
|
||||
duration: const Duration(milliseconds: 150),
|
||||
color: generalColor(context),
|
||||
color: primaryColor(context),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class LibraryGridViewWidget extends StatelessWidget {
|
|||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
color: generalColor(context),
|
||||
color: primaryColor(context),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
|
|
@ -142,17 +142,21 @@ class LibraryGridViewWidget extends StatelessWidget {
|
|||
child: Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(3),
|
||||
bottomLeft: Radius.circular(3)),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 3, right: 3),
|
||||
child: Text(
|
||||
entriesManga[index].lang!.toUpperCase(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
color: primaryColor(context),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(3),
|
||||
bottomLeft: Radius.circular(3)),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 3, right: 3),
|
||||
child: Text(
|
||||
entriesManga[index].lang!.toUpperCase(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -192,8 +196,8 @@ class LibraryGridViewWidget extends StatelessWidget {
|
|||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: generalColor(context)
|
||||
.withOpacity(0.7),
|
||||
color: primaryColor(context)
|
||||
.withOpacity(0.9),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
|
|
@ -218,8 +222,8 @@ class LibraryGridViewWidget extends StatelessWidget {
|
|||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: generalColor(context)
|
||||
.withOpacity(0.7),
|
||||
color: primaryColor(context)
|
||||
.withOpacity(0.9),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
|
|
|
|||
|
|
@ -28,8 +28,14 @@ class LibraryListViewWidget extends StatelessWidget {
|
|||
return ListViewWidget(
|
||||
itemCount: entriesManga.length,
|
||||
itemBuilder: (context, index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0)),
|
||||
elevation: 0,
|
||||
shadowColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
context.push('/manga-reader/detail', extra: entriesManga[index]);
|
||||
},
|
||||
child: Padding(
|
||||
|
|
@ -67,7 +73,7 @@ class LibraryListViewWidget extends StatelessWidget {
|
|||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
color: generalColor(context)),
|
||||
color: primaryColor(context)),
|
||||
child: SizedBox(
|
||||
height: 22,
|
||||
child: Row(
|
||||
|
|
@ -134,18 +140,22 @@ class LibraryListViewWidget extends StatelessWidget {
|
|||
),
|
||||
if (language)
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(3),
|
||||
bottomRight: Radius.circular(3)),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 3, right: 3),
|
||||
child: Text(
|
||||
entriesManga[index].lang!.toUpperCase(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
color: primaryColor(context),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(3),
|
||||
bottomRight: Radius.circular(3)),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 3, right: 3),
|
||||
child: Text(
|
||||
entriesManga[index].lang!.toUpperCase(),
|
||||
style:
|
||||
const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -155,75 +165,69 @@ class LibraryListViewWidget extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
if (continueReaderBtn)
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
return ValueListenableBuilder<Box>(
|
||||
valueListenable: ref
|
||||
.watch(hiveBoxMangaInfoProvider)
|
||||
.listenable(),
|
||||
builder: (context, value, child) {
|
||||
final entries = value.get(
|
||||
"${entriesManga[index].lang}-${entriesManga[index].source}/${entriesManga[index].name}-chapter_index",
|
||||
defaultValue: '');
|
||||
final incognitoMode =
|
||||
ref.watch(incognitoModeStateProvider);
|
||||
Consumer(
|
||||
builder: (context, ref, child) {
|
||||
return ValueListenableBuilder<Box>(
|
||||
valueListenable:
|
||||
ref.watch(hiveBoxMangaInfoProvider).listenable(),
|
||||
builder: (context, value, child) {
|
||||
final entries = value.get(
|
||||
"${entriesManga[index].lang}-${entriesManga[index].source}/${entriesManga[index].name}-chapter_index",
|
||||
defaultValue: '');
|
||||
final incognitoMode =
|
||||
ref.watch(incognitoModeStateProvider);
|
||||
|
||||
if (entries.isNotEmpty && !incognitoMode) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
modelManga: entriesManga[index],
|
||||
index: int.parse(entries.toString()));
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: generalColor(context)
|
||||
.withOpacity(0.7),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
modelManga: entriesManga[index],
|
||||
index: entriesManga[index]
|
||||
.chapters!
|
||||
.length -
|
||||
1);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: generalColor(context)
|
||||
.withOpacity(0.7),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
if (entries.isNotEmpty && !incognitoMode) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
modelManga: entriesManga[index],
|
||||
index: int.parse(entries.toString()));
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color:
|
||||
primaryColor(context).withOpacity(0.9),
|
||||
),
|
||||
);
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
modelManga: entriesManga[index],
|
||||
index:
|
||||
entriesManga[index].chapters!.length -
|
||||
1);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: primaryColor(context).withOpacity(0.9),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
);
|
||||
},
|
||||
))
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
child: AppBar(
|
||||
title: Text(chapterNameList.length.toString()),
|
||||
backgroundColor:
|
||||
generalColor(context).withOpacity(0.2),
|
||||
primaryColor(context).withOpacity(0.2),
|
||||
leading: IconButton(
|
||||
onPressed: () {
|
||||
ref
|
||||
|
|
@ -248,7 +248,7 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
SafeArea(
|
||||
child: DraggableScrollbar(
|
||||
heightScrollThumb: 48.0,
|
||||
backgroundColor: generalColor(context),
|
||||
backgroundColor: primaryColor(context),
|
||||
scrollThumbBuilder: (backgroundColor, thumbAnimation,
|
||||
labelAnimation, height,
|
||||
{labelConstraints, labelText}) {
|
||||
|
|
@ -301,7 +301,7 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
return AnimatedContainer(
|
||||
curve: Curves.easeIn,
|
||||
decoration: BoxDecoration(
|
||||
color: generalColor(context).withOpacity(0.2),
|
||||
color: primaryColor(context).withOpacity(0.2),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(20),
|
||||
topRight: Radius.circular(20))),
|
||||
|
|
@ -327,10 +327,6 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
ref
|
||||
.read(chapterNameListStateProvider.notifier)
|
||||
.clear();
|
||||
|
||||
ref
|
||||
.read(isLongPressedStateProvider.notifier)
|
||||
.update(false);
|
||||
},
|
||||
child: Icon(chapter.isBookmarked
|
||||
? Icons.bookmark_remove
|
||||
|
|
@ -353,9 +349,6 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
ref
|
||||
.read(chapterNameListStateProvider.notifier)
|
||||
.clear();
|
||||
ref
|
||||
.read(isLongPressedStateProvider.notifier)
|
||||
.update(false);
|
||||
},
|
||||
child: Icon(chapter.isRead
|
||||
? Icons.remove_done_sharp
|
||||
|
|
@ -375,9 +368,6 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
modelManga: widget.modelManga!)
|
||||
.notifier)
|
||||
.set();
|
||||
ref
|
||||
.read(isLongPressedStateProvider.notifier)
|
||||
.update(false);
|
||||
ref
|
||||
.read(chapterNameListStateProvider.notifier)
|
||||
.clear();
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
curve: Curves.easeIn,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: generalColor(context),
|
||||
backgroundColor: primaryColor(context),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(15))),
|
||||
|
|
@ -137,7 +137,7 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
curve: Curves.easeIn,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: generalColor(context),
|
||||
backgroundColor: primaryColor(context),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15))),
|
||||
onPressed: () {
|
||||
|
|
@ -247,9 +247,9 @@ class _MangaDetailsViewState extends ConsumerState<MangaDetailsView> {
|
|||
chapters: widget.modelManga.chapters,
|
||||
categories: [],
|
||||
lastRead: widget.modelManga.lastRead);
|
||||
manga.put(
|
||||
'${widget.modelManga.lang}-${widget.modelManga.link}',
|
||||
model);
|
||||
manga.delete(
|
||||
'${widget.modelManga.lang}-${widget.modelManga.link}'
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
children: const [
|
||||
|
|
|
|||
|
|
@ -131,45 +131,26 @@ class ChapterFilterDownloadedState extends _$ChapterFilterDownloadedState {
|
|||
ModelManga getData() {
|
||||
if (getType() == 1) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
chap = modelManga.chapters!.where((element) {
|
||||
final modelChapDownload = ref
|
||||
.watch(hiveBoxMangaDownloadsProvider)
|
||||
.get(chapters[i].name, defaultValue: null);
|
||||
if (modelChapDownload != null && modelChapDownload.isDownload == true) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
.get(element.name, defaultValue: null);
|
||||
return modelChapDownload != null &&
|
||||
modelChapDownload.isDownload == true;
|
||||
}).toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
|
||||
return model;
|
||||
} else if (getType() == 2) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
chap = modelManga.chapters!.where((element) {
|
||||
final modelChapDownload = ref
|
||||
.watch(hiveBoxMangaDownloadsProvider)
|
||||
.get(chapters[i].name, defaultValue: null);
|
||||
if (!(modelChapDownload != null &&
|
||||
modelChapDownload.isDownload == true)) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
.get(element.name, defaultValue: null);
|
||||
return !(modelChapDownload != null &&
|
||||
modelChapDownload.isDownload == true);
|
||||
}).toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
|
||||
|
|
@ -182,45 +163,26 @@ class ChapterFilterDownloadedState extends _$ChapterFilterDownloadedState {
|
|||
ModelManga update() {
|
||||
if (state == 0) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
chap = modelManga.chapters!.where((element) {
|
||||
final modelChapDownload = ref
|
||||
.watch(hiveBoxMangaDownloadsProvider)
|
||||
.get(chapters[i].name, defaultValue: null);
|
||||
if (modelChapDownload != null && modelChapDownload.isDownload == true) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
.get(element.name, defaultValue: null);
|
||||
return modelChapDownload != null &&
|
||||
modelChapDownload.isDownload == true;
|
||||
}).toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
setType(1);
|
||||
return model;
|
||||
} else if (state == 1) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
chap = modelManga.chapters!.where((element) {
|
||||
final modelChapDownload = ref
|
||||
.watch(hiveBoxMangaDownloadsProvider)
|
||||
.get(chapters[i].name, defaultValue: null);
|
||||
if (!(modelChapDownload != null &&
|
||||
modelChapDownload.isDownload == true)) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
.get(element.name, defaultValue: null);
|
||||
return !(modelChapDownload != null &&
|
||||
modelChapDownload.isDownload == true);
|
||||
}).toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
setType(2);
|
||||
|
|
@ -255,38 +217,14 @@ class ChapterFilterUnreadState extends _$ChapterFilterUnreadState {
|
|||
ModelManga getData() {
|
||||
if (getType() == 1) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
if (!chapters[i].isRead) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
chap = modelManga.chapters!.where((element) => !element.isRead).toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
|
||||
return model;
|
||||
} else if (getType() == 2) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
if (chapters[i].isRead) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
chap = modelManga.chapters!.where((element) => element.isRead).toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
|
||||
|
|
@ -299,38 +237,14 @@ class ChapterFilterUnreadState extends _$ChapterFilterUnreadState {
|
|||
ModelManga update() {
|
||||
if (state == 0) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
if (!chapters[i].isRead) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
chap = modelManga.chapters!.where((element) => !element.isRead).toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
setType(1);
|
||||
return model;
|
||||
} else if (state == 1) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
if (chapters[i].isRead) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
chap = modelManga.chapters!.where((element) => element.isRead).toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
setType(2);
|
||||
|
|
@ -365,38 +279,17 @@ class ChapterFilterBookmarkedState extends _$ChapterFilterBookmarkedState {
|
|||
ModelManga getData() {
|
||||
if (getType() == 1) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
if (chapters[i].isBookmarked) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
chap = modelManga.chapters!
|
||||
.where((element) => element.isBookmarked)
|
||||
.toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
|
||||
return model;
|
||||
} else if (getType() == 2) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
if (!chapters[i].isBookmarked) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
chap = modelManga.chapters!
|
||||
.where((element) => !element.isBookmarked)
|
||||
.toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
|
||||
|
|
@ -409,38 +302,18 @@ class ChapterFilterBookmarkedState extends _$ChapterFilterBookmarkedState {
|
|||
ModelManga update() {
|
||||
if (state == 0) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
if (chapters[i].isBookmarked) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
chap = modelManga.chapters!
|
||||
.where((element) => element.isBookmarked)
|
||||
.toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
setType(1);
|
||||
return model;
|
||||
} else if (state == 1) {
|
||||
List<ModelChapters> chap = [];
|
||||
final chapters = modelManga.chapters;
|
||||
for (var i = 0; i < chapters!.length; i++) {
|
||||
if (!chapters[i].isBookmarked) {
|
||||
chap.add(ModelChapters(
|
||||
name: chapters[i].name,
|
||||
url: chapters[i].url,
|
||||
dateUpload: chapters[i].dateUpload,
|
||||
isBookmarked: chapters[i].isBookmarked,
|
||||
scanlator: chapters[i].scanlator,
|
||||
isRead: chapters[i].isRead,
|
||||
lastPageRead: chapters[i].lastPageRead));
|
||||
}
|
||||
}
|
||||
chap = modelManga.chapters!
|
||||
.where((element) => !element.isBookmarked)
|
||||
.toList();
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
setType(2);
|
||||
|
|
@ -512,30 +385,15 @@ class ChapterSetIsBookmarkState extends _$ChapterSetIsBookmarkState {
|
|||
build({required ModelManga modelManga}) {}
|
||||
|
||||
set() {
|
||||
final entries = ref
|
||||
.watch(hiveBoxMangaProvider)
|
||||
.get('${modelManga.lang}-${modelManga.link}', defaultValue: modelManga);
|
||||
ref.read(isLongPressedStateProvider.notifier).update(false);
|
||||
for (var name in ref.watch(chapterNameListStateProvider)) {
|
||||
List<ModelChapters> chap = [];
|
||||
for (var i = 0; i < modelManga.chapters!.length; i++) {
|
||||
chap.add(ModelChapters(
|
||||
name: entries!.chapters![i].name,
|
||||
url: entries.chapters![i].url,
|
||||
dateUpload: entries.chapters![i].dateUpload,
|
||||
isBookmarked: name == entries.chapters![i].name
|
||||
? entries.chapters![i].isBookmarked
|
||||
? false
|
||||
: true
|
||||
: entries.chapters![i].isBookmarked,
|
||||
scanlator: entries.chapters![i].scanlator,
|
||||
isRead: entries.chapters![i].isRead,
|
||||
lastPageRead: entries.chapters![i].lastPageRead));
|
||||
modelManga.chapters![i].isBookmarked =
|
||||
name == modelManga.chapters![i].name
|
||||
? !modelManga.chapters![i].isBookmarked
|
||||
: modelManga.chapters![i].isBookmarked;
|
||||
}
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
ref
|
||||
.watch(hiveBoxMangaProvider)
|
||||
.put('${modelManga.lang}-${modelManga.link}', model);
|
||||
modelManga.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -546,31 +404,14 @@ class ChapterSetIsReadState extends _$ChapterSetIsReadState {
|
|||
build({required ModelManga modelManga}) {}
|
||||
|
||||
set() {
|
||||
final entries = ref
|
||||
.watch(hiveBoxMangaProvider)
|
||||
.get('${modelManga.lang}-${modelManga.link}', defaultValue: modelManga);
|
||||
ref.read(isLongPressedStateProvider.notifier).update(false);
|
||||
for (var name in ref.watch(chapterNameListStateProvider)) {
|
||||
List<ModelChapters> chap = [];
|
||||
for (var i = 0; i < modelManga.chapters!.length; i++) {
|
||||
chap.add(ModelChapters(
|
||||
name: entries!.chapters![i].name,
|
||||
url: entries.chapters![i].url,
|
||||
dateUpload: entries.chapters![i].dateUpload,
|
||||
isBookmarked: entries.chapters![i].isBookmarked,
|
||||
scanlator: entries.chapters![i].scanlator,
|
||||
isRead: name == entries.chapters![i].name
|
||||
? entries.chapters![i].isRead
|
||||
? false
|
||||
: true
|
||||
: entries.chapters![i].isRead,
|
||||
lastPageRead: entries.chapters![i].lastPageRead));
|
||||
modelManga.chapters![i].isRead = name == modelManga.chapters![i].name
|
||||
? !modelManga.chapters![i].isRead
|
||||
: modelManga.chapters![i].isRead;
|
||||
}
|
||||
|
||||
final model =
|
||||
modelMangaWithNewChapValue(modelManga: modelManga, chapters: chap);
|
||||
ref
|
||||
.watch(hiveBoxMangaProvider)
|
||||
.put('${modelManga.lang}-${modelManga.link}', model);
|
||||
modelManga.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -581,6 +422,7 @@ class ChapterSetDownloadState extends _$ChapterSetDownloadState {
|
|||
build({required ModelManga modelManga}) {}
|
||||
|
||||
set() {
|
||||
ref.read(isLongPressedStateProvider.notifier).update(false);
|
||||
List<int> indexList = [];
|
||||
for (var name in ref.watch(chapterNameListStateProvider)) {
|
||||
for (var i = 0; i < modelManga.chapters!.length; i++) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mangayomi/models/manga_reader.dart';
|
||||
|
|
@ -29,9 +31,10 @@ class ChapterListTileWidget extends ConsumerWidget {
|
|||
final idx = reverse ? reverseIndex : finalIndex;
|
||||
final chapterNameList = ref.watch(chapterNameListStateProvider);
|
||||
final chapterName = modelManga.chapters![idx].name;
|
||||
log(chapterNameList.length.toString());
|
||||
return Container(
|
||||
color: chapterNameList.contains(chapterName)
|
||||
? generalColor(context).withOpacity(0.4)
|
||||
? primaryColor(context).withOpacity(0.4)
|
||||
: null,
|
||||
child: ListTile(
|
||||
textColor: chapters[finalIndex].isRead
|
||||
|
|
@ -83,7 +86,7 @@ class ChapterListTileWidget extends ConsumerWidget {
|
|||
? Icon(
|
||||
Icons.bookmark,
|
||||
size: 15,
|
||||
color: generalColor(context),
|
||||
color: primaryColor(context),
|
||||
)
|
||||
: Container(),
|
||||
Flexible(
|
||||
|
|
|
|||
|
|
@ -132,6 +132,9 @@ class _MangaChapterPageGalleryState
|
|||
_rebuildDetail.close();
|
||||
_doubleClickAnimationController.dispose();
|
||||
clearGestureDetailsCache();
|
||||
widget.readerController.setMangaHistoryUpdate();
|
||||
widget.readerController.setPageIndex(_currentIndex);
|
||||
widget.readerController.setChapterPageLastRead(_currentIndex);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
|
@ -159,18 +162,13 @@ class _MangaChapterPageGalleryState
|
|||
}
|
||||
|
||||
void _onPageChanged(int index) {
|
||||
widget.readerController.setMangaHistoryUpdate();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
if (_imageDetailY != 0) {
|
||||
_imageDetailY = 0;
|
||||
_rebuildDetail.sink.add(_imageDetailY);
|
||||
}
|
||||
ref.read(currentIndexProvider.notifier).setCurrentIndex(index);
|
||||
_currentIndex = index;
|
||||
|
||||
if (_imageDetailY != 0) {
|
||||
_imageDetailY = 0;
|
||||
_rebuildDetail.sink.add(_imageDetailY);
|
||||
}
|
||||
widget.readerController.setPageIndex(index);
|
||||
widget.readerController.setChapterPageLastRead(index);
|
||||
}
|
||||
|
||||
void _onAddButtonTapped(int index, bool isPrev, {bool isSlide = false}) {
|
||||
|
|
@ -244,19 +242,14 @@ class _MangaChapterPageGalleryState
|
|||
if (firstImageIndex == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
_recordReadProgress(firstImageIndex);
|
||||
if (_currentIndex != firstImageIndex) {
|
||||
_recordReadProgress(firstImageIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void _recordReadProgress(int index) {
|
||||
widget.readerController.setMangaHistoryUpdate();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
}
|
||||
widget.readerController.setPageIndex(index);
|
||||
widget.readerController.setChapterPageLastRead(index);
|
||||
ref.read(currentIndexProvider.notifier).setCurrentIndex(index);
|
||||
_currentIndex = index;
|
||||
}
|
||||
|
||||
ReaderMode? _selectedValue;
|
||||
|
|
@ -370,6 +363,7 @@ class _MangaChapterPageGalleryState
|
|||
Widget _showMore() {
|
||||
return Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final currentIndex = ref.watch(currentIndexProvider);
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
|
|
@ -495,7 +489,7 @@ class _MangaChapterPageGalleryState
|
|||
child: SizedBox(
|
||||
width: 25,
|
||||
child: Text(
|
||||
"${_currentIndex + 1} ",
|
||||
"${currentIndex + 1} ",
|
||||
style: const TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
@ -667,13 +661,14 @@ class _MangaChapterPageGalleryState
|
|||
Widget _showPage() {
|
||||
return Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final currentIndex = ref.watch(currentIndexProvider);
|
||||
return _isView
|
||||
? Container()
|
||||
: _showPagesNumber
|
||||
? Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Text(
|
||||
'${_currentIndex + 1} / ${widget.readerController.getPageLength(widget.url)}',
|
||||
'${currentIndex + 1} / ${widget.readerController.getPageLength(widget.url)}',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12.0,
|
||||
|
|
@ -710,95 +705,63 @@ class _MangaChapterPageGalleryState
|
|||
return Row(
|
||||
children: [
|
||||
/// left region
|
||||
_isVerticalContinous()
|
||||
? Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
} else {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
}
|
||||
},
|
||||
onDoubleTapDown: (TapDownDetails details) {
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
} else {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
}
|
||||
},
|
||||
onDoubleTapDown: _isVerticalContinous()
|
||||
? (TapDownDetails details) {
|
||||
_toggleScale(details.globalPosition);
|
||||
},
|
||||
onDoubleTap: () {},
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
} else {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
}
|
||||
: null,
|
||||
onDoubleTap: _isVerticalContinous() ? () {} : null,
|
||||
),
|
||||
),
|
||||
|
||||
/// center region
|
||||
_isVerticalContinous()
|
||||
? Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_isViewFunction();
|
||||
},
|
||||
onDoubleTapDown: (TapDownDetails details) {
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_isViewFunction();
|
||||
},
|
||||
onDoubleTapDown: _isVerticalContinous()
|
||||
? (TapDownDetails details) {
|
||||
_toggleScale(details.globalPosition);
|
||||
},
|
||||
onDoubleTap: () {},
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_isViewFunction();
|
||||
},
|
||||
),
|
||||
),
|
||||
}
|
||||
: null,
|
||||
onDoubleTap: _isVerticalContinous() ? () {} : null,
|
||||
),
|
||||
),
|
||||
|
||||
/// right region
|
||||
_isVerticalContinous()
|
||||
? Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
} else {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
}
|
||||
},
|
||||
onDoubleTapDown: (TapDownDetails details) {
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
} else {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
}
|
||||
},
|
||||
onDoubleTapDown: _isVerticalContinous()
|
||||
? (TapDownDetails details) {
|
||||
_toggleScale(details.globalPosition);
|
||||
},
|
||||
onDoubleTap: () {},
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
} else {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
}
|
||||
: null,
|
||||
onDoubleTap: _isVerticalContinous() ? () {} : null,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
|
@ -811,57 +774,41 @@ class _MangaChapterPageGalleryState
|
|||
return Column(
|
||||
children: [
|
||||
/// top region
|
||||
_isVerticalContinous()
|
||||
? Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
},
|
||||
onDoubleTapDown: (TapDownDetails details) {
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
},
|
||||
onDoubleTapDown: _isVerticalContinous()
|
||||
? (TapDownDetails details) {
|
||||
_toggleScale(details.globalPosition);
|
||||
},
|
||||
onDoubleTap: () {},
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_onAddButtonTapped(_currentIndex - 1, true);
|
||||
},
|
||||
),
|
||||
),
|
||||
}
|
||||
: null,
|
||||
onDoubleTap: _isVerticalContinous() ? () {} : null,
|
||||
),
|
||||
),
|
||||
|
||||
/// center region
|
||||
Expanded(flex: 5, child: Container()),
|
||||
|
||||
/// bottom region
|
||||
_isVerticalContinous()
|
||||
? Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
},
|
||||
onDoubleTapDown: (TapDownDetails details) {
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
},
|
||||
onDoubleTapDown: _isVerticalContinous()
|
||||
? (TapDownDetails details) {
|
||||
_toggleScale(details.globalPosition);
|
||||
},
|
||||
onDoubleTap: () {},
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
flex: 2,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_onAddButtonTapped(_currentIndex + 1, false);
|
||||
},
|
||||
),
|
||||
),
|
||||
}
|
||||
: null,
|
||||
onDoubleTap: _isVerticalContinous() ? () {} : null,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,14 +24,7 @@ enum ReaderMode {
|
|||
@riverpod
|
||||
class CurrentIndex extends _$CurrentIndex {
|
||||
@override
|
||||
int build(MangaReaderModel mangaReaderModel) {
|
||||
final modelManga = mangaReaderModel.modelManga;
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
if (!incognitoMode) {
|
||||
return ref.watch(hiveBoxMangaInfoProvider).get(
|
||||
"${modelManga.lang}-${modelManga.source}/${modelManga.name}/${modelManga.chapters![mangaReaderModel.index].name}-page_index",
|
||||
defaultValue: 0);
|
||||
}
|
||||
int build() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -108,41 +101,12 @@ class ReaderController extends _$ReaderController {
|
|||
}
|
||||
}
|
||||
|
||||
void setChapterPageLastRead(int pageIndex) {
|
||||
void setChapterPageLastRead(int pageIndex) async {
|
||||
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,
|
||||
categories: getModelManga().categories,
|
||||
lastRead: getModelManga().lastRead);
|
||||
ref
|
||||
.watch(hiveBoxMangaProvider)
|
||||
.put('${getModelManga().lang}-${getModelManga().link}', model);
|
||||
List<ModelChapters> chapter = getModelManga().chapters!;
|
||||
chapter[getChapterIndex()].lastPageRead = (pageIndex + 1).toString();
|
||||
getModelManga().save();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,38 +114,9 @@ class ReaderController extends _$ReaderController {
|
|||
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,
|
||||
categories: getModelManga().categories,
|
||||
lastRead: getModelManga().lastRead);
|
||||
ref
|
||||
.watch(hiveBoxMangaProvider)
|
||||
.put('${getModelManga().lang}-${getModelManga().link}', model);
|
||||
List<ModelChapters> chapter = getModelManga().chapters!;
|
||||
chapter[getChapterIndex()].isBookmarked = !isBookmarked;
|
||||
getModelManga().save();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,22 @@ class ReaderModeAdapter extends TypeAdapter<ReaderMode> {
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$currentIndexHash() => r'b25073058aa2f1a392a4591d8812a61e752061ef';
|
||||
String _$currentIndexHash() => r'af7ea51b2aa8a5c6db401c52958879b87fc56973';
|
||||
|
||||
/// See also [CurrentIndex].
|
||||
@ProviderFor(CurrentIndex)
|
||||
final currentIndexProvider =
|
||||
AutoDisposeNotifierProvider<CurrentIndex, int>.internal(
|
||||
CurrentIndex.new,
|
||||
name: r'currentIndexProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$currentIndexHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$CurrentIndex = AutoDisposeNotifier<int>;
|
||||
String _$readerControllerHash() => r'a389f9b08001c6863a651f6c2ed3d1b18588d5b0';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
@ -87,103 +102,6 @@ class _SystemHash {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class _$CurrentIndex extends BuildlessAutoDisposeNotifier<int> {
|
||||
late final MangaReaderModel mangaReaderModel;
|
||||
|
||||
int build(
|
||||
MangaReaderModel mangaReaderModel,
|
||||
);
|
||||
}
|
||||
|
||||
/// See also [CurrentIndex].
|
||||
@ProviderFor(CurrentIndex)
|
||||
const currentIndexProvider = CurrentIndexFamily();
|
||||
|
||||
/// See also [CurrentIndex].
|
||||
class CurrentIndexFamily extends Family<int> {
|
||||
/// See also [CurrentIndex].
|
||||
const CurrentIndexFamily();
|
||||
|
||||
/// See also [CurrentIndex].
|
||||
CurrentIndexProvider call(
|
||||
MangaReaderModel mangaReaderModel,
|
||||
) {
|
||||
return CurrentIndexProvider(
|
||||
mangaReaderModel,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
CurrentIndexProvider getProviderOverride(
|
||||
covariant CurrentIndexProvider provider,
|
||||
) {
|
||||
return call(
|
||||
provider.mangaReaderModel,
|
||||
);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get dependencies => _dependencies;
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _allTransitiveDependencies = null;
|
||||
|
||||
@override
|
||||
Iterable<ProviderOrFamily>? get allTransitiveDependencies =>
|
||||
_allTransitiveDependencies;
|
||||
|
||||
@override
|
||||
String? get name => r'currentIndexProvider';
|
||||
}
|
||||
|
||||
/// See also [CurrentIndex].
|
||||
class CurrentIndexProvider
|
||||
extends AutoDisposeNotifierProviderImpl<CurrentIndex, int> {
|
||||
/// See also [CurrentIndex].
|
||||
CurrentIndexProvider(
|
||||
this.mangaReaderModel,
|
||||
) : super.internal(
|
||||
() => CurrentIndex()..mangaReaderModel = mangaReaderModel,
|
||||
from: currentIndexProvider,
|
||||
name: r'currentIndexProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$currentIndexHash,
|
||||
dependencies: CurrentIndexFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
CurrentIndexFamily._allTransitiveDependencies,
|
||||
);
|
||||
|
||||
final MangaReaderModel mangaReaderModel;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return other is CurrentIndexProvider &&
|
||||
other.mangaReaderModel == mangaReaderModel;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
var hash = _SystemHash.combine(0, runtimeType.hashCode);
|
||||
hash = _SystemHash.combine(hash, mangaReaderModel.hashCode);
|
||||
|
||||
return _SystemHash.finish(hash);
|
||||
}
|
||||
|
||||
@override
|
||||
int runNotifierBuild(
|
||||
covariant CurrentIndex notifier,
|
||||
) {
|
||||
return notifier.build(
|
||||
mangaReaderModel,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$readerControllerHash() => r'a389f9b08001c6863a651f6c2ed3d1b18588d5b0';
|
||||
|
||||
abstract class _$ReaderController extends BuildlessAutoDisposeNotifier<void> {
|
||||
late final MangaReaderModel mangaReaderModel;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class ListTileWidget extends StatelessWidget {
|
|||
height: 40,
|
||||
child: Icon(
|
||||
icon,
|
||||
color: generalColor(context),
|
||||
color: primaryColor(context),
|
||||
)),
|
||||
title: Text(title),
|
||||
trailing: trailing,
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mangayomi/models/model_manga.dart';
|
||||
import 'package:mangayomi/providers/hive_provider.dart';
|
||||
import 'package:mangayomi/services/get_manga_detail.dart';
|
||||
import 'package:mangayomi/utils/cached_network.dart';
|
||||
import 'package:mangayomi/utils/headers.dart';
|
||||
import 'package:mangayomi/views/widgets/bottom_text_widget.dart';
|
||||
import 'package:mangayomi/views/widgets/cover_view_widget.dart';
|
||||
|
||||
class MangaImageCardWidget extends ConsumerStatefulWidget {
|
||||
class MangaImageCardWidget extends ConsumerWidget {
|
||||
final String lang;
|
||||
final bool isLoading;
|
||||
|
||||
|
|
@ -22,43 +23,42 @@ class MangaImageCardWidget extends ConsumerStatefulWidget {
|
|||
});
|
||||
|
||||
@override
|
||||
ConsumerState<MangaImageCardWidget> createState() =>
|
||||
_MangaImageCardWidgetState();
|
||||
}
|
||||
|
||||
class _MangaImageCardWidgetState extends ConsumerState<MangaImageCardWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final manga = ref.watch(hiveBoxMangaProvider);
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
final modelManga = ModelManga(
|
||||
imageUrl: widget.getMangaDetailModel!.imageUrl,
|
||||
name: widget.getMangaDetailModel!.name,
|
||||
genre: widget.getMangaDetailModel!.genre,
|
||||
author: widget.getMangaDetailModel!.author,
|
||||
status: widget.getMangaDetailModel!.status,
|
||||
description: widget.getMangaDetailModel!.description,
|
||||
imageUrl: getMangaDetailModel!.imageUrl,
|
||||
name: getMangaDetailModel!.name,
|
||||
genre: getMangaDetailModel!.genre,
|
||||
author: getMangaDetailModel!.author,
|
||||
status: getMangaDetailModel!.status,
|
||||
description: getMangaDetailModel!.description,
|
||||
favorite: false,
|
||||
link: widget.getMangaDetailModel!.url,
|
||||
source: widget.getMangaDetailModel!.source,
|
||||
lang: widget.lang,
|
||||
link: getMangaDetailModel!.url,
|
||||
source: getMangaDetailModel!.source,
|
||||
lang: lang,
|
||||
dateAdded: null,
|
||||
lastUpdate: null,
|
||||
chapters: widget.getMangaDetailModel!.chapters,
|
||||
chapters: getMangaDetailModel!.chapters,
|
||||
categories: [],
|
||||
lastRead: '');
|
||||
if (mounted) {
|
||||
context.push('/manga-reader/detail', extra: modelManga);
|
||||
if (manga.get('$lang-${getMangaDetailModel!.url}',
|
||||
defaultValue: null) ==
|
||||
null) {
|
||||
manga.put('$lang-${getMangaDetailModel!.url}', modelManga);
|
||||
}
|
||||
|
||||
context.push('/manga-reader/detail', extra: modelManga);
|
||||
},
|
||||
child: CoverViewWidget(children: [
|
||||
cachedNetworkImage(
|
||||
headers: headers(widget.getMangaDetailModel!.source!),
|
||||
imageUrl: widget.getMangaDetailModel!.imageUrl!,
|
||||
headers: headers(getMangaDetailModel!.source!),
|
||||
imageUrl: getMangaDetailModel!.imageUrl!,
|
||||
width: 200,
|
||||
height: 270,
|
||||
fit: BoxFit.cover),
|
||||
BottomTextWidget(text: widget.getMangaDetailModel!.name!)
|
||||
BottomTextWidget(text: getMangaDetailModel!.name!)
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
13
pubspec.lock
13
pubspec.lock
|
|
@ -54,10 +54,10 @@ packages:
|
|||
description:
|
||||
path: "."
|
||||
ref: HEAD
|
||||
resolved-ref: "7b778222546d53fcd41a84f6aee90b87c2593930"
|
||||
resolved-ref: "4ccc65af8b8171719c59d79a6c068840e8cf04c6"
|
||||
url: "https://github.com/kodjodevf/background_downloader.git"
|
||||
source: git
|
||||
version: "5.4.5"
|
||||
version: "5.5.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -410,10 +410,11 @@ packages:
|
|||
flutter_js:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_js
|
||||
sha256: "86922b593f80512dfe72586aab826123708992ecd07476349828e9893d7cbaff"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "."
|
||||
ref: HEAD
|
||||
resolved-ref: "021297c5bdf30372dc94528583dc864951e43c39"
|
||||
url: "https://github.com/kodjodevf/flutter_js.git"
|
||||
source: git
|
||||
version: "0.6.0"
|
||||
flutter_launcher_icons:
|
||||
dependency: "direct dev"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ dependencies:
|
|||
http: ^0.13.5
|
||||
riverpod_annotation: ^2.0.2
|
||||
html: ^0.15.2
|
||||
flutter_js: ^0.6.0
|
||||
flutter_js:
|
||||
git:
|
||||
url: https://github.com/kodjodevf/flutter_js.git
|
||||
font_awesome_flutter: ^10.1.0
|
||||
expandable_text: ^2.3.0
|
||||
flex_color_scheme: ^7.0.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue