mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Add an option to display single image on the first reader page. Close #244
This commit is contained in:
@@ -387,7 +387,8 @@
|
|||||||
"Screen center": "屏幕中心",
|
"Screen center": "屏幕中心",
|
||||||
"Suggestions": "建议",
|
"Suggestions": "建议",
|
||||||
"Do not report any issues related to sources to App repo.": "请不要向App仓库报告任何与源相关的问题",
|
"Do not report any issues related to sources to App repo.": "请不要向App仓库报告任何与源相关的问题",
|
||||||
"Click the setting icon to change the source list url.": "点击设置图标更改源列表URL"
|
"Click the setting icon to change the source list url.": "点击设置图标更改源列表URL",
|
||||||
|
"Show single image on first page": "在首页显示单张图片"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Home": "首頁",
|
"Home": "首頁",
|
||||||
@@ -777,6 +778,7 @@
|
|||||||
"Screen center": "螢幕中心",
|
"Screen center": "螢幕中心",
|
||||||
"Suggestions": "建議",
|
"Suggestions": "建議",
|
||||||
"Do not report any issues related to sources to App repo.": "請不要向App倉庫報告任何與源相關的問題",
|
"Do not report any issues related to sources to App repo.": "請不要向App倉庫報告任何與源相關的問題",
|
||||||
"Click the setting icon to change the source list url.": "點擊設定圖示更改源列表URL"
|
"Click the setting icon to change the source list url.": "點擊設定圖示更改源列表URL",
|
||||||
|
"Show single image on first page": "在首頁顯示單張圖片"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -185,6 +185,7 @@ class Settings with ChangeNotifier {
|
|||||||
'initialPage': '0',
|
'initialPage': '0',
|
||||||
'comicListDisplayMode': 'paging', // paging, continuous
|
'comicListDisplayMode': 'paging', // paging, continuous
|
||||||
'showPageNumberInReader': true,
|
'showPageNumberInReader': true,
|
||||||
|
'showSingleImageOnFirstPage': false,
|
||||||
};
|
};
|
||||||
|
|
||||||
operator [](String key) {
|
operator [](String key) {
|
||||||
|
@@ -118,7 +118,14 @@ class _GalleryModeState extends State<_GalleryMode>
|
|||||||
|
|
||||||
/// [totalPages] is the total number of pages in the current chapter.
|
/// [totalPages] is the total number of pages in the current chapter.
|
||||||
/// More than one images can be displayed on one page.
|
/// More than one images can be displayed on one page.
|
||||||
int get totalPages => (reader.images!.length / reader.imagesPerPage).ceil();
|
int get totalPages {
|
||||||
|
if (!showSingleImageOnFirstPage) {
|
||||||
|
return (reader.images!.length / reader.imagesPerPage).ceil();
|
||||||
|
} else {
|
||||||
|
return 1 +
|
||||||
|
((reader.images!.length - 1) / reader.imagesPerPage).ceil();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var imageStates = <State<ComicImage>>{};
|
var imageStates = <State<ComicImage>>{};
|
||||||
|
|
||||||
@@ -137,6 +144,27 @@ class _GalleryModeState extends State<_GalleryMode>
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get showSingleImageOnFirstPage => appdata.settings["showSingleImageOnFirstPage"];
|
||||||
|
|
||||||
|
/// Get the range of images for the given page. [page] is 1-based.
|
||||||
|
(int start, int end) getPageImagesRange(int page) {
|
||||||
|
if (showSingleImageOnFirstPage) {
|
||||||
|
if (page == 1) {
|
||||||
|
return (0, 1);
|
||||||
|
} else {
|
||||||
|
int startIndex = (page - 2) * reader.imagesPerPage + 1;
|
||||||
|
int endIndex = math.min(
|
||||||
|
startIndex + reader.imagesPerPage, reader.images!.length);
|
||||||
|
return (startIndex, endIndex);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int startIndex = (page - 1) * reader.imagesPerPage;
|
||||||
|
int endIndex = math.min(
|
||||||
|
startIndex + reader.imagesPerPage, reader.images!.length);
|
||||||
|
return (startIndex, endIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// [cache] is used to cache the images.
|
/// [cache] is used to cache the images.
|
||||||
/// The count of images to cache is determined by the [preCacheCount] setting.
|
/// The count of images to cache is determined by the [preCacheCount] setting.
|
||||||
/// For previous page and next page, it will do a memory cache.
|
/// For previous page and next page, it will do a memory cache.
|
||||||
@@ -151,9 +179,7 @@ class _GalleryModeState extends State<_GalleryMode>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _cachePage(int page, bool shouldPreCache) {
|
void _cachePage(int page, bool shouldPreCache) {
|
||||||
int startIndex = (page - 1) * reader.imagesPerPage;
|
var (startIndex, endIndex) = getPageImagesRange(page);
|
||||||
int endIndex =
|
|
||||||
math.min(startIndex + reader.imagesPerPage, reader.images!.length);
|
|
||||||
for (int i = startIndex; i < endIndex; i++) {
|
for (int i = startIndex; i < endIndex; i++) {
|
||||||
if (shouldPreCache) {
|
if (shouldPreCache) {
|
||||||
_precacheImage(i+1, context);
|
_precacheImage(i+1, context);
|
||||||
@@ -201,10 +227,7 @@ class _GalleryModeState extends State<_GalleryMode>
|
|||||||
child: const SizedBox(),
|
child: const SizedBox(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
int pageIndex = index - 1;
|
var (startIndex, endIndex) = getPageImagesRange(index);
|
||||||
int startIndex = pageIndex * reader.imagesPerPage;
|
|
||||||
int endIndex = math.min(
|
|
||||||
startIndex + reader.imagesPerPage, reader.images!.length);
|
|
||||||
List<String> pageImages =
|
List<String> pageImages =
|
||||||
reader.images!.sublist(startIndex, endIndex);
|
reader.images!.sublist(startIndex, endIndex);
|
||||||
|
|
||||||
@@ -1081,6 +1104,9 @@ void _preDownloadImage(int page, BuildContext context) {
|
|||||||
}
|
}
|
||||||
var reader = context.reader;
|
var reader = context.reader;
|
||||||
var imageKey = reader.images![page - 1];
|
var imageKey = reader.images![page - 1];
|
||||||
|
if (imageKey.startsWith("file://")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var cid = reader.cid;
|
var cid = reader.cid;
|
||||||
var eid = reader.eid;
|
var eid = reader.eid;
|
||||||
var sourceKey = reader.type.comicSource?.key;
|
var sourceKey = reader.type.comicSource?.key;
|
||||||
|
@@ -66,6 +66,7 @@ class _ReaderSettingsState extends State<ReaderSettings> {
|
|||||||
min: 1,
|
min: 1,
|
||||||
max: 20,
|
max: 20,
|
||||||
onChanged: () {
|
onChanged: () {
|
||||||
|
setState(() {});
|
||||||
widget.onChanged?.call("autoPageTurningInterval");
|
widget.onChanged?.call("autoPageTurningInterval");
|
||||||
},
|
},
|
||||||
).toSliver(),
|
).toSliver(),
|
||||||
@@ -80,6 +81,7 @@ class _ReaderSettingsState extends State<ReaderSettings> {
|
|||||||
min: 1,
|
min: 1,
|
||||||
max: 5,
|
max: 5,
|
||||||
onChanged: () {
|
onChanged: () {
|
||||||
|
setState(() {});
|
||||||
widget.onChanged?.call("readerScreenPicNumberForLandscape");
|
widget.onChanged?.call("readerScreenPicNumberForLandscape");
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -99,6 +101,18 @@ class _ReaderSettingsState extends State<ReaderSettings> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SliverAnimatedVisibility(
|
||||||
|
visible: appdata.settings['readerMode']!.startsWith('gallery') &&
|
||||||
|
(appdata.settings['readerScreenPicNumberForLandscape'] > 1 ||
|
||||||
|
appdata.settings['readerScreenPicNumberForPortrait'] > 1),
|
||||||
|
child: _SwitchSetting(
|
||||||
|
title: "Show single image on first page".tl,
|
||||||
|
settingKey: "showSingleImageOnFirstPage",
|
||||||
|
onChanged: () {
|
||||||
|
widget.onChanged?.call("showSingleImageOnFirstPage");
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
_SwitchSetting(
|
_SwitchSetting(
|
||||||
title: 'Long press to zoom'.tl,
|
title: 'Long press to zoom'.tl,
|
||||||
settingKey: 'enableLongPressToZoom',
|
settingKey: 'enableLongPressToZoom',
|
||||||
|
Reference in New Issue
Block a user