kopia lustrzana https://github.com/vitorpamplona/amethyst
Refactors the url preview state
rodzic
d33a1ce14f
commit
d2872cc8bb
|
@ -61,25 +61,7 @@ fun LoadUrlPreview(
|
||||||
) { state ->
|
) { state ->
|
||||||
when (state) {
|
when (state) {
|
||||||
is UrlPreviewState.Loaded -> {
|
is UrlPreviewState.Loaded -> {
|
||||||
if (state.previewInfo.mimeType.type == "image") {
|
RenderLoaded(state, url, accountViewModel)
|
||||||
Box(modifier = HalfVertPadding) {
|
|
||||||
ZoomableContentView(
|
|
||||||
content = MediaUrlImage(url),
|
|
||||||
roundedCorner = true,
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else if (state.previewInfo.mimeType.type == "video") {
|
|
||||||
Box(modifier = HalfVertPadding) {
|
|
||||||
ZoomableContentView(
|
|
||||||
content = MediaUrlVideo(url),
|
|
||||||
roundedCorner = true,
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
UrlPreviewCard(url, state.previewInfo)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
ClickableUrl(urlText, url)
|
ClickableUrl(urlText, url)
|
||||||
|
@ -88,3 +70,30 @@ fun LoadUrlPreview(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun RenderLoaded(
|
||||||
|
state: UrlPreviewState.Loaded,
|
||||||
|
url: String,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
) {
|
||||||
|
if (state.previewInfo.mimeType.type == "image") {
|
||||||
|
Box(modifier = HalfVertPadding) {
|
||||||
|
ZoomableContentView(
|
||||||
|
content = MediaUrlImage(url),
|
||||||
|
roundedCorner = true,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if (state.previewInfo.mimeType.type == "video") {
|
||||||
|
Box(modifier = HalfVertPadding) {
|
||||||
|
ZoomableContentView(
|
||||||
|
content = MediaUrlVideo(url),
|
||||||
|
roundedCorner = true,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UrlPreviewCard(url, state.previewInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue