package com.adealink.weparty.webview.callback

import android.app.Activity
import android.graphics.Bitmap
import android.net.http.SslError
import android.webkit.SslErrorHandler
import androidx.lifecycle.LifecycleOwner
import com.adealink.weparty.webview.constant.NavigationBarMode
import com.adealink.weparty.webview.jsbridge.JSBridge
import com.adealink.weparty.webview.jsbridge.data.NativeMessage

interface IWebViewCallback {

    val lifeCycleOwner: LifecycleOwner

    fun closeWebView()

    fun getActivity(): Activity?

    fun setTitle(title: String?)

    fun beforeLoadUrl(url: String)

    fun onPageStarted(url: String?, favicon: Bitmap?)

    fun onPageFinished(url: String?)

    fun onProgressChanged(progress: Int)

    fun onReceivedError(url: String?, errorCode: Int, description: String?)

    fun onReceivedSslError(handler: SslErrorHandler?, error: SslError?)

    /**
     * 宿主是否激活状态
     */
    fun isHostActive(): Boolean

    fun setImmersionMode()

    fun setNavigationBarMode(mode: NavigationBarMode)

    fun hideNavigationBar()

    fun <T> notifyNativeMessage(message: NativeMessage<T>)

    fun getJsBridge(name: String): JSBridge?

    fun url(): String?

    // 需要桥接调用
    fun onPageLoadSuccess()
}