Просмотр исходного кода

Used InfoItemWidget for EXIF tile in file info

ashilkn 2 лет назад
Родитель
Сommit
472377dbdf

+ 41 - 2
lib/ui/viewer/file/file_info_widget.dart

@@ -16,15 +16,17 @@ import "package:photos/models/gallery_type.dart";
 import 'package:photos/services/collections_service.dart';
 import "package:photos/services/feature_flag_service.dart";
 import "package:photos/services/object_detection/object_detection_service.dart";
+import "package:photos/theme/colors.dart";
 import 'package:photos/theme/ente_theme.dart';
 import "package:photos/ui/common/loading_widget.dart";
 import "package:photos/ui/components/buttons/chip_button_widget.dart";
 import 'package:photos/ui/components/buttons/icon_button_widget.dart';
+import "package:photos/ui/components/buttons/inline_button_widget.dart";
 import 'package:photos/ui/components/divider_widget.dart';
 import "package:photos/ui/components/info_item_widget.dart";
 import 'package:photos/ui/components/title_bar_widget.dart';
+import "package:photos/ui/viewer/file/exif_info_dialog.dart";
 import 'package:photos/ui/viewer/file/file_caption_widget.dart';
-import 'package:photos/ui/viewer/file/raw_exif_list_tile_widget.dart';
 import "package:photos/ui/viewer/gallery/collection_page.dart";
 import "package:photos/utils/date_time_util.dart";
 import "package:photos/utils/exif_util.dart";
@@ -32,6 +34,7 @@ import "package:photos/utils/file_util.dart";
 import "package:photos/utils/magic_util.dart";
 import "package:photos/utils/navigation_util.dart";
 import "package:photos/utils/thumbnail_util.dart";
+import "package:photos/utils/toast_util.dart";
 
 class FileInfoWidget extends StatefulWidget {
   final File file;
@@ -226,7 +229,13 @@ class _FileInfoWidgetState extends State<FileInfoWidget> {
               ]),
             )
           : null,
-      _isImage ? RawExifListTileWidget(_exif, widget.file) : null,
+      _isImage
+          ? InfoItemWidget(
+              leadingIcon: Icons.text_snippet_outlined,
+              title: "EXIF",
+              subtitleSection: _exifButton(file, _exif),
+            )
+          : null,
     ];
 
     listTiles.removeWhere(
@@ -281,6 +290,36 @@ class _FileInfoWidgetState extends State<FileInfoWidget> {
     );
   }
 
+  Future<List<InlineButtonWidget>> _exifButton(
+    File file,
+    Map<String, IfdTag>? exif,
+  ) {
+    late final String label;
+    late final VoidCallback? onTap;
+    if (exif == null) {
+      label = "Loading EXIF data...";
+      onTap = null;
+    } else if (exif.isNotEmpty) {
+      label = "View all EXIF data";
+      onTap = () => showDialog(
+            context: context,
+            builder: (BuildContext context) {
+              return ExifInfoDialog(file);
+            },
+            barrierColor: backdropFaintDark,
+          );
+    } else {
+      label = "No EXIF data";
+      onTap = () => showShortToast(context, "This image has no exif data");
+    }
+    return Future.value([
+      InlineButtonWidget(
+        label,
+        onTap,
+      )
+    ]);
+  }
+
   Future<List<ChipButtonWidget>> _objectTags(File file) async {
     try {
       final chipButtons = <ChipButtonWidget>[];

+ 0 - 69
lib/ui/viewer/file/raw_exif_list_tile_widget.dart

@@ -1,69 +0,0 @@
-import 'package:exif/exif.dart';
-import 'package:flutter/material.dart';
-import 'package:photos/ente_theme_data.dart';
-import "package:photos/models/file.dart";
-import 'package:photos/ui/viewer/file/exif_info_dialog.dart';
-import 'package:photos/utils/toast_util.dart';
-
-enum Status {
-  loading,
-  exifIsAvailable,
-  noExif,
-}
-
-class RawExifListTileWidget extends StatelessWidget {
-  final File file;
-  final Map<String, IfdTag>? exif;
-  const RawExifListTileWidget(this.exif, this.file, {Key? key})
-      : super(key: key);
-
-  @override
-  Widget build(BuildContext context) {
-    Status exifStatus = Status.loading;
-    if (exif == null) {
-      exifStatus = Status.loading;
-    } else if (exif!.isNotEmpty) {
-      exifStatus = Status.exifIsAvailable;
-    } else {
-      exifStatus = Status.noExif;
-    }
-    return GestureDetector(
-      onTap: exifStatus == Status.exifIsAvailable
-          ? () {
-              showDialog(
-                context: context,
-                builder: (BuildContext context) {
-                  return ExifInfoDialog(file);
-                },
-                barrierColor: Colors.black87,
-              );
-            }
-          : exifStatus == Status.noExif
-              ? () {
-                  showShortToast(context, "This image has no exif data");
-                }
-              : null,
-      child: ListTile(
-        horizontalTitleGap: 2,
-        leading: const Padding(
-          padding: EdgeInsets.only(top: 8),
-          child: Icon(Icons.feed_outlined),
-        ),
-        title: const Text("EXIF"),
-        subtitle: Text(
-          exifStatus == Status.loading
-              ? "Loading EXIF data.."
-              : exifStatus == Status.exifIsAvailable
-                  ? "View all EXIF data"
-                  : "No EXIF data",
-          style: Theme.of(context).textTheme.bodyText2!.copyWith(
-                color: Theme.of(context)
-                    .colorScheme
-                    .defaultTextColor
-                    .withOpacity(0.5),
-              ),
-        ),
-      ),
-    );
-  }
-}