Refactors the url preview state

This commit is contained in:
Vitor Pamplona
2024-04-08 18:34:10 -04:00
parent d33a1ce14f
commit d2872cc8bb
@@ -61,6 +61,22 @@ fun LoadUrlPreview(
) { state ->
when (state) {
is UrlPreviewState.Loaded -> {
RenderLoaded(state, url, accountViewModel)
}
else -> {
ClickableUrl(urlText, url)
}
}
}
}
}
@Composable
fun RenderLoaded(
state: UrlPreviewState.Loaded,
url: String,
accountViewModel: AccountViewModel,
) {
if (state.previewInfo.mimeType.type == "image") {
Box(modifier = HalfVertPadding) {
ZoomableContentView(
@@ -80,11 +96,4 @@ fun LoadUrlPreview(
} else {
UrlPreviewCard(url, state.previewInfo)
}
}
else -> {
ClickableUrl(urlText, url)
}
}
}
}
}