This commit is contained in:
2024-12-18 16:51:57 +08:00
parent 06a6e5156a
commit f9c42aef4b
10 changed files with 172 additions and 41 deletions

View File

@@ -251,7 +251,11 @@
"Aggregated Search": "聚合搜索", "Aggregated Search": "聚合搜索",
"No search results found": "未找到搜索结果", "No search results found": "未找到搜索结果",
"Added @c comics to download queue." : "已添加 @c 本漫画到下载队列", "Added @c comics to download queue." : "已添加 @c 本漫画到下载队列",
"Download started": "下载已开始" "Download started": "下载已开始",
"Click favorite": "点击收藏",
"End": "末尾",
"None": "无",
"View Detail": "查看详情"
}, },
"zh_TW": { "zh_TW": {
"Home": "首頁", "Home": "首頁",
@@ -505,6 +509,10 @@
"Aggregated Search": "聚合搜索", "Aggregated Search": "聚合搜索",
"No search results found": "未找到搜索結果", "No search results found": "未找到搜索結果",
"Added @c comics to download queue." : "已添加 @c 本漫畫到下載隊列", "Added @c comics to download queue." : "已添加 @c 本漫畫到下載隊列",
"Download started": "下載已開始" "Download started": "下載已開始",
"Click favorite": "點擊收藏",
"End": "末尾",
"None": "無",
"View Detail": "查看詳情"
} }
} }

View File

@@ -122,6 +122,7 @@ class _Settings with ChangeNotifier {
'enableClockAndBatteryInfoInReader': true, 'enableClockAndBatteryInfoInReader': true,
'ignoreCertificateErrors': false, 'ignoreCertificateErrors': false,
'authorizationRequired': false, 'authorizationRequired': false,
'onClickFavorite': 'viewDetail', // viewDetail, read
}; };
operator [](String key) { operator [](String key) {

View File

@@ -28,4 +28,12 @@ class ComicType {
} }
static const local = ComicType(0); static const local = ComicType(0);
factory ComicType.fromKey(String key) {
if(key == "local") {
return local;
} else {
return ComicType(key.hashCode);
}
}
} }

View File

@@ -14,6 +14,7 @@ import 'package:venera/foundation/local.dart';
import 'package:venera/foundation/res.dart'; import 'package:venera/foundation/res.dart';
import 'package:venera/network/download.dart'; import 'package:venera/network/download.dart';
import 'package:venera/pages/comic_page.dart'; import 'package:venera/pages/comic_page.dart';
import 'package:venera/pages/reader/reader.dart';
import 'package:venera/utils/io.dart'; import 'package:venera/utils/io.dart';
import 'package:venera/utils/translations.dart'; import 'package:venera/utils/translations.dart';

View File

@@ -389,8 +389,8 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
), ),
]; ];
}, },
onTap: multiSelectMode onTap: (c) {
? (c) { if (multiSelectMode) {
setState(() { setState(() {
if (selectedComics.containsKey(c as FavoriteItem)) { if (selectedComics.containsKey(c as FavoriteItem)) {
selectedComics.remove(c); selectedComics.remove(c);
@@ -400,10 +400,17 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
} }
lastSelectedIndex = comics.indexOf(c); lastSelectedIndex = comics.indexOf(c);
}); });
} } else if (appdata.settings["onClickFavorite"] == "viewDetail") {
: (c) {
App.mainNavigatorKey?.currentContext App.mainNavigatorKey?.currentContext
?.to(() => ComicPage(id: c.id, sourceKey: c.sourceKey)); ?.to(() => ComicPage(id: c.id, sourceKey: c.sourceKey));
} else {
App.mainNavigatorKey?.currentContext?.to(
() => ReaderWithLoading(
id: c.id,
sourceKey: c.sourceKey,
),
);
}
}, },
onLongPressed: (c) { onLongPressed: (c) {
setState(() { setState(() {

View File

@@ -0,0 +1,101 @@
part of 'reader.dart';
class ReaderWithLoading extends StatefulWidget {
const ReaderWithLoading({
super.key,
required this.id,
required this.sourceKey,
});
final String id;
final String sourceKey;
@override
State<ReaderWithLoading> createState() => _ReaderWithLoadingState();
}
class _ReaderWithLoadingState
extends LoadingState<ReaderWithLoading, ReaderProps> {
@override
Widget buildContent(BuildContext context, ReaderProps data) {
return Reader(
type: data.type,
cid: data.cid,
name: data.name,
chapters: data.chapters,
history: data.history,
);
}
@override
Future<Res<ReaderProps>> loadData() async {
var comicSource = ComicSource.find(widget.sourceKey);
var history = HistoryManager().findSync(
widget.id,
ComicType.fromKey(widget.sourceKey),
);
if (comicSource == null) {
var localComic = LocalManager().find(
widget.id,
ComicType.fromKey(widget.sourceKey),
);
if (localComic == null) {
return Res.error("comic not found");
}
return Res(
ReaderProps(
type: ComicType.fromKey(widget.sourceKey),
cid: widget.id,
name: localComic.title,
chapters: localComic.chapters,
history: history ??
History.fromModel(
model: localComic,
ep: 0,
page: 0,
),
),
);
} else {
var comic = await comicSource.loadComicInfo!(widget.id);
if (comic.error) {
return Res.fromErrorRes(comic);
}
return Res(
ReaderProps(
type: ComicType.fromKey(widget.sourceKey),
cid: widget.id,
name: comic.data.title,
chapters: comic.data.chapters,
history: history ??
History.fromModel(
model: comic.data,
ep: 0,
page: 0,
),
),
);
}
}
}
class ReaderProps {
final ComicType type;
final String cid;
final String name;
final Map<String, String>? chapters;
final History history;
const ReaderProps({
required this.type,
required this.cid,
required this.name,
required this.chapters,
required this.history,
});
}

View File

@@ -18,11 +18,13 @@ import 'package:venera/components/custom_slider.dart';
import 'package:venera/foundation/app.dart'; import 'package:venera/foundation/app.dart';
import 'package:venera/foundation/appdata.dart'; import 'package:venera/foundation/appdata.dart';
import 'package:venera/foundation/cache_manager.dart'; import 'package:venera/foundation/cache_manager.dart';
import 'package:venera/foundation/comic_source/comic_source.dart';
import 'package:venera/foundation/comic_type.dart'; import 'package:venera/foundation/comic_type.dart';
import 'package:venera/foundation/history.dart'; import 'package:venera/foundation/history.dart';
import 'package:venera/foundation/image_provider/reader_image.dart'; import 'package:venera/foundation/image_provider/reader_image.dart';
import 'package:venera/foundation/local.dart'; import 'package:venera/foundation/local.dart';
import 'package:venera/foundation/log.dart'; import 'package:venera/foundation/log.dart';
import 'package:venera/foundation/res.dart';
import 'package:venera/pages/settings/settings_page.dart'; import 'package:venera/pages/settings/settings_page.dart';
import 'package:venera/utils/data_sync.dart'; import 'package:venera/utils/data_sync.dart';
import 'package:venera/utils/file_type.dart'; import 'package:venera/utils/file_type.dart';
@@ -36,6 +38,7 @@ part 'scaffold.dart';
part 'images.dart'; part 'images.dart';
part 'gesture.dart'; part 'gesture.dart';
part 'comic_image.dart'; part 'comic_image.dart';
part 'loading.dart';
extension _ReaderContext on BuildContext { extension _ReaderContext on BuildContext {
_ReaderState get reader => findAncestorStateOfType<_ReaderState>()!; _ReaderState get reader => findAncestorStateOfType<_ReaderState>()!;

View File

@@ -16,18 +16,18 @@ class _LocalFavoritesSettingsState extends State<LocalFavoritesSettings> {
SelectSetting( SelectSetting(
title: "Add new favorite to".tl, title: "Add new favorite to".tl,
settingKey: "newFavoriteAddTo", settingKey: "newFavoriteAddTo",
optionTranslation: const { optionTranslation: {
"start": "Start", "start": "Start".tl,
"end": "End", "end": "End".tl,
}, },
).toSliver(), ).toSliver(),
SelectSetting( SelectSetting(
title: "Move favorite after reading".tl, title: "Move favorite after reading".tl,
settingKey: "moveFavoriteAfterRead", settingKey: "moveFavoriteAfterRead",
optionTranslation: const { optionTranslation: {
"none": "None", "none": "None".tl,
"end": "End", "end": "End".tl,
"start": "Start", "start": "Start".tl,
}, },
).toSliver(), ).toSliver(),
SelectSetting( SelectSetting(
@@ -48,6 +48,14 @@ class _LocalFavoritesSettingsState extends State<LocalFavoritesSettings> {
}, },
actionTitle: 'Delete'.tl, actionTitle: 'Delete'.tl,
).toSliver(), ).toSliver(),
SelectSetting(
title: "Click favorite".tl,
settingKey: "onClickFavorite",
optionTranslation: {
"viewDetail": "View Detail".tl,
"read": "Read".tl,
},
).toSliver(),
], ],
); );
} }

View File

@@ -446,11 +446,10 @@ packages:
flutter_to_arch: flutter_to_arch:
dependency: "direct dev" dependency: "direct dev"
description: description:
path: "." name: flutter_to_arch
ref: HEAD sha256: "656cffc182b05af38aa96a1115931620b8865c4b0cfe00813b26fcff0875f2ab"
resolved-ref: "15bfead0380fda79b0256b37c73b886b0882f1bf" url: "https://pub.dev"
url: "https://github.com/wgh136/flutter_to_arch" source: hosted
source: git
version: "1.0.0" version: "1.0.0"
flutter_to_debian: flutter_to_debian:
dependency: "direct dev" dependency: "direct dev"
@@ -1125,12 +1124,11 @@ packages:
zip_flutter: zip_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." name: zip_flutter
ref: "51007a0" sha256: "78c9b6053117828581346d24b07943ba6d3032a13f68d15c133bc21df2cf178a"
resolved-ref: "51007a0c1f34ee7865ef3bdededf40e5f5df85bd" url: "https://pub.dev"
url: "https://github.com/wgh136/zip_flutter" source: hosted
source: git version: "0.0.4"
version: "0.0.3"
sdks: sdks:
dart: ">=3.6.0 <4.0.0" dart: ">=3.6.0 <4.0.0"
flutter: ">=3.27.1" flutter: ">=3.27.1"

View File

@@ -51,10 +51,7 @@ dependencies:
sliver_tools: ^0.2.12 sliver_tools: ^0.2.12
flutter_file_dialog: ^3.0.2 flutter_file_dialog: ^3.0.2
file_selector: ^1.0.3 file_selector: ^1.0.3
zip_flutter: zip_flutter: ^0.0.4
git:
url: https://github.com/wgh136/zip_flutter
ref: 51007a0
lodepng_flutter: lodepng_flutter:
git: git:
url: https://github.com/venera-app/lodepng_flutter url: https://github.com/venera-app/lodepng_flutter
@@ -79,8 +76,7 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^5.0.0 flutter_lints: ^5.0.0
flutter_to_arch: flutter_to_arch: ^1.0.0
git: https://github.com/wgh136/flutter_to_arch
flutter_to_debian: flutter_to_debian:
flutter: flutter: