Преглед на файлове

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

* fix 0,0 location

* image details cleanup

* Static anal fix
Dhrumil Shah преди 1 година
родител
ревизия
fb477627c7
променени са 1 файла, в които са добавени 58 реда и са изтрити 18 реда
  1. 58 18
      mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dart

+ 58 - 18
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),