Unify cache size

This commit is contained in:
Ming Ming 2021-09-16 18:25:08 +08:00
parent c16c97ec9f
commit d8177edd28
11 changed files with 30 additions and 15 deletions

View file

@ -16,3 +16,17 @@ const animationDurationNormal = Duration(milliseconds: 250);
/// Duration for long animation
const animationDurationLong = Duration(milliseconds: 500);
/// Size of the photo/video thumbnails
///
/// It's advisable to use a single size to minimize cache size
const photoThumbSize = 256;
/// Size of the face thumbnails
const faceThumbSize = 192;
/// Size of the opened photos
const photoLargeSize = 1080;
/// Size of the cover photos
const coverSize = 512;

View file

@ -530,8 +530,8 @@ class _AlbumBrowserState extends State<AlbumBrowser>
final previewUrl = api_util.getFilePreviewUrl(
widget.account,
item.file,
width: thumbSize,
height: thumbSize,
width: k.photoThumbSize,
height: k.photoThumbSize,
);
if (file_util.isSupportedImageFormat(item.file)) {
yield _ImageListItem(

View file

@ -38,7 +38,7 @@ mixin AlbumBrowserMixin<T extends StatefulWidget>
try {
final coverFile = album.coverProvider.getCover(album);
_coverPreviewUrl = api_util.getFilePreviewUrl(account, coverFile!,
width: 1024, height: 600);
width: k.coverSize, height: k.coverSize);
} catch (_) {}
}

View file

@ -268,7 +268,7 @@ class _ArchiveBrowserState extends State<ArchiveBrowser>
final f = _backingFiles[i];
final previewUrl = api_util.getFilePreviewUrl(widget.account, f,
width: _thumbSize, height: _thumbSize);
width: k.photoThumbSize, height: k.photoThumbSize);
if (file_util.isSupportedImageFormat(f)) {
yield _ImageListItem(
file: f,

View file

@ -8,6 +8,7 @@ import 'package:nc_photos/app_localizations.dart';
import 'package:nc_photos/cache_manager_util.dart';
import 'package:nc_photos/entity/album.dart';
import 'package:nc_photos/entity/album/provider.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/theme.dart';
import 'package:nc_photos/widget/album_grid_item.dart';
@ -49,7 +50,7 @@ class AlbumGridItemBuilder {
try {
final coverFile = album.coverProvider.getCover(album);
final previewUrl = api_util.getFilePreviewUrl(account, coverFile!,
width: 512, height: 512);
width: k.coverSize, height: k.coverSize);
cover = FittedBox(
clipBehavior: Clip.hardEdge,
fit: BoxFit.cover,

View file

@ -542,8 +542,8 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
final previewUrl = api_util.getFilePreviewUrl(
widget.account,
item.file,
width: thumbSize,
height: thumbSize,
width: k.photoThumbSize,
height: k.photoThumbSize,
);
if (file_util.isSupportedImageFormat(item.file)) {
yield _ImageListItem(

View file

@ -545,7 +545,7 @@ class _HomePhotosState extends State<HomePhotos>
}
final previewUrl = api_util.getFilePreviewUrl(widget.account, f,
width: _thumbSize, height: _thumbSize);
width: k.photoThumbSize, height: k.photoThumbSize);
if (file_util.isSupportedImageFormat(f)) {
yield _ImageListItem(
file: f,

View file

@ -219,8 +219,8 @@ String _getImageUrl(Account account, File file) {
return api_util.getFilePreviewUrl(
account,
file,
width: 1080,
height: 1080,
width: k.photoLargeSize,
height: k.photoLargeSize,
a: true,
);
}

View file

@ -199,7 +199,7 @@ class _PeopleBrowserState extends State<PeopleBrowser> {
account: widget.account,
name: e.name,
faceUrl: api_util.getFacePreviewUrl(widget.account, e.thumbFaceId,
size: 256),
size: k.faceThumbSize),
onTap: () => _onItemTap(e),
))
.toList();

View file

@ -221,7 +221,7 @@ class _PersonBrowserState extends State<PersonBrowser>
cacheManager: ThumbnailCacheManager.inst,
imageUrl: api_util.getFacePreviewUrl(
widget.account, widget.person.thumbFaceId,
size: 64),
size: k.faceThumbSize),
httpHeaders: {
"Authorization": Api.getAuthorizationHeaderValue(widget.account),
},
@ -462,8 +462,8 @@ class _PersonBrowserState extends State<PersonBrowser>
previewUrl: api_util.getFilePreviewUrl(
widget.account,
f,
width: _thumbSize,
height: _thumbSize,
width: k.photoThumbSize,
height: k.photoThumbSize,
),
onTap: () => _onItemTap(i),
))

View file

@ -359,7 +359,7 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
final f = _backingFiles[i];
final previewUrl = api_util.getFilePreviewUrl(widget.account, f,
width: _thumbSize, height: _thumbSize);
width: k.photoThumbSize, height: k.photoThumbSize);
if (file_util.isSupportedImageFormat(f)) {
yield _ImageListItem(
file: f,