improve downloaded page

This commit is contained in:
wgh19
2024-05-15 13:00:29 +08:00
parent 4673709dcb
commit b2f1d1ad93

View File

@@ -5,6 +5,7 @@ import 'package:flutter/gestures.dart';
import 'package:photo_view/photo_view_gallery.dart'; import 'package:photo_view/photo_view_gallery.dart';
import 'package:pixes/components/grid.dart'; import 'package:pixes/components/grid.dart';
import 'package:pixes/components/md.dart'; import 'package:pixes/components/md.dart';
import 'package:pixes/components/message.dart';
import 'package:pixes/components/page_route.dart'; import 'package:pixes/components/page_route.dart';
import 'package:pixes/components/title_bar.dart'; import 'package:pixes/components/title_bar.dart';
import 'package:pixes/foundation/app.dart'; import 'package:pixes/foundation/app.dart';
@@ -57,6 +58,7 @@ class _DownloadedPageState extends State<DownloadedPage> {
itemHeight: 152, itemHeight: 152,
maxCrossAxisExtent: 742, maxCrossAxisExtent: 742,
builder: (context, index) { builder: (context, index) {
var image = DownloadManager().getImage(illusts[index].illustId, 0);
return Card( return Card(
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
@@ -70,9 +72,8 @@ class _DownloadedPageState extends State<DownloadedPage> {
color: ColorScheme.of(context).secondaryContainer color: ColorScheme.of(context).secondaryContainer
), ),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: Image( child: image == null ? null : Image(
image: FileImage(DownloadManager().getImage( image: FileImage(image),
illusts[index].illustId, 0)!),
fit: BoxFit.cover, fit: BoxFit.cover,
filterQuality: FilterQuality.medium, filterQuality: FilterQuality.medium,
), ),
@@ -113,11 +114,15 @@ class _DownloadedPageState extends State<DownloadedPage> {
Button( Button(
child: Text("View".tl).fixWidth(42), child: Text("View".tl).fixWidth(42),
onPressed: () { onPressed: () {
var images = DownloadManager().getImagePaths(
illusts[index].illustId);
if(images.isEmpty) {
showToast(context, message: "No images found".tl);
return;
}
App.rootNavigatorKey.currentState?.push( App.rootNavigatorKey.currentState?.push(
AppPageRoute(builder: (context) { AppPageRoute(builder: (context) {
return _DownloadedIllustViewPage( return _DownloadedIllustViewPage(images);
DownloadManager().getImagePaths(
illusts[index].illustId));
})); }));
}, },
), ),