From 292e44ded7e6ec46a676202a45bfeae577de9c0f Mon Sep 17 00:00:00 2001 From: Marty Fuhry Date: Mon, 8 May 2023 10:12:15 -0400 Subject: [PATCH] Removed extraenous nesting else statements and added comments --- .../asset_viewer/views/gallery_viewer.dart | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart index d2e24e435..5dd83b6d3 100644 --- a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart +++ b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart @@ -373,24 +373,31 @@ class GalleryViewerPage extends HookConsumerWidget { ); } + /// The image provider to use for the given asset ImageProvider imageProvider(Asset asset) { + // Local assets if (asset.isLocal) { return localImageProvider(asset); - } else { - if (isLoadOriginal.value) { - return originalImageProvider(asset); - } else if (isLoadPreview.value) { - return remoteThumbnailImageProvider( - asset, - api.ThumbnailFormat.JPEG, - ); - } else { - return remoteThumbnailImageProvider( - asset, - api.ThumbnailFormat.WEBP, - ); - } } + + // Original assets + if (isLoadOriginal.value) { + return originalImageProvider(asset); + } + + // Preview uses remote JPEG + if (isLoadPreview.value) { + return remoteThumbnailImageProvider( + asset, + api.ThumbnailFormat.JPEG, + ); + } + + // Otherwise, use the thumbnail preview + return remoteThumbnailImageProvider( + asset, + api.ThumbnailFormat.WEBP, + ); } return Scaffold(