diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3bd4ff40..6f410b9b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -5,7 +5,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - mangayomi + Mangayomi CFBundlePackageType APPL CFBundleShortVersionString diff --git a/lib/services/get_manga_chapter_url.dart b/lib/services/get_manga_chapter_url.dart index 7bf74544..46cbba0e 100644 --- a/lib/services/get_manga_chapter_url.dart +++ b/lib/services/get_manga_chapter_url.dart @@ -11,6 +11,7 @@ import 'package:mangayomi/providers/storage_provider.dart'; import 'package:mangayomi/services/get_popular_manga.dart'; import 'package:mangayomi/services/http_res_to_dom_html.dart'; import 'package:mangayomi/source/source_model.dart'; +import 'package:mangayomi/utils/reg_exp_matcher.dart'; import 'package:mangayomi/views/more/settings/providers/incognito_mode_state_provider.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:flutter_js/flutter_js.dart'; @@ -19,7 +20,9 @@ part 'get_manga_chapter_url.g.dart'; class GetMangaChapterUrlModel { Directory? path; List urll = []; - GetMangaChapterUrlModel({required this.path, required this.urll}); + List isLocaleList = []; + GetMangaChapterUrlModel( + {required this.path, required this.urll, required this.isLocaleList}); } @riverpod @@ -30,6 +33,7 @@ Future getMangaChapterUrl( }) async { Directory? path; List urll = []; + List isLocaleList = []; String source = modelManga.source!.toLowerCase(); List pagesUrl = ref.watch(hiveBoxMangaInfo).get( "${modelManga.lang}-${modelManga.source}/${modelManga.name}/${modelManga.chapters![index].name}-pageurl", @@ -130,7 +134,8 @@ Future getMangaChapterUrl( /***********/ else if (modelManga.source == 'mangakawaii') { - final response = await http.get(Uri.parse(modelManga.chapters![index].url!)); + final response = + await http.get(Uri.parse(modelManga.chapters![index].url!)); var chapterSlug = RegExp("""var chapter_slug = "([^"]*)";""") .allMatches(response.body.toString()) .last @@ -307,6 +312,16 @@ Future getMangaChapterUrl( } } } + if (urll.isNotEmpty) { + for (var i = 0; i < urll.length; i++) { + if (await File("${path!.path}" "${padIndex(i + 1)}.jpg").exists()) { + isLocaleList.add(true); + } else { + isLocaleList.add(false); + } + } + } - return GetMangaChapterUrlModel(path: path, urll: urll); + return GetMangaChapterUrlModel( + path: path, urll: urll, isLocaleList: isLocaleList); } diff --git a/lib/services/get_popular_manga.dart b/lib/services/get_popular_manga.dart index 3f94dfbc..342db46d 100644 --- a/lib/services/get_popular_manga.dart +++ b/lib/services/get_popular_manga.dart @@ -196,7 +196,7 @@ Future getPopularManga(GetPopularMangaRef ref, ' body > div.container.weekrank.ranking > div > div > ul > li > a > img') .where((e) => e.attributes.containsKey('src')) .where((e) => e.attributes['src']!.contains("cover")) - .map((e) => e.attributes['src']) + .map((e) => e.attributes['src']!.split('?').first) .toList(); name = dom diff --git a/lib/utils/headers.dart b/lib/utils/headers.dart index e6fec57e..5d8fe2c5 100644 --- a/lib/utils/headers.dart +++ b/lib/utils/headers.dart @@ -1,4 +1,8 @@ +import 'dart:developer'; + Map headers(String source) { + source = source.toLowerCase(); + log(source); return source == 'mangakawaii' ? { 'Referer': 'https://www.mangakawaii.io/', diff --git a/lib/views/general/general_screen.dart b/lib/views/general/general_screen.dart index f9d12ff4..0c6a8ef3 100644 --- a/lib/views/general/general_screen.dart +++ b/lib/views/general/general_screen.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; @@ -6,16 +8,16 @@ import 'package:mangayomi/utils/colors.dart'; import 'package:mangayomi/utils/media_query.dart'; import 'package:mangayomi/views/more/settings/providers/incognito_mode_state_provider.dart'; -class GeneralScreen extends ConsumerStatefulWidget { +class GeneralScreen extends StatefulWidget { const GeneralScreen({super.key, required this.child}); final Widget child; @override - ConsumerState createState() => _GeneralScreenState(); + State createState() => _GeneralScreenState(); } -class _GeneralScreenState extends ConsumerState { +class _GeneralScreenState extends State { @override Widget build(BuildContext context) { final route = GoRouter.of(context); @@ -36,8 +38,11 @@ class _GeneralScreenState extends ConsumerState { final incognitoMode = ref.watch(incognitoModeStateProvider); return Material( child: AnimatedContainer( - height: - incognitoMode ? MediaQuery.of(context).padding.top * 2 : 0, + height: incognitoMode + ? Platform.isAndroid || Platform.isIOS + ? MediaQuery.of(context).padding.top * 2 + : 50 + : 0, curve: Curves.easeIn, duration: const Duration(milliseconds: 150), color: generalColor(context), diff --git a/lib/views/manga/detail/manga_detail_view.dart b/lib/views/manga/detail/manga_detail_view.dart index 7b323475..2e07b34a 100644 --- a/lib/views/manga/detail/manga_detail_view.dart +++ b/lib/views/manga/detail/manga_detail_view.dart @@ -211,7 +211,7 @@ class _MangaDetailViewState extends ConsumerState controller: _scrollController, child: ListView.builder( controller: _scrollController, - padding: const EdgeInsets.only(top: 0), + padding: const EdgeInsets.only(top: 0, bottom: 60), itemCount: widget.listLength, itemBuilder: (context, index) { int finalIndex = index - 1; diff --git a/lib/views/manga/detail/widgets/chapter_list_tile_widget.dart b/lib/views/manga/detail/widgets/chapter_list_tile_widget.dart index 8d7ab943..15454bec 100644 --- a/lib/views/manga/detail/widgets/chapter_list_tile_widget.dart +++ b/lib/views/manga/detail/widgets/chapter_list_tile_widget.dart @@ -81,9 +81,12 @@ class ChapterListTileWidget extends ConsumerWidget { color: generalColor(context), ) : Container(), - Text( - chapters[finalIndex].name!, - style: const TextStyle(fontSize: 13), + Flexible( + child: Text( + chapters[finalIndex].name!, + style: const TextStyle(fontSize: 13), + overflow: TextOverflow.ellipsis, + ), ), ], ), diff --git a/lib/views/manga/reader/image_view_horizontal.dart b/lib/views/manga/reader/image_view_horizontal.dart index 6a204a4d..3d7d610c 100644 --- a/lib/views/manga/reader/image_view_horizontal.dart +++ b/lib/views/manga/reader/image_view_horizontal.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:mangayomi/utils/headers.dart'; import 'package:mangayomi/utils/reg_exp_matcher.dart'; -class ImageViewHorizontal extends StatefulWidget { +class ImageViewHorizontal extends StatelessWidget { final int length; final String url; final int index; @@ -12,6 +12,7 @@ class ImageViewHorizontal extends StatefulWidget { final String source; final String chapter; final Directory path; + final bool isLocale; final Widget? Function(ExtendedImageState state) loadStateChanged; final Function(ExtendedImageGestureState state) onDoubleTap; final GestureConfig Function(ExtendedImageState state) @@ -28,70 +29,33 @@ class ImageViewHorizontal extends StatefulWidget { required this.loadStateChanged, required this.onDoubleTap, required this.initGestureConfigHandler, + required this.isLocale, }); - @override - State createState() => _ImageViewHorizontalState(); -} - -typedef DoubleClickAnimationListener = void Function(); - -class _ImageViewHorizontalState extends State { - @override - void initState() { - _localCheck(); - super.initState(); - } - - _localCheck() async { - if (await File("${widget.path.path}" "${padIndex(widget.index + 1)}.jpg") - .exists()) { - if (mounted) { - setState(() { - _isLocale = true; - _isLoading = false; - }); - } - } else { - if (mounted) { - setState(() { - _isLocale = false; - _isLoading = false; - }); - } - } - } - - bool _isLoading = true; - bool _isLocale = false; @override Widget build(BuildContext context) { - return _isLoading - ? const Center( - child: CircularProgressIndicator(), + return isLocale + ? ExtendedImage.file( + File("${path.path}" "${padIndex(index + 1)}.jpg"), + clearMemoryCacheWhenDispose: true, + enableMemoryCache: false, + mode: ExtendedImageMode.gesture, + initGestureConfigHandler: initGestureConfigHandler, + onDoubleTap: onDoubleTap, + loadStateChanged: loadStateChanged, ) - : _isLocale - ? ExtendedImage.file( - File("${widget.path.path}" "${padIndex(widget.index + 1)}.jpg"), - clearMemoryCacheWhenDispose: true, - enableMemoryCache: false, - mode: ExtendedImageMode.gesture, - initGestureConfigHandler: widget.initGestureConfigHandler, - onDoubleTap: widget.onDoubleTap, - loadStateChanged: widget.loadStateChanged, - ) - : ExtendedImage.network( - widget.url, - cache: true, - clearMemoryCacheWhenDispose: true, - enableMemoryCache: false, - cacheMaxAge: const Duration(days: 7), - headers: headers(widget.source), - mode: ExtendedImageMode.gesture, - initGestureConfigHandler: widget.initGestureConfigHandler, - onDoubleTap: widget.onDoubleTap, - handleLoadingProgress: true, - loadStateChanged: widget.loadStateChanged, - ); + : ExtendedImage.network( + url, + cache: true, + clearMemoryCacheWhenDispose: true, + enableMemoryCache: false, + cacheMaxAge: const Duration(days: 7), + headers: headers(source), + mode: ExtendedImageMode.gesture, + initGestureConfigHandler: initGestureConfigHandler, + onDoubleTap: onDoubleTap, + handleLoadingProgress: true, + loadStateChanged: loadStateChanged, + ); } } diff --git a/lib/views/manga/reader/image_view_vertical.dart b/lib/views/manga/reader/image_view_vertical.dart index 6ec352cc..08aec62a 100644 --- a/lib/views/manga/reader/image_view_vertical.dart +++ b/lib/views/manga/reader/image_view_vertical.dart @@ -7,9 +7,9 @@ import 'package:mangayomi/utils/headers.dart'; import 'package:mangayomi/utils/media_query.dart'; import 'package:mangayomi/utils/reg_exp_matcher.dart'; -class ImageViewVertical extends ConsumerStatefulWidget { +class ImageViewVertical extends StatelessWidget { final int length; - + final bool isLocale; final String url; final int index; final String titleManga; @@ -17,142 +17,99 @@ class ImageViewVertical extends ConsumerStatefulWidget { final String chapter; final Directory path; - const ImageViewVertical( - {super.key, - required this.url, - required this.chapter, - required this.index, - required this.path, - required this.titleManga, - required this.source, - required this.length}); + const ImageViewVertical({ + super.key, + required this.url, + required this.chapter, + required this.index, + required this.path, + required this.titleManga, + required this.source, + required this.length, + required this.isLocale, + }); - @override - ConsumerState createState() => _ImageViewVerticalState(); -} - -class _ImageViewVerticalState extends ConsumerState - with AutomaticKeepAliveClientMixin { - @override - void initState() { - _localCheck(); - super.initState(); - } - - _localCheck() async { - if (await File("${widget.path.path}" "${padIndex(widget.index + 1)}.jpg") - .exists()) { - if (mounted) { - setState(() { - _isLocale = true; - _isLoading = false; - }); - } - } else { - if (mounted) { - setState(() { - _isLocale = false; - _isLoading = false; - }); - } - } - } - - bool _isLoading = true; - bool _isLocale = false; @override Widget build(BuildContext context) { - super.build(context); return Container( color: Colors.black, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - if (widget.index == 0) + if (index == 0) SizedBox( height: MediaQuery.of(context).padding.top, ), - _isLoading - ? SizedBox( - height: mediaHeight(context, 0.8), - child: const Center( - child: SizedBox( - height: 35, - width: 35, - child: CircularProgressIndicator()), - ), - ) - : _isLocale - ? ExtendedImage.file( - fit: BoxFit.contain, - clearMemoryCacheWhenDispose: true, - enableMemoryCache: false, - File( - '${widget.path.path}${padIndex(widget.index + 1)}.jpg')) - : ExtendedImage.network(widget.url, - headers: headers(widget.source), - handleLoadingProgress: true, - fit: BoxFit.contain, - cacheMaxAge: const Duration(days: 7), - clearMemoryCacheWhenDispose: true, - enableMemoryCache: false, - loadStateChanged: (ExtendedImageState state) { - if (state.extendedImageLoadState == LoadState.loading) { - final ImageChunkEvent? loadingProgress = - state.loadingProgress; - final double progress = - loadingProgress?.expectedTotalBytes != null - ? loadingProgress!.cumulativeBytesLoaded / - loadingProgress.expectedTotalBytes! - : 0; - return TweenAnimationBuilder( - duration: const Duration(milliseconds: 500), - curve: Curves.easeInOut, - tween: Tween( - begin: 0, - end: progress, - ), - builder: (context, value, _) => Container( - color: Colors.black, - height: mediaHeight(context, 0.8), - child: Center( - child: progress == 0 - ? const CircularProgressIndicator() - : CircularProgressIndicator( - value: progress, - ), - ), - ), - ); - } - if (state.extendedImageLoadState == LoadState.failed) { - return Container( - color: Colors.black, - height: mediaHeight(context, 0.8), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ElevatedButton( - onPressed: () { - state.reLoadImage(); - }, - child: const Icon( - Icons.replay_outlined, - size: 30, - )), - ], - )); - } - return null; - }), - if (widget.index + 1 == widget.length) + isLocale + ? ExtendedImage.file( + fit: BoxFit.contain, + clearMemoryCacheWhenDispose: true, + enableMemoryCache: false, + File('${path.path}${padIndex(index + 1)}.jpg')) + : ExtendedImage.network(url, + headers: headers(source), + handleLoadingProgress: true, + fit: BoxFit.contain, + cacheMaxAge: const Duration(days: 7), + clearMemoryCacheWhenDispose: true, + enableMemoryCache: false, + loadStateChanged: (ExtendedImageState state) { + if (state.extendedImageLoadState == LoadState.loading) { + final ImageChunkEvent? loadingProgress = + state.loadingProgress; + final double progress = + loadingProgress?.expectedTotalBytes != null + ? loadingProgress!.cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes! + : 0; + return TweenAnimationBuilder( + duration: const Duration(milliseconds: 500), + curve: Curves.easeInOut, + tween: Tween( + begin: 0, + end: progress, + ), + builder: (context, value, _) => Container( + color: Colors.black, + height: mediaHeight(context, 0.8), + child: Center( + child: progress == 0 + ? const CircularProgressIndicator() + : CircularProgressIndicator( + value: progress, + ), + ), + ), + ); + } + if (state.extendedImageLoadState == LoadState.failed) { + return Container( + color: Colors.black, + height: mediaHeight(context, 0.8), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + onPressed: () { + state.reLoadImage(); + }, + child: const Icon( + Icons.replay_outlined, + size: 30, + )), + ], + )); + } + return null; + }), + if (index + 1 == length) SizedBox( height: mediaHeight(context, 0.3), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - '${widget.chapter} finished', + '$chapter finished', style: const TextStyle( fontSize: 17.0, fontWeight: FontWeight.bold, diff --git a/lib/views/manga/reader/manga_reader_view.dart b/lib/views/manga/reader/manga_reader_view.dart index 278fdac6..586ba9e8 100644 --- a/lib/views/manga/reader/manga_reader_view.dart +++ b/lib/views/manga/reader/manga_reader_view.dart @@ -20,6 +20,8 @@ import 'package:photo_view/photo_view_gallery.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; import 'package:collection/collection.dart'; +typedef DoubleClickAnimationListener = void Function(); + class MangaReaderView extends ConsumerWidget { final MangaReaderModel mangaReaderModel; const MangaReaderView({ @@ -43,6 +45,7 @@ class MangaReaderView extends ConsumerWidget { path: data.path!, url: data.urll, readerController: readerController, + isLocaleList: data.isLocaleList, ); }, error: (error, stackTrace) => Scaffold( @@ -104,10 +107,12 @@ class MangaChapterPageGallery extends ConsumerStatefulWidget { {super.key, required this.path, required this.url, - required this.readerController}); + required this.readerController, + required this.isLocaleList}); final ReaderController readerController; final Directory path; final List url; + final List isLocaleList; @override ConsumerState createState() { @@ -122,7 +127,7 @@ class _MangaChapterPageGalleryState ItemScrollController(); late AnimationController _scaleAnimationController; late Animation _animation; - + late int _currentIndex = widget.readerController.getPageIndex(); @override void dispose() { _rebuildDetail.close(); @@ -157,10 +162,9 @@ class _MangaChapterPageGalleryState void _onPageChanged(int index) { widget.readerController.setMangaHistoryUpdate(); if (mounted) { - ref - .read(currentIndexProvider(widget.readerController.mangaReaderModel) - .notifier) - .setCurrentIndex(index); + setState(() { + _currentIndex = index; + }); if (_imageDetailY != 0) { _imageDetailY = 0; _rebuildDetail.sink.add(_imageDetailY); @@ -174,10 +178,16 @@ class _MangaChapterPageGalleryState if (_selectedValue == ReaderMode.verticalContinuous || _selectedValue == ReaderMode.webtoon) { if (index != -1) { - _itemScrollController.scrollTo( - curve: Curves.ease, + if (isSlide) { + _itemScrollController.jumpTo( index: index, - duration: Duration(milliseconds: isSlide ? 2 : 150)); + ); + } else { + _itemScrollController.scrollTo( + curve: Curves.ease, + index: index, + duration: Duration(milliseconds: isSlide ? 2 : 150)); + } } } else { if (index != -1) { @@ -192,10 +202,16 @@ class _MangaChapterPageGalleryState if (_selectedValue == ReaderMode.verticalContinuous || _selectedValue == ReaderMode.webtoon) { if (widget.readerController.getPageLength(widget.url) != index) { - _itemScrollController.scrollTo( - curve: Curves.ease, + if (isSlide) { + _itemScrollController.jumpTo( index: index, - duration: Duration(milliseconds: isSlide ? 2 : 150)); + ); + } else { + _itemScrollController.scrollTo( + curve: Curves.ease, + index: index, + duration: Duration(milliseconds: isSlide ? 2 : 150)); + } } } else { if (widget.readerController.getPageLength(widget.url) != index) { @@ -235,10 +251,9 @@ class _MangaChapterPageGalleryState void _recordReadProgress(int index) { widget.readerController.setMangaHistoryUpdate(); if (mounted) { - ref - .read(currentIndexProvider(widget.readerController.mangaReaderModel) - .notifier) - .setCurrentIndex(index); + setState(() { + _currentIndex = index; + }); } widget.readerController.setPageIndex(index); } @@ -261,7 +276,7 @@ class _MangaChapterPageGalleryState } late final _extendedController = ExtendedPageController( - initialPage: widget.readerController.getPageIndex(), + initialPage: _currentIndex, shouldIgnorePointerWhenScrolling: false, ); double get pixelRatio => ui.window.devicePixelRatio; @@ -315,8 +330,7 @@ class _MangaChapterPageGalleryState if (isInit) { await Future.delayed(const Duration(milliseconds: 30)); } - _extendedController.jumpToPage(ref.watch( - currentIndexProvider(widget.readerController.mangaReaderModel))); + _extendedController.jumpToPage(_currentIndex); } } else if (value == ReaderMode.ltr || value == ReaderMode.rtl) { if (mounted) { @@ -332,8 +346,7 @@ class _MangaChapterPageGalleryState if (isInit) { await Future.delayed(const Duration(milliseconds: 30)); } - _extendedController.jumpToPage(ref.watch( - currentIndexProvider(widget.readerController.mangaReaderModel))); + _extendedController.jumpToPage(_currentIndex); } } else { if (mounted) { @@ -345,9 +358,7 @@ class _MangaChapterPageGalleryState await Future.delayed(const Duration(milliseconds: 30)); } _itemScrollController.scrollTo( - index: ref.watch( - currentIndexProvider(widget.readerController.mangaReaderModel)), - duration: const Duration(milliseconds: 1)); + index: _currentIndex, duration: const Duration(milliseconds: 1)); } } } @@ -460,7 +471,7 @@ class _MangaChapterPageGalleryState Padding( padding: const EdgeInsets.only(left: 12), child: Text( - "${ref.watch(currentIndexProvider(widget.readerController.mangaReaderModel)) + 1} ", + "${_currentIndex + 1} ", style: const TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, @@ -492,11 +503,7 @@ class _MangaChapterPageGalleryState .getPageLength(widget.url) - 1, 1), - value: ref - .watch(currentIndexProvider(widget - .readerController - .mangaReaderModel)) - .toDouble(), + value: _currentIndex.toDouble(), min: 0, max: (widget.readerController .getPageLength(widget.url) - @@ -509,7 +516,7 @@ class _MangaChapterPageGalleryState Padding( padding: const EdgeInsets.only(right: 12), child: Text( - "${ref.watch(currentIndexProvider(widget.readerController.mangaReaderModel)) + 1} ", + "${_currentIndex + 1} ", style: const TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, @@ -647,7 +654,7 @@ class _MangaChapterPageGalleryState ? Align( alignment: Alignment.bottomCenter, child: Text( - '${ref.watch(currentIndexProvider(widget.readerController.mangaReaderModel)) + 1} / ${widget.readerController.getPageLength(widget.url)}', + '${_currentIndex + 1} / ${widget.readerController.getPageLength(widget.url)}', style: const TextStyle( fontSize: 12.0, color: Colors.white, @@ -681,8 +688,6 @@ class _MangaChapterPageGalleryState Widget _gestureRightLeft() { return Consumer( builder: (context, ref, child) { - final currentIndex = ref.watch( - currentIndexProvider(widget.readerController.mangaReaderModel)); return Row( children: [ /// left region @@ -693,9 +698,9 @@ class _MangaChapterPageGalleryState behavior: HitTestBehavior.translucent, onTap: () { if (_isReversHorizontal) { - _onAddButtonTapped(currentIndex + 1, false); + _onAddButtonTapped(_currentIndex + 1, false); } else { - _onAddButtonTapped(currentIndex - 1, true); + _onAddButtonTapped(_currentIndex - 1, true); } }, onDoubleTapDown: (TapDownDetails details) { @@ -710,9 +715,9 @@ class _MangaChapterPageGalleryState behavior: HitTestBehavior.translucent, onTap: () { if (_isReversHorizontal) { - _onAddButtonTapped(currentIndex + 1, false); + _onAddButtonTapped(_currentIndex + 1, false); } else { - _onAddButtonTapped(currentIndex - 1, true); + _onAddButtonTapped(_currentIndex - 1, true); } }, ), @@ -751,9 +756,9 @@ class _MangaChapterPageGalleryState behavior: HitTestBehavior.translucent, onTap: () { if (_isReversHorizontal) { - _onAddButtonTapped(currentIndex - 1, true); + _onAddButtonTapped(_currentIndex - 1, true); } else { - _onAddButtonTapped(currentIndex + 1, false); + _onAddButtonTapped(_currentIndex + 1, false); } }, onDoubleTapDown: (TapDownDetails details) { @@ -768,9 +773,9 @@ class _MangaChapterPageGalleryState behavior: HitTestBehavior.translucent, onTap: () { if (_isReversHorizontal) { - _onAddButtonTapped(currentIndex - 1, true); + _onAddButtonTapped(_currentIndex - 1, true); } else { - _onAddButtonTapped(currentIndex + 1, false); + _onAddButtonTapped(_currentIndex + 1, false); } }, ), @@ -784,8 +789,6 @@ class _MangaChapterPageGalleryState Widget _gestureTopBottom() { return Consumer( builder: (context, ref, child) { - final currentIndex = ref.watch( - currentIndexProvider(widget.readerController.mangaReaderModel)); return Column( children: [ /// top region @@ -795,7 +798,7 @@ class _MangaChapterPageGalleryState child: GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { - _onAddButtonTapped(currentIndex - 1, true); + _onAddButtonTapped(_currentIndex - 1, true); }, onDoubleTapDown: (TapDownDetails details) { _toggleScale(details.globalPosition); @@ -808,7 +811,7 @@ class _MangaChapterPageGalleryState child: GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { - _onAddButtonTapped(currentIndex - 1, true); + _onAddButtonTapped(_currentIndex - 1, true); }, ), ), @@ -823,7 +826,7 @@ class _MangaChapterPageGalleryState child: GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { - _onAddButtonTapped(currentIndex + 1, false); + _onAddButtonTapped(_currentIndex + 1, false); }, onDoubleTapDown: (TapDownDetails details) { _toggleScale(details.globalPosition); @@ -836,7 +839,7 @@ class _MangaChapterPageGalleryState child: GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { - _onAddButtonTapped(currentIndex + 1, false); + _onAddButtonTapped(_currentIndex + 1, false); }, ), ), @@ -885,8 +888,7 @@ class _MangaChapterPageGalleryState child: ScrollablePositionedList.separated( physics: const ClampingScrollPhysics(), minCacheExtent: 8 * (MediaQuery.of(context).size.height), - initialScrollIndex: - widget.readerController.getPageIndex(), + initialScrollIndex: _currentIndex, itemCount: widget.readerController.getPageLength(widget.url), itemScrollController: _itemScrollController, @@ -899,13 +901,18 @@ class _MangaChapterPageGalleryState onDoubleTap: () {}, child: ImageViewVertical( titleManga: widget.readerController.getMangaName(), - source: widget.readerController.getSourceName(), + source: widget.readerController + .getSourceName() + .replaceAll( + '${widget.readerController.mangaReaderModel.modelManga.lang}-', + ''), index: index, url: widget.url[index], path: widget.path, chapter: widget.readerController.getChapterTitle(), length: widget.readerController.getPageLength(widget.url), + isLocale: widget.isLocaleList[index], ), ), separatorBuilder: (_, __) => Divider( @@ -930,7 +937,11 @@ class _MangaChapterPageGalleryState itemBuilder: (BuildContext context, int index) { return ImageViewHorizontal( titleManga: widget.readerController.getMangaName(), - source: widget.readerController.getSourceName(), + source: widget.readerController + .getSourceName() + .replaceAll( + '${widget.readerController.mangaReaderModel.modelManga.lang}-', + ''), index: index, url: widget.url[index], path: widget.path, @@ -1075,6 +1086,9 @@ class _MangaChapterPageGalleryState _doubleClickAnimationController.forward(); }, + isLocale: _isReversHorizontal + ? widget.isLocaleList.reversed.toList()[index] + : widget.isLocaleList[index], ); }, itemCount: diff --git a/lib/views/more/settings/appearance/providers/flex_scheme_color_state_provider.dart b/lib/views/more/settings/appearance/providers/flex_scheme_color_state_provider.dart index 5adf997a..8cc78cfd 100644 --- a/lib/views/more/settings/appearance/providers/flex_scheme_color_state_provider.dart +++ b/lib/views/more/settings/appearance/providers/flex_scheme_color_state_provider.dart @@ -8,18 +8,17 @@ part 'flex_scheme_color_state_provider.g.dart'; class FlexSchemeColorState extends _$FlexSchemeColorState { @override FlexSchemeColor build() { - if (ref.read(themeModeStateProvider)) { - if (ref.watch(hiveBoxSettings).get('FlexColorIndex') != null) { - state = ThemeAA - .schemes[ref.watch(hiveBoxSettings).get('FlexColorIndex')].light; - } - } else { - if (ref.watch(hiveBoxSettings).get('FlexColorIndex') != null) { - state = ThemeAA - .schemes[ref.watch(hiveBoxSettings).get('FlexColorIndex')].dark; - } - } - return state; + return ref.read(themeModeStateProvider) + ? ThemeAA + .schemes[ref + .watch(hiveBoxSettings) + .get('FlexColorIndex', defaultValue: 2)] + .light + : ThemeAA + .schemes[ref + .watch(hiveBoxSettings) + .get('FlexColorIndex', defaultValue: 2)] + .dark; } void setTheme(FlexSchemeColor color, int index) { diff --git a/lib/views/more/settings/appearance/widgets/blend_level_slider.dart b/lib/views/more/settings/appearance/widgets/blend_level_slider.dart index 4cf19298..7c1aa8d7 100644 --- a/lib/views/more/settings/appearance/widgets/blend_level_slider.dart +++ b/lib/views/more/settings/appearance/widgets/blend_level_slider.dart @@ -22,7 +22,7 @@ class BlendLevelSlider extends ConsumerWidget { Slider( min: 0.0, max: 40.0, - divisions: max(40 - 1, 1), + divisions: max(39, 1), value: blendLevel, onChanged: (value) { ref.read(blendLevelStateProvider.notifier).setBlendLevel(value); diff --git a/pubspec.lock b/pubspec.lock index a6823095..b1de2b0b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -387,10 +387,10 @@ packages: dependency: "direct main" description: name: flutter_riverpod - sha256: b3c3a8a9714b7f88dd2a41e1efbc47f76d620b06ab427c62ae7bc82298cd7dbb + sha256: "9692634c2c00d2a1a5e96bbde0b79a7c6f0f266aa266d76cd52841f791949a89" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.3.5" flutter_test: dependency: "direct dev" description: flutter @@ -837,10 +837,10 @@ packages: dependency: transitive description: name: riverpod - sha256: b0fbf7927333c5c318f7e2c22c8b4fd2542ba294de0373e80ecdb34e0dcd8dc4 + sha256: ec5641067d111681ef825754d1327565c987985c7cb52e09bc867b78248854b2 url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.3.5" riverpod_analyzer_utils: dependency: transitive description: @@ -1042,10 +1042,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: dd729390aa936bf1bdf5cd1bc7468ff340263f80a2c4f569416507667de8e3c8 + sha256: a52628068d282d01a07cd86e6ba99e497aa45ce8c91159015b2416907d78e411 url: "https://pub.dev" source: hosted - version: "6.0.26" + version: "6.0.27" url_launcher_ios: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 61dd38f7..2b9528fd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.0.11+3 +version: 0.0.15+4 environment: sdk: '>=2.19.5 <3.0.0'