Khanzada Kashif
09/06/2023, 7:02 PM@Composable
actual fun MyAsyncImage(
url: String,
contentScale: ContentScale,
contentDescription: String?,
modifier: Modifier,
) {
Box(
modifier = modifier
) {
UIKitView(
factory = {
UIImageView().apply {
loadImageFromUrl(url = url)
}
},
modifier = Modifier
)
Box(modifier = Modifier.fillMaxSize())
}
}
fun UIImageView.loadImageFromUrl(url: String) {
if (url.contains("\\s".toRegex()).not())
NSURLSession.sharedSession.dataTaskWithURL(
url = NSURL(string = url),
completionHandler = { data, response, error ->
if (error == null && response != null && data != null) {
if ((response as NSHTTPURLResponse).statusCode == 200L) {
CoroutineScope(Dispatchers.Main).launch {
image = UIImage(data = data)
}
}
}
}
).resume()
}
It loads and caches images just fine but the only problem is the these images are being loaded in a lazy column that is under the top bar. Now while scrolling when rest of the lazy column goes under the top bar, just this image goes on top of the top bar. I have attached the ss of it.SeikoDes
09/08/2023, 6:05 AM