Forráskód Böngészése

converted raw exif button to listTile

ashilkn 2 éve
szülő
commit
0d1311ae57

+ 33 - 37
lib/ui/viewer/file/file_info_widget.dart

@@ -14,7 +14,7 @@ import 'package:photos/ui/components/icon_button_widget.dart';
 import 'package:photos/ui/components/title_bar_widget.dart';
 import 'package:photos/ui/viewer/file/collections_list_of_file_widget.dart';
 import 'package:photos/ui/viewer/file/device_folders_list_of_file_widget.dart';
-import 'package:photos/ui/viewer/file/raw_exif_button.dart';
+import 'package:photos/ui/viewer/file/raw_exif_list_tile_widget.dart';
 import "package:photos/utils/date_time_util.dart";
 import "package:photos/utils/exif_util.dart";
 import "package:photos/utils/file_util.dart";
@@ -245,45 +245,41 @@ class _FileInfoWidgetState extends State<FileInfoWidget> {
             )
           : const SizedBox.shrink(),
       _isImage
-          ? Padding(
-              padding: const EdgeInsets.fromLTRB(0, 24, 0, 16),
-              child: SafeArea(
-                child: RawExifButton(_exif, widget.file),
-              ),
-            )
-          : const SizedBox(
-              height: 12,
-            )
+          ? RawExifListTileWidget(_exif, widget.file)
+          : const SizedBox.shrink(),
     ];
 
-    return Padding(
-      padding: const EdgeInsets.all(8.0),
-      child: CustomScrollView(
-        shrinkWrap: true,
-        slivers: <Widget>[
-          TitleBarWidget(
-            isFlexibleSpaceDisabled: true,
-            title: "Details",
-            isOnTopOfScreen: false,
-            leading: IconButtonWidget(
-              icon: Icons.close_outlined,
-              iconButtonType: IconButtonType.primary,
-              onTap: () => Navigator.pop(context),
-            ),
-          ),
-          SliverList(
-            delegate: SliverChildBuilderDelegate(
-              (context, index) {
-                if (index.isOdd) {
-                  return const DividerWidget(dividerType: DividerType.menu);
-                } else {
-                  return listTiles[index ~/ 2];
-                }
-              },
-              childCount: (listTiles.length * 2) - 1,
+    return SafeArea(
+      top: false,
+      child: Padding(
+        padding: const EdgeInsets.all(8.0),
+        child: CustomScrollView(
+          shrinkWrap: true,
+          slivers: <Widget>[
+            TitleBarWidget(
+              isFlexibleSpaceDisabled: true,
+              title: "Details",
+              isOnTopOfScreen: false,
+              leading: IconButtonWidget(
+                icon: Icons.close_outlined,
+                iconButtonType: IconButtonType.primary,
+                onTap: () => Navigator.pop(context),
+              ),
             ),
-          )
-        ],
+            SliverList(
+              delegate: SliverChildBuilderDelegate(
+                (context, index) {
+                  if (index.isOdd) {
+                    return const DividerWidget(dividerType: DividerType.menu);
+                  } else {
+                    return listTiles[index ~/ 2];
+                  }
+                },
+                childCount: (listTiles.length * 2) - 1,
+              ),
+            )
+          ],
+        ),
       ),
     );
   }

+ 0 - 100
lib/ui/viewer/file/raw_exif_button.dart

@@ -1,100 +0,0 @@
-// @dart=2.9
-
-import 'package:exif/exif.dart';
-import 'package:flutter/cupertino.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 RawExifButton extends StatelessWidget {
-  final File file;
-  final Map<String, IfdTag> exif;
-  const RawExifButton(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.loading || 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: Container(
-        height: 40,
-        width: 140,
-        decoration: BoxDecoration(
-          color: Theme.of(context)
-              .colorScheme
-              .inverseBackgroundColor
-              .withOpacity(0.12),
-          borderRadius: const BorderRadius.all(
-            Radius.circular(20),
-          ),
-        ),
-        child: Center(
-          child: exifStatus == Status.loading
-              ? Row(
-                  mainAxisAlignment: MainAxisAlignment.center,
-                  children: const [
-                    CupertinoActivityIndicator(
-                      radius: 8,
-                    ),
-                    SizedBox(
-                      width: 8,
-                    ),
-                    Text('EXIF')
-                  ],
-                )
-              : exifStatus == Status.exifIsAvailable
-                  ? Row(
-                      mainAxisAlignment: MainAxisAlignment.center,
-                      children: const [
-                        Icon(Icons.feed_outlined),
-                        SizedBox(
-                          width: 8,
-                        ),
-                        Text('Raw EXIF'),
-                      ],
-                    )
-                  : Row(
-                      mainAxisAlignment: MainAxisAlignment.center,
-                      children: const [
-                        Icon(Icons.feed_outlined),
-                        SizedBox(
-                          width: 8,
-                        ),
-                        Text('No EXIF'),
-                      ],
-                    ),
-        ),
-      ),
-    );
-  }
-}

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

@@ -0,0 +1,120 @@
+// @dart=2.9
+
+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(
+        leading: const Padding(
+          padding: EdgeInsets.only(top: 8, left: 6),
+          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),
+              ),
+        ),
+      ),
+      //  Container(
+      //   height: 40,
+      //   width: 140,
+      //   decoration: BoxDecoration(
+      //     color: Theme.of(context)
+      //         .colorScheme
+      //         .inverseBackgroundColor
+      //         .withOpacity(0.12),
+      //     borderRadius: const BorderRadius.all(
+      //       Radius.circular(20),
+      //     ),
+      //   ),
+      //   child: Center(
+      //     child: exifStatus == Status.loading
+      //         ? Row(
+      //             mainAxisAlignment: MainAxisAlignment.center,
+      //             children: const [
+      //               CupertinoActivityIndicator(
+      //                 radius: 8,
+      //               ),
+      //               SizedBox(
+      //                 width: 8,
+      //               ),
+      //               Text('EXIF')
+      //             ],
+      //           )
+      //         : exifStatus == Status.exifIsAvailable
+      //             ? Row(
+      //                 mainAxisAlignment: MainAxisAlignment.center,
+      //                 children: const [
+      //                   Icon(Icons.feed_outlined),
+      //                   SizedBox(
+      //                     width: 8,
+      //                   ),
+      //                   Text('Raw EXIF'),
+      //                 ],
+      //               )
+      //             : Row(
+      //                 mainAxisAlignment: MainAxisAlignment.center,
+      //                 children: const [
+      //                   Icon(Icons.feed_outlined),
+      //                   SizedBox(
+      //                     width: 8,
+      //                   ),
+      //                   Text('No EXIF'),
+      //                 ],
+      //               ),
+      //   ),
+      // ),
+    );
+  }
+}