mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Add settings to adjust thumbnail display
This commit is contained in:
@@ -30,9 +30,11 @@ class Thumbnail extends StatefulWidget {
|
||||
this.gdata,
|
||||
this.isSelectMode = false,
|
||||
this.isSelected = false,
|
||||
this.onSelectedChange})
|
||||
this.onSelectedChange,
|
||||
this.align,
|
||||
this.method})
|
||||
: _pMeta = pMeta,
|
||||
_max = max ?? 1200,
|
||||
_max = max ?? 400,
|
||||
_width = width,
|
||||
_height = height,
|
||||
_fileId = fileId;
|
||||
@@ -48,6 +50,8 @@ class Thumbnail extends StatefulWidget {
|
||||
final bool isSelectMode;
|
||||
final bool isSelected;
|
||||
final ValueChanged<bool>? onSelectedChange;
|
||||
final ThumbnailGenMethod? method;
|
||||
final ThumbnailAlign? align;
|
||||
|
||||
int get height => _height != null
|
||||
? _height!
|
||||
@@ -134,8 +138,8 @@ class _Thumbnail extends State<Thumbnail> {
|
||||
max: widget._max,
|
||||
width: widget._width,
|
||||
height: widget._height,
|
||||
method: ThumbnailMethod.contain,
|
||||
align: ThumbnailAlign.center);
|
||||
method: widget.method,
|
||||
align: widget.align);
|
||||
if (isImageCacheEnabled) {
|
||||
try {
|
||||
final cache = await imageCaches.getCache(_originalUrl!);
|
||||
@@ -156,8 +160,8 @@ class _Thumbnail extends State<Thumbnail> {
|
||||
max: widget._max,
|
||||
width: widget._width,
|
||||
height: widget._height,
|
||||
method: ThumbnailMethod.contain,
|
||||
align: ThumbnailAlign.center,
|
||||
method: widget.method,
|
||||
align: widget.align,
|
||||
cancel: _cancel);
|
||||
if (re.response.statusCode != 200) {
|
||||
throw Exception(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../api/client.dart';
|
||||
import '../api/file.dart';
|
||||
import '../api/gallery.dart';
|
||||
import '../globals.dart';
|
||||
@@ -27,6 +28,18 @@ class ThumbnailGridView extends StatelessWidget {
|
||||
displayAd ? gdata.pages : gdata.pages.where((e) => !e.isAd).toList();
|
||||
final baseSize = gridDelegate.maxCrossAxisExtent.toInt();
|
||||
final max = (baseSize * MediaQuery.of(context).devicePixelRatio).toInt();
|
||||
final tgen = prefs.getInt("thumbnailMethod") ?? 0;
|
||||
final gen = tgen >= 0 && tgen < ThumbnailGenMethod.values.length
|
||||
? ThumbnailGenMethod.values[tgen]
|
||||
: ThumbnailGenMethod.unknown;
|
||||
final talign = prefs.getInt("thumbnailAlign") ?? 1;
|
||||
final align = talign >= 0 && talign < ThumbnailAlign.values.length
|
||||
? ThumbnailAlign.values[talign]
|
||||
: ThumbnailAlign.center;
|
||||
final isDefault = gen == ThumbnailGenMethod.unknown;
|
||||
final alignUseless = isDefault || gen == ThumbnailGenMethod.fill;
|
||||
final methodKey =
|
||||
alignUseless ? "${align.index}" : "${align.index}-${align.index}";
|
||||
return SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemCount: npages.length,
|
||||
@@ -34,7 +47,8 @@ class ThumbnailGridView extends StatelessWidget {
|
||||
final page = npages[index]!;
|
||||
final fileId =
|
||||
files != null ? files!.files[page.token]!.firstOrNull?.id : null;
|
||||
final key = Key("thumbnail$gid-${page.index}-$fileId-$max");
|
||||
final key =
|
||||
Key("thumbnail$gid-${page.index}-$fileId-$max-$methodKey");
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Thumbnail(
|
||||
@@ -58,6 +72,10 @@ class ThumbnailGridView extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
max: max,
|
||||
width: isDefault ? null : max,
|
||||
height: isDefault ? null : max,
|
||||
method: isDefault ? null : gen,
|
||||
align: alignUseless ? null : align,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user