show novel progress in percentage and fixed gesture detector
This commit is contained in:
parent
66e48612ae
commit
84c82ba1ee
8 changed files with 95 additions and 146 deletions
|
|
@ -6,7 +6,7 @@ part of 'update_manga_detail_providers.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$updateMangaDetailHash() => r'82c52aa8760fb455e6558be925d05f5f0703af98';
|
||||
String _$updateMangaDetailHash() => r'a86fe8fea46e411203182287c970cd80cc9a1a0c';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,10 @@ class ChapterListTileWidget extends ConsumerWidget {
|
|||
int.parse(chapter.lastPageRead!))
|
||||
.toString()
|
||||
.substringBefore("."))
|
||||
: l10n.page(chapter.lastPageRead!),
|
||||
: l10n.page(chapter.manga.value!.itemType ==
|
||||
ItemType.manga
|
||||
? chapter.lastPageRead!
|
||||
: "${((double.tryParse(chapter.lastPageRead!) ?? 0) * 100).toStringAsFixed(0)} %"),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: context.isLight
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'download_provider.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$downloadChapterHash() => r'44f8aeae592a90e0c657da0263276997afbbe433';
|
||||
String _$downloadChapterHash() => r'de8e2d5b952071bc0d014fc3aa5c9b0714fbcee0';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class _ChapterListTileState extends State<ChapterListTile> {
|
|||
if (!chapter.isRead!)
|
||||
if (chapter.lastPageRead!.isNotEmpty &&
|
||||
chapter.lastPageRead != "1")
|
||||
if (chapter.scanlator!.isNotEmpty)
|
||||
if (chapter.scanlator != null && chapter.scanlator!.isNotEmpty)
|
||||
Row(
|
||||
children: [
|
||||
const Text(' • '),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
import 'package:mangayomi/models/chapter.dart';
|
||||
|
|
@ -7,25 +5,9 @@ import 'package:mangayomi/models/download.dart';
|
|||
import 'package:mangayomi/models/history.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
import 'package:mangayomi/models/track.dart';
|
||||
import 'package:mangayomi/models/track_preference.dart';
|
||||
import 'package:mangayomi/modules/manga/detail/providers/track_state_providers.dart';
|
||||
import 'package:mangayomi/modules/more/settings/track/providers/track_providers.dart';
|
||||
import 'package:mangayomi/utils/chapter_recognition.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'novel_reader_controller_provider.g.dart';
|
||||
|
||||
BoxFit getBoxFit(ScaleType scaleType) {
|
||||
return switch (scaleType) {
|
||||
ScaleType.fitHeight => BoxFit.fitHeight,
|
||||
ScaleType.fitWidth => BoxFit.fitWidth,
|
||||
ScaleType.fitScreen => BoxFit.contain,
|
||||
ScaleType.originalSize => BoxFit.cover,
|
||||
ScaleType.smartFit => BoxFit.contain,
|
||||
_ => BoxFit.cover
|
||||
};
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class NovelReaderController extends _$NovelReaderController {
|
||||
@override
|
||||
|
|
@ -115,7 +97,7 @@ class NovelReaderController extends _$NovelReaderController {
|
|||
}
|
||||
}
|
||||
if (index == null) {
|
||||
final chapters = getManga().chapters.toList().reversed.toList();
|
||||
final chapters = getManga().chapters.toList().toList();
|
||||
for (var i = 0; i < chapters.length; i++) {
|
||||
if (chapters[i].id == chapter.id) {
|
||||
index = i + 1;
|
||||
|
|
@ -135,7 +117,7 @@ class NovelReaderController extends _$NovelReaderController {
|
|||
}
|
||||
}
|
||||
if (index == null) {
|
||||
final chapters = getManga().chapters.toList().reversed.toList();
|
||||
final chapters = getManga().chapters.toList().toList();
|
||||
for (var i = 0; i < chapters.length; i++) {
|
||||
if (chapters[i].id == chapter.id) {
|
||||
index = i - 1;
|
||||
|
|
@ -155,7 +137,7 @@ class NovelReaderController extends _$NovelReaderController {
|
|||
}
|
||||
}
|
||||
if (index == null) {
|
||||
final chapters = getManga().chapters.toList().reversed.toList();
|
||||
final chapters = getManga().chapters.toList().toList();
|
||||
for (var i = 0; i < chapters.length; i++) {
|
||||
if (chapters[i].id == chapter.id) {
|
||||
index = i;
|
||||
|
|
@ -170,14 +152,14 @@ class NovelReaderController extends _$NovelReaderController {
|
|||
final prevChapIdx = getPrevChapterIndex();
|
||||
return prevChapIdx.$2
|
||||
? getManga().getFilteredChapterList()[prevChapIdx.$1]
|
||||
: getManga().chapters.toList().reversed.toList()[prevChapIdx.$1];
|
||||
: getManga().chapters.toList().toList()[prevChapIdx.$1];
|
||||
}
|
||||
|
||||
Chapter getNextChapter() {
|
||||
final nextChapIdx = getNextChapterIndex();
|
||||
return nextChapIdx.$2
|
||||
? getManga().getFilteredChapterList()[nextChapIdx.$1]
|
||||
: getManga().chapters.toList().reversed.toList()[nextChapIdx.$1];
|
||||
: getManga().chapters.toList().toList()[nextChapIdx.$1];
|
||||
}
|
||||
|
||||
int getChaptersLength(bool isInFilterList) {
|
||||
|
|
@ -199,59 +181,9 @@ class NovelReaderController extends _$NovelReaderController {
|
|||
}
|
||||
}
|
||||
|
||||
extension ChapterExtensions on Chapter {
|
||||
void updateTrackChapterRead(dynamic ref) {
|
||||
if (!(ref is WidgetRef || ref is Ref)) return;
|
||||
final updateProgressAfterReading =
|
||||
ref.watch(updateProgressAfterReadingStateProvider);
|
||||
if (!updateProgressAfterReading) return;
|
||||
final manga = this.manga.value!;
|
||||
final chapterNumber =
|
||||
ChapterRecognition().parseChapterNumber(manga.name!, name!);
|
||||
|
||||
final tracks = isar.tracks
|
||||
.filter()
|
||||
.idIsNotNull()
|
||||
.isMangaEqualTo(manga.itemType == ItemType.manga)
|
||||
.mangaIdEqualTo(manga.id!)
|
||||
.findAllSync();
|
||||
|
||||
if (tracks.isEmpty) return;
|
||||
for (var track in tracks) {
|
||||
final service = isar.trackPreferences
|
||||
.filter()
|
||||
.syncIdIsNotNull()
|
||||
.syncIdEqualTo(track.syncId)
|
||||
.findFirstSync();
|
||||
if (!(service == null || chapterNumber <= (track.lastChapterRead ?? 0))) {
|
||||
if (track.status != TrackStatus.completed) {
|
||||
track.lastChapterRead = chapterNumber;
|
||||
if (track.lastChapterRead == track.totalChapter &&
|
||||
(track.totalChapter ?? 0) > 0) {
|
||||
track.status = TrackStatus.completed;
|
||||
track.finishedReadingDate = DateTime.now().millisecondsSinceEpoch;
|
||||
} else {
|
||||
track.status = manga.itemType == ItemType.manga
|
||||
? TrackStatus.reading
|
||||
: TrackStatus.watching;
|
||||
if (track.lastChapterRead == 1) {
|
||||
track.startedReadingDate = DateTime.now().millisecondsSinceEpoch;
|
||||
}
|
||||
}
|
||||
}
|
||||
ref
|
||||
.read(trackStateProvider(
|
||||
track: track, isManga: manga.itemType == ItemType.manga)
|
||||
.notifier)
|
||||
.updateManga();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension MangaExtensions on Manga {
|
||||
List<Chapter> getFilteredChapterList() {
|
||||
final data = this.chapters.toList().reversed.toList();
|
||||
final data = this.chapters.toList().toList();
|
||||
final filterUnread = (isar.settings
|
||||
.getSync(227)!
|
||||
.chapterFilterUnreadList!
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ part of 'novel_reader_controller_provider.dart';
|
|||
// **************************************************************************
|
||||
|
||||
String _$novelReaderControllerHash() =>
|
||||
r'9ac937ab7fcc82a99088128f0f12f1aaad7fa1e8';
|
||||
r'2eec885b858de8195e31a2d0b70feb56c1dc4268';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
|
|
@ -217,72 +217,86 @@ class _NovelWebViewState extends ConsumerState<NovelWebView>
|
|||
child: SingleChildScrollView(
|
||||
controller: _scrollController,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
children: [
|
||||
HtmlWidget(
|
||||
htmlContent,
|
||||
customStylesBuilder: (element) {
|
||||
switch (backgroundColor) {
|
||||
case BackgroundColor.black:
|
||||
return {
|
||||
'background-color': 'black',
|
||||
};
|
||||
default:
|
||||
return {
|
||||
'background-color': '#F0F0F0',
|
||||
};
|
||||
}
|
||||
},
|
||||
onTapUrl: (url) {
|
||||
context.push("/mangawebview",
|
||||
extra: {'url': url, 'title': url});
|
||||
return true;
|
||||
},
|
||||
renderMode: RenderMode.column,
|
||||
textStyle: TextStyle(
|
||||
color: backgroundColor ==
|
||||
BackgroundColor.white
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
fontSize: 14),
|
||||
),
|
||||
Center(
|
||||
child: IconButton(
|
||||
padding: const EdgeInsets.all(5),
|
||||
onPressed: () =>
|
||||
pushReplacementMangaReaderView(
|
||||
context: context,
|
||||
chapter:
|
||||
_readerController.getPrevChapter(),
|
||||
),
|
||||
icon: Icon(
|
||||
Icons.arrow_back,
|
||||
color: backgroundColor ==
|
||||
BackgroundColor.white
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
_isViewFunction();
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
HtmlWidget(
|
||||
htmlContent,
|
||||
customStylesBuilder: (element) {
|
||||
switch (backgroundColor) {
|
||||
case BackgroundColor.black:
|
||||
return {
|
||||
'background-color': 'black',
|
||||
};
|
||||
default:
|
||||
return {
|
||||
'background-color': '#F0F0F0',
|
||||
};
|
||||
}
|
||||
},
|
||||
onTapUrl: (url) {
|
||||
context.push("/mangawebview",
|
||||
extra: {'url': url, 'title': url});
|
||||
return true;
|
||||
},
|
||||
renderMode: RenderMode.column,
|
||||
textStyle: TextStyle(
|
||||
color: backgroundColor ==
|
||||
BackgroundColor.white
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
fontSize: 14),
|
||||
),
|
||||
Center(
|
||||
heightFactor: 2,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
spacing: 5,
|
||||
children: [
|
||||
IconButton(
|
||||
padding: const EdgeInsets.all(5),
|
||||
onPressed: () =>
|
||||
pushReplacementMangaReaderView(
|
||||
context: context,
|
||||
chapter: _readerController
|
||||
.getPrevChapter(),
|
||||
),
|
||||
icon: Icon(
|
||||
size: 32,
|
||||
Icons.arrow_back,
|
||||
color: backgroundColor ==
|
||||
BackgroundColor.white
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
padding: const EdgeInsets.all(5),
|
||||
onPressed: () =>
|
||||
pushReplacementMangaReaderView(
|
||||
context: context,
|
||||
chapter: _readerController
|
||||
.getNextChapter(),
|
||||
),
|
||||
icon: Icon(
|
||||
size: 32,
|
||||
Icons.arrow_forward,
|
||||
color: backgroundColor ==
|
||||
BackgroundColor.white
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: IconButton(
|
||||
padding: const EdgeInsets.all(5),
|
||||
onPressed: () =>
|
||||
pushReplacementMangaReaderView(
|
||||
context: context,
|
||||
chapter:
|
||||
_readerController.getNextChapter(),
|
||||
),
|
||||
icon: Icon(
|
||||
Icons.arrow_forward,
|
||||
color: backgroundColor ==
|
||||
BackgroundColor.white
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
@ -296,8 +310,8 @@ class _NovelWebViewState extends ConsumerState<NovelWebView>
|
|||
)),
|
||||
],
|
||||
),
|
||||
_gestureRightLeft(),
|
||||
_gestureTopBottom(),
|
||||
//_gestureRightLeft(),
|
||||
//_gestureTopBottom(),
|
||||
_appBar(),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'get_chapter_pages.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$getChapterPagesHash() => r'8a2606a6640046cb006b24516bf88512f3204aca';
|
||||
String _$getChapterPagesHash() => r'5b18b20360abecf1125f27c32b10977dd18f1831';
|
||||
|
||||
/// Copied from Dart SDK
|
||||
class _SystemHash {
|
||||
|
|
|
|||
Loading…
Reference in a new issue