浏览代码

Show uploader avatar for collected files

vishnukvmd 2 年之前
父节点
当前提交
e0f6db707c

+ 9 - 1
lib/models/magic_metadata.dart

@@ -15,6 +15,7 @@ const subTypeKey = 'subType';
 const pubMagicKeyEditedTime = 'editedTime';
 const pubMagicKeyEditedName = 'editedName';
 const pubMagicKeyCaption = "caption";
+const pubMagicKeyUploaderName = "uploaderName";
 
 class MagicMetadata {
   // 0 -> visible
@@ -41,8 +42,14 @@ class PubMagicMetadata {
   int? editedTime;
   String? editedName;
   String? caption;
+  String? uploaderName;
 
-  PubMagicMetadata({this.editedTime, this.editedName, this.caption});
+  PubMagicMetadata({
+    this.editedTime,
+    this.editedName,
+    this.caption,
+    this.uploaderName,
+  });
 
   factory PubMagicMetadata.fromEncodedJson(String encodedJson) =>
       PubMagicMetadata.fromJson(jsonDecode(encodedJson));
@@ -56,6 +63,7 @@ class PubMagicMetadata {
       editedTime: map[pubMagicKeyEditedTime],
       editedName: map[pubMagicKeyEditedName],
       caption: map[pubMagicKeyCaption],
+      uploaderName: map[pubMagicKeyUploaderName],
     );
   }
 }

+ 0 - 1
lib/ui/collections/collection_item_widget.dart

@@ -43,7 +43,6 @@ class CollectionItem extends StatelessWidget {
                             c.thumbnail,
                             shouldShowArchiveStatus: c.collection.isArchived(),
                             showFavForAlbumOnly: true,
-                            shownAsAlbumCover: true,
                             key: Key(heroTag),
                           )
                         : const NoThumbnailWidget(),

+ 1 - 0
lib/ui/huge_listview/lazy_loading_gallery.dart

@@ -437,6 +437,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
                   thumbnailSize: widget.photoGridSize < photoGridSizeDefault
                       ? thumbnailLargeSize
                       : thumbnailSmallSize,
+                  shouldShowOwnerAvatar: true,
                 ),
               ),
             ),

+ 0 - 2
lib/ui/shared_collections_gallery.dart

@@ -296,7 +296,6 @@ class OutgoingCollectionItem extends StatelessWidget {
                   tag: "outgoing_collection" + c.thumbnail.tag,
                   child: ThumbnailWidget(
                     c.thumbnail,
-                    shownAsAlbumCover: true,
                     key: Key("outgoing_collection" + c.thumbnail.tag),
                   ),
                 ),
@@ -389,7 +388,6 @@ class IncomingCollectionItem extends StatelessWidget {
                     child: ThumbnailWidget(
                       c.thumbnail,
                       key: Key("shared_collection" + c.thumbnail.tag),
-                      shownAsAlbumCover: true,
                     ),
                   ),
                   Align(

+ 24 - 13
lib/ui/viewer/file/thumbnail_widget.dart

@@ -11,6 +11,7 @@ import 'package:photos/db/files_db.dart';
 import 'package:photos/db/trash_db.dart';
 import 'package:photos/events/files_updated_event.dart';
 import 'package:photos/events/local_photos_updated_event.dart';
+import 'package:photos/models/collection.dart';
 import 'package:photos/models/file.dart';
 import 'package:photos/models/file_type.dart';
 import 'package:photos/models/trash_file.dart';
@@ -30,7 +31,7 @@ class ThumbnailWidget extends StatefulWidget {
   final Duration diskLoadDeferDuration;
   final Duration serverLoadDeferDuration;
   final int thumbnailSize;
-  final bool shownAsAlbumCover;
+  final bool shouldShowOwnerAvatar;
 
   ThumbnailWidget(
     this.file, {
@@ -40,7 +41,7 @@ class ThumbnailWidget extends StatefulWidget {
     this.shouldShowLivePhotoOverlay = false,
     this.shouldShowArchiveStatus = false,
     this.showFavForAlbumOnly = false,
-    this.shownAsAlbumCover = false,
+    this.shouldShowOwnerAvatar = false,
     this.diskLoadDeferDuration,
     this.serverLoadDeferDuration,
     this.thumbnailSize = thumbnailSmallSize,
@@ -115,17 +116,27 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
           widget.shouldShowLivePhotoOverlay) {
         contentChildren.add(const LivePhotoOverlayIcon());
       }
-      if (widget.file.ownerID != null &&
-          widget.file.ownerID != Configuration.instance.getUserID() &&
-          widget.shownAsAlbumCover == false) {
-        // hide this icon if the current thumbnail is being showed as album
-        // cover
-        contentChildren.add(
-          OwnerAvatarOverlayIcon(
-            CollectionsService.instance
-                .getFileOwner(widget.file.ownerID, widget.file.collectionID),
-          ),
-        );
+      if (widget.shouldShowOwnerAvatar) {
+        final owner = CollectionsService.instance
+            .getFileOwner(widget.file.ownerID, widget.file.collectionID);
+        if (widget.file.ownerID != null &&
+            widget.file.ownerID != Configuration.instance.getUserID()) {
+          // hide this icon if the current thumbnail is being showed as album
+          // cover
+          contentChildren.add(
+            OwnerAvatarOverlayIcon(owner),
+          );
+        } else if (widget.file.pubMagicMetadata.uploaderName != null) {
+          contentChildren.add(
+            OwnerAvatarOverlayIcon(
+              User(
+                id: widget.file.ownerID,
+                email: owner.email,
+                name: widget.file.pubMagicMetadata.uploaderName,
+              ),
+            ),
+          );
+        }
       }
       content = contentChildren.length == 1
           ? contentChildren.first