Applies remember functions to more parameters.
This commit is contained in:
@@ -10,6 +10,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
@@ -41,13 +42,15 @@ fun UrlPreviewCard(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
val validatedUrl = URL(previewInfo.url)
|
val validatedUrl = remember { URL(previewInfo.url) }
|
||||||
|
|
||||||
// correctly treating relative images
|
// correctly treating relative images
|
||||||
val imageUrl = if (previewInfo.image.startsWith("/")) {
|
val imageUrl = remember {
|
||||||
URL(validatedUrl, previewInfo.image).toString()
|
if (previewInfo.image.startsWith("/")) {
|
||||||
} else {
|
URL(validatedUrl, previewInfo.image).toString()
|
||||||
previewInfo.image
|
} else {
|
||||||
|
previewInfo.image
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
|
|||||||
@@ -116,9 +116,9 @@ fun VideoView(videoUri: Uri, description: String? = null, onDialog: ((Boolean) -
|
|||||||
.defaultMinSize(minHeight = 70.dp)
|
.defaultMinSize(minHeight = 70.dp)
|
||||||
.align(Alignment.Center)
|
.align(Alignment.Center)
|
||||||
.onVisibilityChanges { visible ->
|
.onVisibilityChanges { visible ->
|
||||||
if (visible) {
|
if (visible && !exoPlayer.isPlaying) {
|
||||||
exoPlayer.play()
|
exoPlayer.play()
|
||||||
} else {
|
} else if (!visible && exoPlayer.isPlaying) {
|
||||||
exoPlayer.pause()
|
exoPlayer.pause()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -280,12 +280,16 @@ private fun UrlImageView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
BoxWithConstraints(contentAlignment = Alignment.Center) {
|
BoxWithConstraints(contentAlignment = Alignment.Center) {
|
||||||
val myModifier = mainImageModifier.run {
|
val myModifier = remember {
|
||||||
aspectRatio(content.dim)?.let { ratio ->
|
mainImageModifier.run {
|
||||||
this.aspectRatio(ratio, maxHeight.isFinite)
|
aspectRatio(content.dim)?.let { ratio ->
|
||||||
} ?: this
|
this.aspectRatio(ratio, maxHeight.isFinite)
|
||||||
|
} ?: this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val contentScale = remember {
|
||||||
|
if (maxHeight.isFinite) ContentScale.Inside else ContentScale.FillWidth
|
||||||
}
|
}
|
||||||
val contentScale = if (maxHeight.isFinite) ContentScale.Inside else ContentScale.FillWidth
|
|
||||||
|
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = content.url,
|
model = content.url,
|
||||||
|
|||||||
Reference in New Issue
Block a user