From 2e9bc412f58c03d5886871ee5ba56f691f496760 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Tue, 22 Jun 2021 12:52:50 +0800 Subject: [PATCH] Tweak layout of photo items --- lib/widget/photo_list_item.dart | 96 +++++++++++++++++---------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/lib/widget/photo_list_item.dart b/lib/widget/photo_list_item.dart index 384460ed..b8b06869 100644 --- a/lib/widget/photo_list_item.dart +++ b/lib/widget/photo_list_item.dart @@ -17,29 +17,33 @@ class PhotoListImage extends StatelessWidget { return FittedBox( clipBehavior: Clip.hardEdge, fit: BoxFit.cover, - child: CachedNetworkImage( - imageUrl: previewUrl, - httpHeaders: { - "Authorization": Api.getAuthorizationHeaderValue(account), - }, - fadeInDuration: const Duration(), - 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), + child: Container( + // arbitrary size here + constraints: BoxConstraints.tight(const Size(128, 128)), + color: AppTheme.getListItemBackgroundColor(context), + child: CachedNetworkImage( + imageUrl: previewUrl, + httpHeaders: { + "Authorization": Api.getAuthorizationHeaderValue(account), + }, + fadeInDuration: const Duration(), + filterQuality: FilterQuality.high, + errorWidget: (context, url, error) { + // won't work on web because the image is downloaded by the cache + // manager instead + // where's the preview??? + return Container( + child: Center( + child: Icon( + Icons.image_not_supported, + size: 64, + color: Colors.white.withOpacity(.8), + ), ), - ), - ); - }, - imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet, + ); + }, + imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet, + ), ), ); } @@ -60,30 +64,32 @@ class PhotoListVideo extends StatelessWidget { return FittedBox( clipBehavior: Clip.hardEdge, fit: BoxFit.cover, - child: CachedNetworkImage( - imageUrl: previewUrl, - httpHeaders: { - "Authorization": Api.getAuthorizationHeaderValue(account), - }, - fadeInDuration: const Duration(), - filterQuality: FilterQuality.high, - errorWidget: (context, url, error) { - // no preview for this video. Normal since video preview is disabled - // by default - return Container( - color: AppTheme.getListItemBackgroundColor(context), - width: 128, - height: 128, - child: Center( - child: Icon( - Icons.videocam, - size: 56, - color: Colors.white.withOpacity(.8), + child: Container( + // arbitrary size here + constraints: BoxConstraints.tight(const Size(128, 128)), + color: AppTheme.getListItemBackgroundColor(context), + child: CachedNetworkImage( + imageUrl: previewUrl, + httpHeaders: { + "Authorization": Api.getAuthorizationHeaderValue(account), + }, + fadeInDuration: const Duration(), + filterQuality: FilterQuality.high, + errorWidget: (context, url, error) { + // no preview for this video. Normal since video preview is disabled + // by default + return Container( + child: Center( + child: Icon( + Icons.videocam, + size: 64, + color: Colors.white.withOpacity(.8), + ), ), - ), - ); - }, - imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet, + ); + }, + imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet, + ), ), ); }