Przeglądaj źródła

fix: 避免共享元素动画闪现默认封面文字

HapeLee 4 miesięcy temu
rodzic
commit
04b04c8ef6

+ 14 - 6
app/src/main/java/io/legado/app/ui/widget/components/image/cover/CoilBookCover.kt

@@ -103,20 +103,24 @@ fun BookCoverImage(
         }
     }
 
+    val isUsingDefaultCover = finalPath == null || onlineCoverLoadFailed
+    val showLoadingDefault = sharedCoverKey == null && !isOnlineCoverLoaded
+    val showCustomDefault = hasCustomDefault &&
+        !isOnlineCoverLoaded &&
+        (isUsingDefaultCover || showLoadingDefault)
     val showDefaultIcon = !hasCustomDefault &&
         (
-            finalPath == null ||
-                onlineCoverLoadFailed ||
-                (showLoadingPlaceholder && !isOnlineCoverLoaded)
+            isUsingDefaultCover ||
+                (showLoadingPlaceholder && showLoadingDefault)
         )
     val isDefaultCoverVisible =
-        (hasCustomDefault && !isOnlineCoverLoaded) || showDefaultIcon
+        showCustomDefault || showDefaultIcon
     LaunchedEffect(isDefaultCoverVisible) {
         onDefaultCoverVisibilityChange?.invoke(isDefaultCoverVisible)
     }
 
     Box(modifier = modifier) {
-        if (hasCustomDefault && !isOnlineCoverLoaded) {
+        if (showCustomDefault) {
             AsyncImage(
                 model = buildCoverImageRequest(
                     context = context,
@@ -282,7 +286,11 @@ fun CoilBookCover(
         if (
             finalPath == null ||
             onlineCoverLoadFailed ||
-            (showLoadingPlaceholder && !isOnlineCoverLoaded)
+            (
+                sharedCoverKey == null &&
+                    showLoadingPlaceholder &&
+                    !isOnlineCoverLoaded
+                )
         ) {
             CoverTextOverlay(
                 name = name,