public static void MapRequestScrollTo(IScrollViewHandler handler, IScrollView scrollView, object?args) { if (args is ScrollToRequest request) { handler.PlatformView.ChangeView(request.HoriztonalOffset, request.VerticalOffset, null, request.Instant); } }
public static void MapContent(IScrollViewHandler handler, IScrollView scrollView) { if (handler.PlatformView == null || handler.MauiContext == null) { return; } UpdateContentPanel(scrollView, handler); }
public static void MapContent(IScrollViewHandler handler, IScrollView scrollView) { if (handler.PlatformView == null || handler.MauiContext == null) { return; } handler.PlatformView.UpdateContent(scrollView.PresentedContent, handler.MauiContext); }
public static void MapRequestScrollTo(IScrollViewHandler handler, IScrollView scrollView, object?args) { if (args is ScrollToRequest request) { handler.PlatformView.SetContentOffset(new CoreGraphics.CGPoint(request.HoriztonalOffset, request.VerticalOffset), !request.Instant); if (request.Instant) { scrollView.ScrollFinished(); } } }
public static void MapContent(IScrollViewHandler handler, IScrollView scrollView) { if (handler.MauiContext == null || scrollView.PresentedContent == null || handler is not ScrollViewHandler sHandler || sHandler.Canvas == null) { return; } sHandler.Canvas.UnPackAll(); sHandler.Canvas.PackEnd(scrollView.PresentedContent.ToPlatform(handler.MauiContext)); if (scrollView.PresentedContent.Handler is IPlatformViewHandler thandler) { thandler?.SetParent(sHandler); } sHandler.UpdateContentSize(); }
public static void MapContent(IScrollViewHandler handler, IScrollView scrollView) { if (handler.PlatformView == null || handler.MauiContext == null) { return; } if (NeedsInsetView(scrollView)) { UpdateInsetView(scrollView, handler); } else { handler.PlatformView.UpdateContent(scrollView.PresentedContent, handler.MauiContext); } }
static void InsertInsetView(IScrollViewHandler handler, IScrollView scrollView, View nativeContent) { if (scrollView.PresentedContent == null || handler.MauiContext?.Context == null) { return; } var paddingShim = new ContentViewGroup(handler.MauiContext.Context) { CrossPlatformMeasure = IncludeScrollViewInsets(scrollView.CrossPlatformMeasure, scrollView), Tag = InsetPanelTag }; handler.PlatformView.RemoveAllViews(); paddingShim.AddView(nativeContent); handler.PlatformView.SetContent(paddingShim); }
public static void MapRequestScrollTo(IScrollViewHandler handler, IScrollView scrollView, object?args) { if (args is not ScrollToRequest request) { return; } var context = handler.PlatformView.Context; if (context == null) { return; } var horizontalOffsetDevice = (int)context.ToPixels(request.HoriztonalOffset); var verticalOffsetDevice = (int)context.ToPixels(request.VerticalOffset); handler.PlatformView.ScrollTo(horizontalOffsetDevice, verticalOffsetDevice, request.Instant, () => handler.VirtualView.ScrollFinished()); }
static void UpdateInsetView(IScrollView scrollView, IScrollViewHandler handler) { if (scrollView.PresentedContent == null || handler.MauiContext == null) { return; } var nativeContent = scrollView.PresentedContent.ToPlatform(handler.MauiContext); if (FindInsetPanel(handler) is ContentViewGroup currentPaddingLayer) { if (currentPaddingLayer.ChildCount == 0 || currentPaddingLayer.GetChildAt(0) != nativeContent) { currentPaddingLayer.RemoveAllViews(); currentPaddingLayer.AddView(nativeContent); } } else { InsertInsetView(handler, scrollView, nativeContent); } }
public static void MapRequestScrollTo(IScrollViewHandler handler, IScrollView scrollView, object?args) { if (args is ScrollToRequest request) { var x = request.HoriztonalOffset; var y = request.VerticalOffset; var region = new ElmSharp.Rect { X = x.ToScaledPixel(), Y = y.ToScaledPixel(), Width = handler.PlatformView !.Geometry.Width, Height = handler.PlatformView !.Geometry.Height }; handler.PlatformView.ScrollTo(region, !request.Instant); if (request.Instant) { scrollView.ScrollFinished(); } } }
static void UpdateContentPanel(IScrollView scrollView, IScrollViewHandler handler) { if (scrollView.PresentedContent == null || handler.MauiContext == null) { return; } var scrollViewer = handler.PlatformView; var nativeContent = scrollView.PresentedContent.ToPlatform(handler.MauiContext); if (GetContentPanel(scrollViewer) is ContentPanel currentPaddingLayer) { if (currentPaddingLayer.Children.Count == 0 || currentPaddingLayer.Children[0] != nativeContent) { currentPaddingLayer.Children.Clear(); currentPaddingLayer.Children.Add(nativeContent); } } else { InsertContentPanel(scrollViewer, scrollView, nativeContent); } }
static void UpdateContentView(IScrollView scrollView, IScrollViewHandler handler) { if (scrollView.PresentedContent == null || handler.MauiContext == null) { return; } var platformScrollView = handler.PlatformView; var nativeContent = scrollView.PresentedContent.ToPlatform(handler.MauiContext); if (GetContentView(platformScrollView) is ContentView currentContentContainer) { if (currentContentContainer.Subviews.Length == 0 || currentContentContainer.Subviews[0] != nativeContent) { currentContentContainer.ClearSubviews(); currentContentContainer.AddSubview(nativeContent); currentContentContainer.View = scrollView.PresentedContent; } } else { InsertContentView(platformScrollView, scrollView, nativeContent); } }
public static void MapIsEnabled(IScrollViewHandler handler, IScrollView scrollView) { handler.PlatformView.UpdateIsEnabled(scrollView); }
public static void MapVerticalScrollBarVisibility(IScrollViewHandler handler, IScrollView scrollView) { handler.PlatformView.VerticalScrollBarVisibility = scrollView.VerticalScrollBarVisibility.ToWindowsScrollBarVisibility(); }
public static void MapOrientation(IScrollViewHandler handler, IScrollView scrollView) { handler.PlatformView?.UpdateScrollBarVisibility(scrollView.Orientation, scrollView.HorizontalScrollBarVisibility); }
public static void MapVerticalScrollBarVisibility(IScrollViewHandler handler, IScrollView scrollView) { handler.PlatformView.SetVerticalScrollBarVisibility(scrollView.HorizontalScrollBarVisibility); }
static ContentViewGroup?FindInsetPanel(IScrollViewHandler handler) { return(handler.PlatformView.FindViewWithTag(InsetPanelTag) as ContentViewGroup); }
public static void MapOrientation(IScrollViewHandler handler, IScrollView scrollView) { handler.PlatformView.SetOrientation(scrollView.Orientation); }
public static void MapOrientation(IScrollViewHandler handler, IScrollView scrollView) { // Nothing to do here for now, but we might need to make adjustments for FlowDirection when the orientation is set to Horizontal }
public static void MapVerticalScrollBarVisibility(IScrollViewHandler handler, IScrollView scrollView) { handler.PlatformView?.UpdateVerticalScrollBarVisibility(scrollView.VerticalScrollBarVisibility); }
public static void MapRequestScrollTo(IScrollViewHandler handler, IScrollView scrollView, object?args) { }
// We don't actually have this mapped because we don't need it, but we can't remove it because it's public public static void MapContentSize(IScrollViewHandler handler, IScrollView scrollView) { handler.PlatformView.UpdateContentSize(scrollView.ContentSize); }