mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-24 16:04:43 +01:00
Always use preview when showing image
This commit is contained in:
parent
5143f86751
commit
f47fbb11ef
4 changed files with 56 additions and 29 deletions
|
@ -113,6 +113,12 @@ class AppTheme extends StatelessWidget {
|
||||||
return Colors.white.withOpacity(.5);
|
return Colors.white.withOpacity(.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Color getListItemBackgroundColor(BuildContext context) {
|
||||||
|
return Theme.of(context).brightness == Brightness.light
|
||||||
|
? Colors.black26
|
||||||
|
: Colors.white12;
|
||||||
|
}
|
||||||
|
|
||||||
static const primarySwatchLight = Colors.blue;
|
static const primarySwatchLight = Colors.blue;
|
||||||
static const primarySwatchDark = Colors.cyan;
|
static const primarySwatchDark = Colors.cyan;
|
||||||
|
|
||||||
|
|
|
@ -77,13 +77,10 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
|
|
||||||
void _initCover() {
|
void _initCover() {
|
||||||
try {
|
try {
|
||||||
final coverFile = _backingFiles.first;
|
final coverFile =
|
||||||
if (coverFile.hasPreview) {
|
_backingFiles.firstWhere((element) => element.hasPreview);
|
||||||
_coverPreviewUrl = api_util.getFilePreviewUrl(widget.account, coverFile,
|
_coverPreviewUrl = api_util.getFilePreviewUrl(widget.account, coverFile,
|
||||||
width: 1024, height: 600);
|
width: 1024, height: 600);
|
||||||
} else {
|
|
||||||
_coverPreviewUrl = api_util.getFileUrl(widget.account, coverFile);
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +161,10 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
Api.getAuthorizationHeaderValue(widget.account),
|
Api.getAuthorizationHeaderValue(widget.account),
|
||||||
},
|
},
|
||||||
filterQuality: FilterQuality.high,
|
filterQuality: FilterQuality.high,
|
||||||
|
errorWidget: (context, url, error) {
|
||||||
|
// just leave it empty
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -262,13 +263,8 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
.sorted(compareFileDateTimeDescending);
|
.sorted(compareFileDateTimeDescending);
|
||||||
|
|
||||||
itemStreamListItems = _backingFiles.mapWithIndex((i, e) {
|
itemStreamListItems = _backingFiles.mapWithIndex((i, e) {
|
||||||
var previewUrl;
|
final previewUrl = api_util.getFilePreviewUrl(widget.account, e,
|
||||||
if (e.hasPreview) {
|
width: _thumbSize, height: _thumbSize);
|
||||||
previewUrl = api_util.getFilePreviewUrl(widget.account, e,
|
|
||||||
width: _thumbSize, height: _thumbSize);
|
|
||||||
} else {
|
|
||||||
previewUrl = api_util.getFileUrl(widget.account, e);
|
|
||||||
}
|
|
||||||
return _ImageListItem(
|
return _ImageListItem(
|
||||||
account: widget.account,
|
account: widget.account,
|
||||||
previewUrl: previewUrl,
|
previewUrl: previewUrl,
|
||||||
|
@ -319,6 +315,21 @@ class _ImageListItem extends SelectableItemStreamListItem {
|
||||||
},
|
},
|
||||||
fadeInDuration: const Duration(),
|
fadeInDuration: const Duration(),
|
||||||
filterQuality: FilterQuality.high,
|
filterQuality: FilterQuality.high,
|
||||||
|
errorWidget: (context, url, error) {
|
||||||
|
// where's the preview???
|
||||||
|
return Container(
|
||||||
|
color: AppTheme.getListItemBackgroundColor(context),
|
||||||
|
width: 128,
|
||||||
|
height: 128,
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
Icons.image_not_supported,
|
||||||
|
size: 56,
|
||||||
|
color: Colors.white.withOpacity(.8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -188,17 +188,13 @@ class _HomeAlbumsState extends State<HomeAlbums> {
|
||||||
final latestFile = album.items
|
final latestFile = album.items
|
||||||
.whereType<AlbumFileItem>()
|
.whereType<AlbumFileItem>()
|
||||||
.map((e) => e.file)
|
.map((e) => e.file)
|
||||||
.where((element) => file_util.isSupportedFormat(element))
|
.where((element) =>
|
||||||
|
file_util.isSupportedFormat(element) && element.hasPreview)
|
||||||
.sorted(compareFileDateTimeDescending)
|
.sorted(compareFileDateTimeDescending)
|
||||||
.first;
|
.first;
|
||||||
|
|
||||||
String previewUrl;
|
final previewUrl = api_util.getFilePreviewUrl(widget.account, latestFile,
|
||||||
if (latestFile.hasPreview) {
|
width: 512, height: 512);
|
||||||
previewUrl = api_util.getFilePreviewUrl(widget.account, latestFile,
|
|
||||||
width: 512, height: 512);
|
|
||||||
} else {
|
|
||||||
previewUrl = api_util.getFileUrl(widget.account, latestFile);
|
|
||||||
}
|
|
||||||
cover = FittedBox(
|
cover = FittedBox(
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
|
@ -209,6 +205,10 @@ class _HomeAlbumsState extends State<HomeAlbums> {
|
||||||
},
|
},
|
||||||
fadeInDuration: const Duration(),
|
fadeInDuration: const Duration(),
|
||||||
filterQuality: FilterQuality.high,
|
filterQuality: FilterQuality.high,
|
||||||
|
errorWidget: (context, url, error) {
|
||||||
|
// just leave it empty
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -360,13 +360,8 @@ class _HomePhotosState extends State<HomePhotos>
|
||||||
currentDateStr = newDateStr;
|
currentDateStr = newDateStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
var previewUrl;
|
final previewUrl = api_util.getFilePreviewUrl(widget.account, f,
|
||||||
if (f.hasPreview) {
|
width: _thumbSize, height: _thumbSize);
|
||||||
previewUrl = api_util.getFilePreviewUrl(widget.account, f,
|
|
||||||
width: _thumbSize, height: _thumbSize);
|
|
||||||
} else {
|
|
||||||
previewUrl = api_util.getFileUrl(widget.account, f);
|
|
||||||
}
|
|
||||||
yield _ImageListItem(
|
yield _ImageListItem(
|
||||||
file: f,
|
file: f,
|
||||||
account: widget.account,
|
account: widget.account,
|
||||||
|
@ -491,6 +486,21 @@ class _ImageListItem extends _FileListItem {
|
||||||
},
|
},
|
||||||
fadeInDuration: const Duration(),
|
fadeInDuration: const Duration(),
|
||||||
filterQuality: FilterQuality.high,
|
filterQuality: FilterQuality.high,
|
||||||
|
errorWidget: (context, url, error) {
|
||||||
|
// where's the preview???
|
||||||
|
return Container(
|
||||||
|
color: AppTheme.getListItemBackgroundColor(context),
|
||||||
|
width: 128,
|
||||||
|
height: 128,
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
Icons.image_not_supported,
|
||||||
|
size: 56,
|
||||||
|
color: Colors.white.withOpacity(.8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue