fix
This commit is contained in:
parent
a4bae71dba
commit
f3716324b7
5 changed files with 119 additions and 73 deletions
|
|
@ -80,15 +80,7 @@ flutter {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
||||
all {
|
||||
|
||||
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
|
||||
|
||||
}
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.1"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
|
||||
}
|
||||
|
|
@ -177,14 +177,21 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
if (sortChapter == 0) {
|
||||
chapters.sort(
|
||||
(a, b) {
|
||||
return a.scanlator!.compareTo(b.scanlator!) |
|
||||
a.dateUpload!.compareTo(b.dateUpload!);
|
||||
return (a.scanlator == null ||
|
||||
b.scanlator == null ||
|
||||
a.dateUpload == null ||
|
||||
b.dateUpload == null)
|
||||
? 0
|
||||
: a.scanlator!.compareTo(b.scanlator!) |
|
||||
a.dateUpload!.compareTo(b.dateUpload!);
|
||||
},
|
||||
);
|
||||
} else if (sortChapter == 2) {
|
||||
chapters.sort(
|
||||
(a, b) {
|
||||
return a.dateUpload!.compareTo(b.dateUpload!);
|
||||
return (a.dateUpload == null || b.dateUpload == null)
|
||||
? 0
|
||||
: a.dateUpload!.compareTo(b.dateUpload!);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
@ -452,7 +459,7 @@ class _MangaDetailViewState extends ConsumerState<MangaDetailView>
|
|||
.scaffoldBackgroundColor,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets
|
||||
.symmetric(
|
||||
.symmetric(
|
||||
horizontal: 8),
|
||||
child: Text(
|
||||
widget.manga!.isManga!
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@ import 'package:mangayomi/main.dart';
|
|||
import 'package:mangayomi/models/chapter.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
import 'package:mangayomi/modules/more/settings/reader/providers/reader_state_provider.dart';
|
||||
import 'package:mangayomi/providers/l10n_providers.dart';
|
||||
import 'package:mangayomi/sources/utils/utils.dart';
|
||||
import 'package:mangayomi/modules/manga/reader/providers/push_router.dart';
|
||||
import 'package:mangayomi/services/get_chapter_url.dart';
|
||||
import 'package:mangayomi/utils/headers.dart';
|
||||
import 'package:mangayomi/utils/image_detail_info.dart';
|
||||
import 'package:mangayomi/utils/media_query.dart';
|
||||
import 'package:mangayomi/modules/manga/reader/image_view_center.dart';
|
||||
|
|
@ -23,6 +25,7 @@ import 'package:mangayomi/modules/manga/reader/providers/reader_controller_provi
|
|||
import 'package:mangayomi/modules/manga/reader/widgets/circular_progress_indicator_animate_rotate.dart';
|
||||
import 'package:mangayomi/modules/more/settings/reader/reader_screen.dart';
|
||||
import 'package:mangayomi/modules/widgets/progress_center.dart';
|
||||
import 'package:mangayomi/utils/reg_exp_matcher.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:photo_view/photo_view_gallery.dart';
|
||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||
|
|
@ -163,6 +166,45 @@ class _MangaChapterPageGalleryState
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
void _preloadImage(int index) {
|
||||
final cropBorders = ref.watch(cropBordersStateProvider);
|
||||
|
||||
if (0 <= index && index < _uChapDataPreload.length) {
|
||||
if (_cropImagesList.isNotEmpty && cropBorders == true
|
||||
? true
|
||||
: _uChapDataPreload[index].isLocale!) {
|
||||
final archiveImage = (_cropImagesList.isNotEmpty && cropBorders == true
|
||||
? _cropImagesList[index]
|
||||
: _uChapDataPreload[index].archiveImage);
|
||||
|
||||
if (archiveImage != null) {
|
||||
precacheImage(
|
||||
ExtendedMemoryImageProvider(
|
||||
(_cropImagesList.isNotEmpty && cropBorders == true
|
||||
? _cropImagesList[index]
|
||||
: _uChapDataPreload[index].archiveImage)!),
|
||||
context);
|
||||
} else {
|
||||
precacheImage(
|
||||
ExtendedFileImageProvider(File(
|
||||
"${_uChapDataPreload[index].path!.path}${padIndex(_uChapDataPreload[index].index! + 1)}.jpg")),
|
||||
context);
|
||||
}
|
||||
} else {
|
||||
precacheImage(
|
||||
ExtendedNetworkImageProvider(
|
||||
_uChapDataPreload[index].url!,
|
||||
cache: true,
|
||||
cacheMaxAge: const Duration(days: 7),
|
||||
headers: ref.watch(headersProvider(
|
||||
source: chapter.manga.value!.source!,
|
||||
lang: chapter.manga.value!.lang!)),
|
||||
),
|
||||
context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
late GetChapterUrlModel _chapterUrlModel = widget.chapterUrlModel;
|
||||
|
||||
late Chapter chapter = widget.chapter;
|
||||
|
|
@ -246,15 +288,15 @@ class _MangaChapterPageGalleryState
|
|||
List<UChapDataPreload> uChapDataPreloadP = [];
|
||||
List<UChapDataPreload> uChapDataPreloadL = _uChapDataPreload;
|
||||
List<UChapDataPreload> preChap = [];
|
||||
for (var ee in _uChapDataPreload) {
|
||||
for (var chp in _uChapDataPreload) {
|
||||
if (chapterData.uChapDataPreload.first.chapter!.url ==
|
||||
ee.chapter!.url) {
|
||||
chp.chapter!.url) {
|
||||
isExist = true;
|
||||
}
|
||||
}
|
||||
if (!isExist) {
|
||||
for (var aa in chapterData.uChapDataPreload) {
|
||||
preChap.add(aa);
|
||||
for (var ch in chapterData.uChapDataPreload) {
|
||||
preChap.add(ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -263,15 +305,7 @@ class _MangaChapterPageGalleryState
|
|||
for (var i = 0; i < preChap.length; i++) {
|
||||
int index = i + length;
|
||||
final dataPreload = preChap[i];
|
||||
uChapDataPreloadP.add(UChapDataPreload(
|
||||
dataPreload.chapter,
|
||||
dataPreload.path,
|
||||
dataPreload.url,
|
||||
dataPreload.isLocale,
|
||||
dataPreload.archiveImage,
|
||||
dataPreload.index,
|
||||
dataPreload.chapterUrlModel,
|
||||
index));
|
||||
uChapDataPreloadP.add(dataPreload..pageIndex = index);
|
||||
}
|
||||
if (mounted) {
|
||||
uChapDataPreloadL.addAll(uChapDataPreloadP);
|
||||
|
|
@ -301,6 +335,12 @@ class _MangaChapterPageGalleryState
|
|||
}
|
||||
|
||||
void _onPageChanged(int index) {
|
||||
_preloadImage(index - 3);
|
||||
_preloadImage(index - 2);
|
||||
_preloadImage(index - 1);
|
||||
_preloadImage(index + 1);
|
||||
_preloadImage(index + 2);
|
||||
_preloadImage(index + 3);
|
||||
if (_readerController.chapter.id != _uChapDataPreload[index].chapter!.id) {
|
||||
setState(() {
|
||||
_readerController =
|
||||
|
|
@ -438,7 +478,6 @@ class _MangaChapterPageGalleryState
|
|||
|
||||
late final _extendedController = ExtendedPageController(
|
||||
initialPage: _currentIndex!,
|
||||
shouldIgnorePointerWhenScrolling: false,
|
||||
);
|
||||
|
||||
double get pixelRatio => View.of(context).devicePixelRatio;
|
||||
|
|
@ -476,7 +515,7 @@ class _MangaChapterPageGalleryState
|
|||
}
|
||||
|
||||
Axis _scrollDirection = Axis.vertical;
|
||||
bool _isReversHorizontal = false;
|
||||
bool _isReverseHorizontal = false;
|
||||
|
||||
late bool _showPagesNumber = _readerController.getShowPageNumber();
|
||||
_setReaderMode(ReaderMode value, bool isInit) async {
|
||||
|
|
@ -486,7 +525,7 @@ class _MangaChapterPageGalleryState
|
|||
setState(() {
|
||||
_selectedValue = value;
|
||||
_scrollDirection = Axis.vertical;
|
||||
_isReversHorizontal = false;
|
||||
_isReverseHorizontal = false;
|
||||
});
|
||||
await Future.delayed(const Duration(milliseconds: 30));
|
||||
|
||||
|
|
@ -496,9 +535,9 @@ class _MangaChapterPageGalleryState
|
|||
if (mounted) {
|
||||
setState(() {
|
||||
if (value == ReaderMode.rtl) {
|
||||
_isReversHorizontal = true;
|
||||
_isReverseHorizontal = true;
|
||||
} else {
|
||||
_isReversHorizontal = false;
|
||||
_isReverseHorizontal = false;
|
||||
}
|
||||
_selectedValue = value;
|
||||
_scrollDirection = Axis.horizontal;
|
||||
|
|
@ -511,7 +550,7 @@ class _MangaChapterPageGalleryState
|
|||
if (mounted) {
|
||||
setState(() {
|
||||
_selectedValue = value;
|
||||
_isReversHorizontal = false;
|
||||
_isReverseHorizontal = false;
|
||||
});
|
||||
await Future.delayed(const Duration(milliseconds: 30));
|
||||
_itemScrollController.scrollTo(
|
||||
|
|
@ -533,11 +572,19 @@ class _MangaChapterPageGalleryState
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
height: _isView ? 80 : 0,
|
||||
height: _isView
|
||||
? Platform.isIOS
|
||||
? 120
|
||||
: 80
|
||||
: 0,
|
||||
curve: Curves.ease,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: PreferredSize(
|
||||
preferredSize: Size.fromHeight(_isView ? 80 : 0),
|
||||
preferredSize: Size.fromHeight(_isView
|
||||
? Platform.isIOS
|
||||
? 120
|
||||
: 80
|
||||
: 0),
|
||||
child: AppBar(
|
||||
centerTitle: false,
|
||||
automaticallyImplyLeading: false,
|
||||
|
|
@ -643,7 +690,7 @@ class _MangaChapterPageGalleryState
|
|||
),
|
||||
Expanded(
|
||||
child: Transform.scale(
|
||||
scaleX: !_isReversHorizontal ? 1 : -1,
|
||||
scaleX: !_isReverseHorizontal ? 1 : -1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Container(
|
||||
|
|
@ -656,7 +703,7 @@ class _MangaChapterPageGalleryState
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
child: Transform.scale(
|
||||
scaleX: !_isReversHorizontal ? 1 : -1,
|
||||
scaleX: !_isReverseHorizontal ? 1 : -1,
|
||||
child: SizedBox(
|
||||
width: 30,
|
||||
child: Consumer(
|
||||
|
|
@ -729,7 +776,7 @@ class _MangaChapterPageGalleryState
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
child: Transform.scale(
|
||||
scaleX: !_isReversHorizontal ? 1 : -1,
|
||||
scaleX: !_isReverseHorizontal ? 1 : -1,
|
||||
child: SizedBox(
|
||||
width: 30,
|
||||
child: Text(
|
||||
|
|
@ -932,7 +979,7 @@ class _MangaChapterPageGalleryState
|
|||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
if (_isReverseHorizontal) {
|
||||
_onBtnTapped(_currentIndex! + 1, false);
|
||||
} else {
|
||||
_onBtnTapped(_currentIndex! - 1, true);
|
||||
|
|
@ -970,7 +1017,7 @@ class _MangaChapterPageGalleryState
|
|||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
if (_isReversHorizontal) {
|
||||
if (_isReverseHorizontal) {
|
||||
_onBtnTapped(_currentIndex! - 1, true);
|
||||
} else {
|
||||
_onBtnTapped(_currentIndex! + 1, false);
|
||||
|
|
@ -1085,7 +1132,6 @@ class _MangaChapterPageGalleryState
|
|||
basePosition: _scalePosition,
|
||||
onScaleEnd: _onScaleEnd,
|
||||
child: ScrollablePositionedList.separated(
|
||||
// scrollOffsetController: _scrollController,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
minCacheExtent: 15 * mediaHeight(context, 1),
|
||||
initialScrollIndex: _currentIndex!,
|
||||
|
|
@ -1133,7 +1179,7 @@ class _MangaChapterPageGalleryState
|
|||
child: ExtendedImageGesturePageView.builder(
|
||||
controller: _extendedController,
|
||||
scrollDirection: _scrollDirection,
|
||||
reverse: _isReversHorizontal,
|
||||
reverse: _isReverseHorizontal,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
canScrollPage: (GestureDetails? gestureDetails) {
|
||||
return gestureDetails != null
|
||||
|
|
@ -1304,6 +1350,7 @@ class _MangaChapterPageGalleryState
|
|||
}
|
||||
|
||||
_showModalSettings() {
|
||||
final l10n = l10nLocalizations(context)!;
|
||||
DraggableMenu.open(
|
||||
context,
|
||||
DraggableMenu(
|
||||
|
|
@ -1319,11 +1366,11 @@ class _MangaChapterPageGalleryState
|
|||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'Settings',
|
||||
style: TextStyle(
|
||||
l10n.settings,
|
||||
style: const TextStyle(
|
||||
fontSize: 17, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
|
|
@ -1334,7 +1381,7 @@ class _MangaChapterPageGalleryState
|
|||
children: [
|
||||
SwitchListTile(
|
||||
dense: true,
|
||||
title: const Text('Show Page Number'),
|
||||
title: Text(l10n.show_page_number),
|
||||
value: _showPagesNumber,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
|
|
@ -1355,14 +1402,14 @@ class _MangaChapterPageGalleryState
|
|||
}
|
||||
|
||||
class UChapDataPreload {
|
||||
final Chapter? chapter;
|
||||
final Directory? path;
|
||||
final String? url;
|
||||
final bool? isLocale;
|
||||
final Uint8List? archiveImage;
|
||||
final int? index;
|
||||
final GetChapterUrlModel? chapterUrlModel;
|
||||
final int? pageIndex;
|
||||
Chapter? chapter;
|
||||
Directory? path;
|
||||
String? url;
|
||||
bool? isLocale;
|
||||
Uint8List? archiveImage;
|
||||
int? index;
|
||||
GetChapterUrlModel? chapterUrlModel;
|
||||
int? pageIndex;
|
||||
UChapDataPreload(
|
||||
this.chapter,
|
||||
this.path,
|
||||
|
|
|
|||
32
pubspec.lock
32
pubspec.lock
|
|
@ -445,10 +445,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: flex_color_scheme
|
||||
sha256: "57feb7e5b783e843a43e7d2713b0b0a58941ac3abc0439501290661cad4183a5"
|
||||
sha256: "32914024a4f404d90ff449f58d279191675b28e7c08824046baf06826e99d984"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.3.0"
|
||||
version: "7.3.1"
|
||||
flex_seed_scheme:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -519,10 +519,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_meedu_videoplayer
|
||||
sha256: "8f4880ac0dbe1662ea8d0d03e35c86ea5696651600b59e9005f5607fbb9a8b6f"
|
||||
sha256: "9fe1e0951c0742f84637be0aa4eac4073a2a6f394e9d0f08c4e93e4ae3d93caf"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.2.24"
|
||||
version: "4.2.26"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -617,10 +617,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
sha256: b3cadd2cd59a4103fd5f6bc572ca75111264698784e927aa471921c3477d5475
|
||||
sha256: "2aa884667eeda3a1c461f31e72af1f77984ab0f29450d8fb12ec1f7bc53eea14"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.0.0"
|
||||
version: "10.1.0"
|
||||
google_fonts:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -833,10 +833,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: media_kit
|
||||
sha256: "0a89e7037002a62701ec319c375586849f9ef8e681820e1dd4a4ff7b843f7542"
|
||||
sha256: eb47c2d51b7c06b319d8c776b47be912c5a4f53af7ab4814927a52a76442609e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.4+1"
|
||||
version: "1.1.2+1"
|
||||
media_kit_libs_android_video:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -857,10 +857,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: media_kit_libs_linux
|
||||
sha256: "570bf18ebbd1221caec082657468be05d180510385d3515ec38e0be44fdcc859"
|
||||
sha256: "838b9e8041d376873cc938872c75812989d0feb247ad93afd8dbc92bf052680a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
version: "1.1.0"
|
||||
media_kit_libs_macos_video:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -873,10 +873,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: media_kit_libs_windows_video
|
||||
sha256: f33aabd8414470d99e2c91dd98d605e6a5f1c4b8082dd933c10951bc961b9124
|
||||
sha256: "31c6c75ab08627df9fce7ce2431e5ac5e5990ac40faef75b07c48d1d7907a37f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.7"
|
||||
version: "1.0.6"
|
||||
media_kit_native_event_loop:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -889,10 +889,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: media_kit_video
|
||||
sha256: e7fcbe426d42a78ad6696f8f557adb9cbdc012177829026d04992cc106a1c815
|
||||
sha256: "4b627683ef9e7f5cd049fd01be4b5deb5f31effc878503f108c81b19fd745040"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.5"
|
||||
version: "1.1.2"
|
||||
meedu:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1598,10 +1598,10 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: video_player_media_kit
|
||||
sha256: "5f52455b3dc7df286a50b40629e7662e87a1c4bf282fa771d10223618a7fac8b"
|
||||
sha256: "486c7704ddcc4324c841a362bc028198ce830c919a5d057dec360272f3d5b6dc"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.23"
|
||||
version: "0.0.26"
|
||||
video_player_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ dependencies:
|
|||
flutter_web_auth_2: ^2.1.5
|
||||
numberpicker: ^2.1.2
|
||||
encrypt: ^5.0.1
|
||||
flutter_meedu_videoplayer: ^4.2.24
|
||||
flutter_meedu_videoplayer: ^4.2.26
|
||||
media_kit_libs_android_video: ^1.3.2
|
||||
media_kit_libs_ios_video: ^1.1.3
|
||||
js_packer: ^0.0.5
|
||||
|
|
|
|||
Loading…
Reference in a new issue