Skip to content

High performance self-hosted photo and video management solution.

fix(mobile): Clean up image details if there is missing info (#4018)

Dhrumil Shahfb477627c755
diff --git a/mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dart b/mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dart
index eec80b7d54..9293ac1506 100644
--- a/mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dart
+++ b/mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dart
@@ -18,7 +18,10 @@ class ExifBottomSheet extends HookConsumerWidget {
const ExifBottomSheet({Key? key, required this.asset}) : super(key: key);
bool get hasCoordinates =>
- asset.exifInfo?.latitude != null && asset.exifInfo?.longitude != null;
+ asset.exifInfo?.latitude != null &&
+ asset.exifInfo?.longitude != null &&
+ asset.exifInfo!.latitude! != 0 &&
+ asset.exifInfo!.longitude! != 0;
String get formattedDateTime {
final fileCreatedAt = asset.fileCreatedAt.toLocal();
@@ -124,7 +127,7 @@ class ExifBottomSheet extends HookConsumerWidget {
? formatBytes(a.exifInfo!.fileSize!)
: "";
String text = resolution + fileSize;
- return text.isEmpty ? null : Text(text);
+ return text.isNotEmpty ? text : null;
}
buildDragHeader() {
@@ -207,8 +210,60 @@ class ExifBottomSheet extends HookConsumerWidget {
),
);
}
+
+
+ buildImageProperties() {
+ // Helper to create the ListTile and avoid repeating code
+ createImagePropertiesListStyle(title, subtitle) => ListTile(
+ contentPadding: const EdgeInsets.all(0),
+ dense: true,
+ leading: Icon(
+ Icons.image,
+ color: textColor.withAlpha(200),
+ ),
+ titleAlignment: ListTileTitleAlignment.center,
+ title: Text(
+ title,
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ color: textColor,
+ ),
+ ),
+ subtitle: subtitle,
+ );
+
+ final imgSizeString = buildSizeText(asset);
+
+ if (imgSizeString == null && asset.fileName.isNotEmpty) {
+ // There is only filename
+ return createImagePropertiesListStyle(
+ asset.fileName,
+ null,
+ );
+ } else if (imgSizeString != null && asset.fileName.isNotEmpty) {
+ // There is both filename and size information
+ return createImagePropertiesListStyle(
+ asset.fileName,
+ Text(imgSizeString),
+ );
+ } else if (imgSizeString != null && asset.fileName.isEmpty) {
+ // There is only size information
+ return createImagePropertiesListStyle(
+ imgSizeString,
+ null,
+ );
+ }
+ }
buildDetail() {
+ final imgProperties = buildImageProperties();
+
+ // There are no details
+ if (imgProperties == null &&
+ (exifInfo == null || exifInfo.make == null)) {
+ return Container();
+ }
+
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -223,22 +278,7 @@ class ExifBottomSheet extends HookConsumerWidget {
),
).tr(),
),
- ListTile(
- contentPadding: const EdgeInsets.all(0),
- dense: true,
- leading: Icon(
- Icons.image,
- color: textColor.withAlpha(200),
- ),
- title: Text(
- asset.fileName,
- style: TextStyle(
- fontWeight: FontWeight.bold,
- color: textColor,
- ),
- ),
- subtitle: buildSizeText(asset),
- ),
+ if (imgProperties != null) imgProperties,
if (exifInfo?.make != null)
ListTile(
contentPadding: const EdgeInsets.all(0),