Michael Bichlmeier
07/13/2022, 7:22 AMMichael Bichlmeier
07/13/2022, 7:35 AMclass WebViewStore(){
private val map = mutableMapOf<String, WebView>()
fun getReusableWebView(key: String, create: ((context: Context) -> WebView)) {
// if already created return WebView from map
// otherwise call create and store WebView in Map
}
}
The composable I am using in my lists to display web content:
@Composable
fun WebViewElement(key: String, modifier: Modifier = Modifier) {
val webViewStore = remember { getKoin().get<WebViewStore>() } // get via DI
val webView = webViewStore.getReusableWebView(key) { context ->
createMyCustomWebViewImpl(context) // returns a custom implementation of a WebView
}
AndroidView(
factory = { webView },
modifier = modifier
)
}
If you need more information, just let me know ✌️