mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
download comics in local favorites page
This commit is contained in:
@@ -249,7 +249,9 @@
|
|||||||
"Export as pdf": "导出为pdf",
|
"Export as pdf": "导出为pdf",
|
||||||
"Export as epub": "导出为epub",
|
"Export as epub": "导出为epub",
|
||||||
"Aggregated Search": "聚合搜索",
|
"Aggregated Search": "聚合搜索",
|
||||||
"No search results found": "未找到搜索结果"
|
"No search results found": "未找到搜索结果",
|
||||||
|
"Added @c comics to download queue." : "已添加 @c 本漫画到下载队列",
|
||||||
|
"Download started": "下载已开始"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Home": "首頁",
|
"Home": "首頁",
|
||||||
@@ -501,6 +503,8 @@
|
|||||||
"Export as pdf": "匯出為pdf",
|
"Export as pdf": "匯出為pdf",
|
||||||
"Export as epub": "匯出為epub",
|
"Export as epub": "匯出為epub",
|
||||||
"Aggregated Search": "聚合搜索",
|
"Aggregated Search": "聚合搜索",
|
||||||
"No search results found": "未找到搜索結果"
|
"No search results found": "未找到搜索結果",
|
||||||
|
"Added @c comics to download queue." : "已添加 @c 本漫畫到下載隊列",
|
||||||
|
"Download started": "下載已開始"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -389,7 +389,7 @@ class LocalManager with ChangeNotifier {
|
|||||||
return files.map((e) => "file://${e.path}").toList();
|
return files.map((e) => "file://${e.path}").toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> isDownloaded(String id, ComicType type, [int? ep]) async {
|
bool isDownloaded(String id, ComicType type, [int? ep]) {
|
||||||
var comic = find(id, type);
|
var comic = find(id, type);
|
||||||
if (comic == null) return false;
|
if (comic == null) return false;
|
||||||
if (comic.chapters == null || ep == null) return true;
|
if (comic.chapters == null || ep == null) return true;
|
||||||
|
@@ -10,7 +10,9 @@ 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/consts.dart';
|
import 'package:venera/foundation/consts.dart';
|
||||||
import 'package:venera/foundation/favorites.dart';
|
import 'package:venera/foundation/favorites.dart';
|
||||||
|
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/pages/comic_page.dart';
|
import 'package:venera/pages/comic_page.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';
|
||||||
|
@@ -53,8 +53,6 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
void selectAll() {
|
void selectAll() {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedComics = comics.asMap().map((k, v) => MapEntry(v, true));
|
selectedComics = comics.asMap().map((k, v) => MapEntry(v, true));
|
||||||
@@ -70,6 +68,42 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool downloadComic(FavoriteItem c) {
|
||||||
|
var source = c.type.comicSource;
|
||||||
|
if (source != null) {
|
||||||
|
bool isDownloaded = LocalManager().isDownloaded(
|
||||||
|
c.id,
|
||||||
|
(c).type,
|
||||||
|
);
|
||||||
|
if (isDownloaded) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LocalManager().addTask(ImagesDownloadTask(
|
||||||
|
source: source,
|
||||||
|
comicId: c.id,
|
||||||
|
comicTitle: c.title,
|
||||||
|
));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void downloadSelected() {
|
||||||
|
int count = 0;
|
||||||
|
for (var c in selectedComics.keys) {
|
||||||
|
if (downloadComic(c as FavoriteItem)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count > 0) {
|
||||||
|
context.showMessage(
|
||||||
|
message: "Added @c comics to download queue.".tlParams({"c": count}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
var body = Scaffold(
|
var body = Scaffold(
|
||||||
body: SmoothCustomScrollView(slivers: [
|
body: SmoothCustomScrollView(slivers: [
|
||||||
if (!searchMode && !multiSelectMode)
|
if (!searchMode && !multiSelectMode)
|
||||||
@@ -300,6 +334,11 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
MenuEntry(
|
||||||
|
icon: Icons.download,
|
||||||
|
text: "Download".tl,
|
||||||
|
onClick: downloadSelected,
|
||||||
|
),
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@@ -336,6 +375,20 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
|||||||
SliverGridComics(
|
SliverGridComics(
|
||||||
comics: comics,
|
comics: comics,
|
||||||
selections: selectedComics,
|
selections: selectedComics,
|
||||||
|
menuBuilder: (c) {
|
||||||
|
return [
|
||||||
|
MenuEntry(
|
||||||
|
icon: Icons.download,
|
||||||
|
text: "Download".tl,
|
||||||
|
onClick: () {
|
||||||
|
downloadComic(c as FavoriteItem);
|
||||||
|
context.showMessage(
|
||||||
|
message: "Download started".tl,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
];
|
||||||
|
},
|
||||||
onTap: multiSelectMode
|
onTap: multiSelectMode
|
||||||
? (c) {
|
? (c) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -597,9 +650,12 @@ class _ReorderComicsPageState extends State<_ReorderComicsPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color lightenColor(Color color, double lightenValue) {
|
Color lightenColor(Color color, double lightenValue) {
|
||||||
int red = (_floatToInt8(color.r) + ((255 - color.r) * lightenValue)).round();
|
int red =
|
||||||
int green = (_floatToInt8(color.g) * 255 + ((255 - color.g) * lightenValue)).round();
|
(_floatToInt8(color.r) + ((255 - color.r) * lightenValue)).round();
|
||||||
int blue = (_floatToInt8(color.b) * 255 + ((255 - color.b) * lightenValue)).round();
|
int green = (_floatToInt8(color.g) * 255 + ((255 - color.g) * lightenValue))
|
||||||
|
.round();
|
||||||
|
int blue = (_floatToInt8(color.b) * 255 + ((255 - color.b) * lightenValue))
|
||||||
|
.round();
|
||||||
|
|
||||||
return Color.fromARGB(_floatToInt8(color.a), red, green, blue);
|
return Color.fromARGB(_floatToInt8(color.a), red, green, blue);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user