Merge EhPreviewItem and its placeholder
This commit is contained in:
1 parent
e16b5b0437
commit
24664d4e83
3 files changed
+5
-25
No files matched your search
@@ -87,22 +87,7 @@ fun EhAsyncPreview(
|
||||
|
||||
@Composable
|
||||
fun EhPreviewItem(
|
||||
galleryPreview: GalleryPreview,
|
||||
onClick: () -> Unit,
|
||||
) = Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
CrystalCard(
|
||||
onClick = onClick,
|
||||
modifier = Modifier.fillMaxWidth().aspectRatio(0.6666667F),
|
||||
) {
|
||||
EhAsyncPreview(model = galleryPreview, modifier = Modifier.fillMaxSize())
|
||||
}
|
||||
}
|
||||
Text((galleryPreview.position + 1).toString())
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun EhPreviewItemPlaceholder(
|
||||
galleryPreview: GalleryPreview?,
|
||||
position: Int,
|
||||
onClick: () -> Unit,
|
||||
) = Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
@@ -111,6 +96,7 @@ fun EhPreviewItemPlaceholder(
|
||||
onClick = onClick,
|
||||
modifier = Modifier.fillMaxWidth().aspectRatio(0.6666667F),
|
||||
) {
|
||||
if (galleryPreview != null) EhAsyncPreview(model = galleryPreview, modifier = Modifier.fillMaxSize())
|
||||
}
|
||||
}
|
||||
Text((position + 1).toString())
|
||||
|
||||
@@ -636,6 +636,7 @@ class GalleryDetailScene : BaseScene() {
|
||||
items(previewList) {
|
||||
EhPreviewItem(
|
||||
galleryPreview = it,
|
||||
position = it.position,
|
||||
onClick = { context?.navToReader(gd, it.position) },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ import com.hippo.ehviewer.coil.imageRequest
|
||||
import com.hippo.ehviewer.coil.justDownload
|
||||
import com.hippo.ehviewer.ui.legacy.calculateSuitableSpanCount
|
||||
import com.hippo.ehviewer.ui.main.EhPreviewItem
|
||||
import com.hippo.ehviewer.ui.main.EhPreviewItemPlaceholder
|
||||
import com.hippo.ehviewer.ui.navToReader
|
||||
import com.hippo.ehviewer.ui.setMD3Content
|
||||
import com.hippo.ehviewer.ui.tools.rememberDialogState
|
||||
@@ -154,14 +153,8 @@ class GalleryPreviewScreen : Fragment() {
|
||||
contentType = data.itemContentType(),
|
||||
) { index ->
|
||||
val item = data[index]
|
||||
if (item != null) {
|
||||
EhPreviewItem(item) {
|
||||
onPreviewCLick(item.position)
|
||||
}
|
||||
} else {
|
||||
EhPreviewItemPlaceholder(index) {
|
||||
onPreviewCLick(index)
|
||||
}
|
||||
EhPreviewItem(item, index) {
|
||||
onPreviewCLick(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user