Selaa lähdekoodia

Performance imporvements to thumbnail (#1099)

Ashil 2 vuotta sitten
vanhempi
commit
7826ed0539

+ 1 - 5
lib/ui/viewer/file/thumbnail_widget.dart

@@ -170,11 +170,7 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
     }
     final List<Widget> viewChildren = [
       const ThumbnailPlaceHolder(),
-      AnimatedOpacity(
-        opacity: content == null ? 0 : 1.0,
-        duration: const Duration(milliseconds: 200),
-        child: content,
-      )
+      content ?? const SizedBox(),
     ];
     if (widget.shouldShowSyncStatus && widget.file!.uploadedFileID == null) {
       viewChildren.add(const UnSyncedIcon());

+ 50 - 38
lib/ui/viewer/gallery/component/gallery_file_widget.dart

@@ -60,46 +60,58 @@ class GalleryFileWidget extends StatelessWidget {
             ? _onLongPressWithSelectionLimit(context, file)
             : _onLongPressNoSelectionLimit(context, file);
       },
-      child: ClipRRect(
-        borderRadius: BorderRadius.circular(1),
-        child: Stack(
-          children: [
-            Hero(
+      child: Stack(
+        children: [
+          ClipRRect(
+            borderRadius: BorderRadius.circular(1),
+            child: Hero(
               tag: tag + file.tag,
-              child: ColorFiltered(
-                colorFilter: ColorFilter.mode(
-                  Colors.black.withOpacity(
-                    isFileSelected ? 0.4 : 0,
-                  ),
-                  BlendMode.darken,
-                ),
-                child: ThumbnailWidget(
-                  file,
-                  diskLoadDeferDuration: thumbnailDiskLoadDeferDuration,
-                  serverLoadDeferDuration: thumbnailServerLoadDeferDuration,
-                  shouldShowLivePhotoOverlay: true,
-                  key: Key(tag + file.tag),
-                  thumbnailSize: photoGridSize < photoGridSizeDefault
-                      ? thumbnailLargeSize
-                      : thumbnailSmallSize,
-                  shouldShowOwnerAvatar: !isFileSelected,
-                ),
-              ),
+              child: isFileSelected
+                  ? ColorFiltered(
+                      colorFilter: ColorFilter.mode(
+                        Colors.black.withOpacity(
+                          0.4,
+                        ),
+                        BlendMode.darken,
+                      ),
+                      child: ThumbnailWidget(
+                        file,
+                        diskLoadDeferDuration: thumbnailDiskLoadDeferDuration,
+                        serverLoadDeferDuration:
+                            thumbnailServerLoadDeferDuration,
+                        shouldShowLivePhotoOverlay: true,
+                        key: Key(tag + file.tag),
+                        thumbnailSize: photoGridSize < photoGridSizeDefault
+                            ? thumbnailLargeSize
+                            : thumbnailSmallSize,
+                        shouldShowOwnerAvatar: !isFileSelected,
+                      ),
+                    )
+                  : ThumbnailWidget(
+                      file,
+                      diskLoadDeferDuration: thumbnailDiskLoadDeferDuration,
+                      serverLoadDeferDuration: thumbnailServerLoadDeferDuration,
+                      shouldShowLivePhotoOverlay: true,
+                      key: Key(tag + file.tag),
+                      thumbnailSize: photoGridSize < photoGridSizeDefault
+                          ? thumbnailLargeSize
+                          : thumbnailSmallSize,
+                      shouldShowOwnerAvatar: !isFileSelected,
+                    ),
             ),
-            Visibility(
-              visible: isFileSelected,
-              child: Positioned(
-                right: 4,
-                top: 4,
-                child: Icon(
-                  Icons.check_circle_rounded,
-                  size: 20,
-                  color: selectionColor, //same for both themes
-                ),
-              ),
-            )
-          ],
-        ),
+          ),
+          isFileSelected
+              ? Positioned(
+                  right: 4,
+                  top: 4,
+                  child: Icon(
+                    Icons.check_circle_rounded,
+                    size: 20,
+                    color: selectionColor, //same for both themes
+                  ),
+                )
+              : const SizedBox.shrink(),
+        ],
       ),
     );
   }