mirror of
https://github.com/status-im/react-native-webview.git
synced 2026-08-31 19:51:10 +00:00
* Add isTopFrame to shouldStartLoadForRequest on iOS onLoadingStart is not raised for inner frames, but onShouldStartLoadWithRequest still is. This keeps that behavior but adds isTopFrame to onShouldStartLoadWithRequest so that apps can perform their own filtering if desired. * Update docs Co-authored-by: Jamon Holmgren <jamonholmgren@gmail.com>
30 lines
935 B
Kotlin
30 lines
935 B
Kotlin
package com.reactnativecommunity.webview.events
|
|
|
|
import com.facebook.react.bridge.WritableMap
|
|
import com.facebook.react.uimanager.events.Event
|
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
|
|
/**
|
|
* Event emitted when shouldOverrideUrlLoading is called
|
|
*/
|
|
class TopShouldStartLoadWithRequestEvent(viewId: Int, private val mData: WritableMap) : Event<TopShouldStartLoadWithRequestEvent>(viewId) {
|
|
companion object {
|
|
const val EVENT_NAME = "topShouldStartLoadWithRequest"
|
|
}
|
|
|
|
init {
|
|
mData.putString("navigationType", "other")
|
|
// Android does not raise shouldOverrideUrlLoading for inner frames
|
|
mData.putBoolean("isTopFrame", true)
|
|
}
|
|
|
|
override fun getEventName(): String = EVENT_NAME
|
|
|
|
override fun canCoalesce(): Boolean = false
|
|
|
|
override fun getCoalescingKey(): Short = 0
|
|
|
|
override fun dispatch(rctEventEmitter: RCTEventEmitter) =
|
|
rctEventEmitter.receiveEvent(viewTag, EVENT_NAME, mData)
|
|
}
|