Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public partial class HybridWebViewHandler : IHybridWebViewHandler

public static IPropertyMapper<IHybridWebView, IHybridWebViewHandler> Mapper = new PropertyMapper<IHybridWebView, IHybridWebViewHandler>(ViewHandler.ViewMapper)
{
#if WINDOWS
#if WINDOWS || IOS || MACCATALYST
[nameof(IView.FlowDirection)] = MapFlowDirection,
#endif
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ internal static void EvaluateJavaScript(IHybridWebViewHandler handler, IHybridWe
handler.PlatformView.EvaluateJavaScript(request);
}

internal static void MapFlowDirection(IHybridWebViewHandler handler, IHybridWebView hybridWebView)
{
var scrollView = handler.PlatformView?.ScrollView;
if (scrollView == null)
return;

scrollView.UpdateFlowDirectionForScrollView(hybridWebView);
}

public static void MapSendRawMessage(IHybridWebViewHandler handler, IHybridWebView hybridWebView, object? arg)
{
if (arg is not HybridWebViewRawMessage hybridWebViewRawMessage || handler.PlatformView is not IHybridPlatformWebView hybridPlatformWebView)
Expand Down
3 changes: 2 additions & 1 deletion src/Core/src/Handlers/WebView/WebViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public partial class WebViewHandler : IWebViewHandler
[nameof(WebViewClient)] = MapWebViewClient,
[nameof(WebChromeClient)] = MapWebChromeClient,
[nameof(WebView.Settings)] = MapWebViewSettings
#elif __IOS__
#elif __IOS__ || MACCATALYST
[nameof(IWebView.FlowDirection)] = MapFlowDirection,
[nameof(WKUIDelegate)] = MapWKUIDelegate,
[nameof(IWebView.Background)] = MapBackground,
#endif
Expand Down
9 changes: 9 additions & 0 deletions src/Core/src/Handlers/WebView/WebViewHandler.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ public static void MapGoForward(IWebViewHandler handler, IWebView webView, objec
handler.PlatformView?.UpdateGoForward(webView);
}

internal static void MapFlowDirection(IWebViewHandler handler, IWebView webView)
{
var scrollView = handler.PlatformView?.ScrollView;
if (scrollView == null)
return;

scrollView.UpdateFlowDirectionForScrollView(webView);
}

public static async void MapReload(IWebViewHandler handler, IWebView webView, object? arg)
{
var platformHandler = handler as WebViewHandler;
Expand Down
23 changes: 23 additions & 0 deletions src/Core/src/Platform/iOS/WebViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ internal static void UpdateCanGoBackForward(this WKWebView platformWebView, IWeb
webView.CanGoForward = platformWebView.CanGoForward;
}

internal static void UpdateFlowDirectionForScrollView(this UIKit.UIScrollView scrollView, IView view)
{
scrollView.UpdateFlowDirection(view);

// On macOS, we need to refresh the scroll indicators when flow direction changes
// But only for runtime changes, not during initial load
// The view.IsLoadedOnPlatform() check ensures that this code is executed
// only after the view has been loaded on the platform. During the initial load,
// the scroll indicators do not need to be refreshed as they are set up correctly
// by default. This avoids unnecessary operations during the initial load phase.
if (OperatingSystem.IsMacCatalyst() && view.IsLoadedOnPlatform())
{
bool showsVertical = scrollView.ShowsVerticalScrollIndicator;
bool showsHorizontal = scrollView.ShowsHorizontalScrollIndicator;

scrollView.ShowsVerticalScrollIndicator = false;
scrollView.ShowsHorizontalScrollIndicator = false;

scrollView.ShowsVerticalScrollIndicator = showsVertical;
scrollView.ShowsHorizontalScrollIndicator = showsHorizontal;
}
}

public static void Eval(this WKWebView platformWebView, IWebView webView, string script)
{
platformWebView.EvaluateJavaScriptAsync(script);
Expand Down
Loading