Skip to content

Commit f3a8441

Browse files
committed
updated deprecated properties and android bug
1 parent 0e27c2f commit f3a8441

File tree

1 file changed

+45
-36
lines changed

1 file changed

+45
-36
lines changed

modules/ensemble/lib/widget/webview/native/webviewstate.dart

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -146,41 +146,39 @@ class WebViewState extends EWidgetState<EnsembleWebView> with CookieMethods {
146146
headers: widget.controller.headers,
147147
)
148148
: null,
149-
initialOptions: InAppWebViewGroupOptions(
150-
crossPlatform: InAppWebViewOptions(
151-
useShouldOverrideUrlLoading: true,
152-
mediaPlaybackRequiresUserGesture: false,
153-
javaScriptEnabled: true,
154-
useOnLoadResource: true,
155-
clearCache: true,
156-
transparentBackground: true,
157-
supportZoom: true,
158-
preferredContentMode: UserPreferredContentMode.MOBILE,
159-
),
160-
android: AndroidInAppWebViewOptions(
161-
useHybridComposition: true,
162-
hardwareAcceleration: true,
163-
mixedContentMode:
164-
AndroidMixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW,
165-
safeBrowsingEnabled: false,
166-
domStorageEnabled: true,
167-
databaseEnabled: true,
168-
supportMultipleWindows: true,
169-
builtInZoomControls: true,
170-
displayZoomControls: false,
171-
allowFileAccess: true,
172-
useWideViewPort: true,
173-
allowContentAccess: true,
174-
loadWithOverviewMode: true,
175-
),
176-
ios: IOSInAppWebViewOptions(
177-
allowsInlineMediaPlayback: true,
178-
allowsBackForwardNavigationGestures: true,
179-
enableViewportScale: true,
180-
suppressesIncrementalRendering: false,
181-
allowsPictureInPictureMediaPlayback: true,
182-
isFraudulentWebsiteWarningEnabled: false,
183-
),
149+
initialSettings: InAppWebViewSettings(
150+
// Cross Platform Settings
151+
useShouldOverrideUrlLoading: true,
152+
mediaPlaybackRequiresUserGesture: false,
153+
javaScriptEnabled: true,
154+
useOnLoadResource: true,
155+
transparentBackground: true,
156+
supportZoom: true,
157+
clearCache: true,
158+
preferredContentMode: UserPreferredContentMode.MOBILE,
159+
160+
// Android Specific Settings
161+
useHybridComposition: true,
162+
hardwareAcceleration: true,
163+
mixedContentMode: MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW,
164+
safeBrowsingEnabled: false,
165+
domStorageEnabled: true,
166+
databaseEnabled: true,
167+
supportMultipleWindows: true,
168+
builtInZoomControls: true,
169+
displayZoomControls: false,
170+
allowFileAccess: true,
171+
useWideViewPort: true,
172+
allowContentAccess: true,
173+
loadWithOverviewMode: true,
174+
175+
// iOS Specific Settings
176+
allowsInlineMediaPlayback: true,
177+
allowsBackForwardNavigationGestures: true,
178+
enableViewportScale: true,
179+
suppressesIncrementalRendering: false,
180+
allowsPictureInPictureMediaPlayback: true,
181+
isFraudulentWebsiteWarningEnabled: false,
184182
),
185183
gestureRecognizers: gestureRecognizers,
186184
onWebViewCreated: (controller) async {
@@ -234,9 +232,20 @@ class WebViewState extends EWidgetState<EnsembleWebView> with CookieMethods {
234232
setState(
235233
() => widget.controller.error = "Error loading html content");
236234
},
235+
onCreateWindow: (controller, createWindowAction) async {
236+
print('onCreateWindow: ${createWindowAction.request.url}');
237+
// Get the URL from the creation request
238+
final url = createWindowAction.request.url?.toString();
239+
if (url != null) {
240+
// Load the URL in the current WebView instead of creating a new window
241+
await controller.loadUrl(urlRequest: URLRequest(url: WebUri(url)));
242+
}
243+
return true;
244+
},
237245
shouldOverrideUrlLoading: (controller, navigationAction) async {
238246
final url = navigationAction.request.url?.toString() ?? '';
239-
247+
print('shouldOverrideUrlLoading: $url');
248+
// Rest of your existing navigation handling
240249
WebViewNavigationEvent event = WebViewNavigationEvent(widget, url);
241250
if (widget.controller.onNavigationRequest != null) {
242251
ScreenController().executeAction(

0 commit comments

Comments
 (0)