Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions harmony/rn_webview/src/main/ets/RNCWebView.ets
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface WebViewProps extends ViewBaseProps {
shouldStartLoadWithRequestEnabled: boolean
webviewDebuggingEnabled: boolean
// nestedScrollEnabled: boolean
scrollEnabled: boolean
}

export class RNCWebViewBridge {
Expand Down Expand Up @@ -111,6 +112,7 @@ export struct RNCWebView {
controllerAttached: boolean = false;
// nestedScrollFlag: boolean = false;
renderMode: RenderMode = RenderMode.SYNC_RENDER;
scrollEnabled = true;

aboutToAppear() {
this.descriptor = this.ctx.descriptorRegistry.getDescriptor<WebViewViewDescriptor>(this.tag)
Expand Down Expand Up @@ -148,6 +150,7 @@ export struct RNCWebView {
}
)
webview.WebviewController.setWebDebuggingAccess(this.descriptor.props.webviewDebuggingEnabled)
this.scrollEnabled = this.descriptor.props.scrollEnabled;
this.javaScriptEnable = this.descriptor.props.javaScriptEnabled;
this.cacheMode =
this.descriptor.props.cacheEnabled ? this.transCacheMode(this.descriptor.props.cacheMode) : CacheMode.Online;
Expand Down Expand Up @@ -288,6 +291,20 @@ export struct RNCWebView {
});
}

onLoadingStart() {
this.ctx.rnInstance.emitComponentEvent(this.descriptor.tag, WEB_VIEW, {
type: "onLoadingStart",
url: this.controller.getUrl(),
loading: this.progress != 100,
title: this.controller.getTitle(),
canGoBack: this.controller.accessBackward(),
canGoForward: this.controller.accessForward(),
lockIdentifier: 0,
navigationType: "other",
mainDocumentURL: ""
})
}

onLoadingFinish() {
this.ctx.rnInstance.emitComponentEvent(this.descriptor.tag, WEB_VIEW, {
type: "onLoadingFinish",
Expand Down Expand Up @@ -396,6 +413,10 @@ export struct RNCWebView {
Logger.debug(TAG, "[RNOH] event progress: " + event.newProgress)
}
})
.onPageBegin(() => {
this.onLoadingStart()
this.controller.setScrollable(this.scrollEnabled)
})
.onPageEnd(() => {
Logger.debug(TAG, "[RNOH] onPageEnd")
this.runInjectedJavaScript()
Expand All @@ -405,11 +426,6 @@ export struct RNCWebView {
if (event) {
let errorInfo: string = event.error.getErrorInfo();
let errorCode: number = event.error.getErrorCode();
if (errorInfo == "ERR_INTERNET_DISCONNECTED" || errorInfo == "ERR_CACHE_MISS" ||
!event.request.isMainFrame()) {
Logger.debug(TAG, "[RNOH] ERR_INTERNET_DISCONNECTED:OR ERR_CACHE_MISS")
return
}
Logger.debug(TAG, "[RNOH] errorInfo:" + errorInfo)
Logger.debug(TAG, "[RNOH] errorCode:" + errorCode)
this.onLoadingError(errorCode, errorInfo)
Expand Down