All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.tech.skot.core.components.SKWebViewVC.kt Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
package tech.skot.core.components

@SKLayoutIsSimpleView
interface SKWebViewVC: SKComponentVC {
    val config:Config
    var openUrl:OpenUrl?
    var goBack:BackRequest?
    fun requestGoForward()
    fun requestReload()

    data class Config(val userAgent:String?, val redirect:List = emptyList())
    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