commonMain.tech.skot.core.components.SKWebViewVC.kt Maven / Gradle / Ivy
package tech.skot.core.components
import tech.skot.core.SKUri
@SKLayoutIsSimpleView
interface SKWebViewVC : SKComponentVC {
val config: Config
var openUrl: OpenUrl?
var goBack: BackRequest?
fun requestGoForward()
fun requestReload()
data class Config(
val userAgent: String?,
val javascriptEnabled: Boolean = true,
val domStorageEnabled: Boolean = true,
val shouldOverrideUrlLoading: ((skUri: SKUri) -> Boolean)? = null,
val onRequest: ((skUri: SKUri) -> Unit)? = null
)
data class OpenUrl(
val url: String,
val onFinished: (() -> Unit)? = null,
val javascriptOnFinished: String? = null,
val onError: (() -> Unit)? = null,
val post: Map? = null
)
abstract class RedirectParam {
abstract fun matches(url: String): Boolean
abstract val onRedirect: (path: String, params: Map) -> Boolean
class Start(
private val start: String,
override val onRedirect: (path: String, params: Map) -> Boolean
) : RedirectParam() {
override fun matches(url: String) = url.startsWith(start)
}
class Match(
private val regex: Regex,
override val onRedirect: (path: String, params: Map) -> Boolean
) : RedirectParam() {
override fun matches(url: String) = regex.matches(url)
}
}
data class BackRequest(val onCantBack: (() -> Unit)? = null)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy