looks like mutableStateOf remember rizz works reactively
This commit is contained in:
parent
75a637caf6
commit
43cf9d416f
1 changed files with 23 additions and 7 deletions
|
|
@ -11,14 +11,26 @@ import android.webkit.WebViewClient
|
|||
import android.widget.LinearLayout
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.IntrinsicSize
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import com.mykola2312.outagefetch.ui.theme.OutageFetchTheme
|
||||
|
||||
|
|
@ -46,17 +58,12 @@ fun ExtractWebView() {
|
|||
|
||||
AndroidView(factory = {
|
||||
WebView(it).apply {
|
||||
this.layoutParams = ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
|
||||
this.webViewClient = ExtractorClient()
|
||||
}
|
||||
}, update = {
|
||||
it.settings.javaScriptEnabled = true
|
||||
it.loadUrl(url);
|
||||
})
|
||||
}) // , modifier = Modifier.size(300.dp)
|
||||
}
|
||||
|
||||
class ExtractorClient : WebViewClient() {
|
||||
|
|
@ -82,7 +89,16 @@ class ExtractorClient : WebViewClient() {
|
|||
|
||||
@Composable
|
||||
fun FetchScreen() {
|
||||
ExtractWebView()
|
||||
var doFetch by remember { mutableStateOf(false) }
|
||||
Column() {
|
||||
Button(onClick = { doFetch = true }) {
|
||||
Text("WebView Fetch")
|
||||
}
|
||||
|
||||
if (doFetch) {
|
||||
ExtractWebView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue