Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        public static void MapContent(IScrollViewHandler handler, IScrollView scrollView)
        {
            if (handler.PlatformView == null || handler.MauiContext == null)
            {
                return;
            }

            UpdateContentPanel(scrollView, handler);
        }
Ejemplo n.º 3
0
        public static void MapContent(IScrollViewHandler handler, IScrollView scrollView)
        {
            if (handler.PlatformView == null || handler.MauiContext == null)
            {
                return;
            }

            handler.PlatformView.UpdateContent(scrollView.PresentedContent, handler.MauiContext);
        }
Ejemplo n.º 4
0
        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();
                }
            }
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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());
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
        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();
                }
            }
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
 public static void MapIsEnabled(IScrollViewHandler handler, IScrollView scrollView)
 {
     handler.PlatformView.UpdateIsEnabled(scrollView);
 }
Ejemplo n.º 14
0
 public static void MapVerticalScrollBarVisibility(IScrollViewHandler handler, IScrollView scrollView)
 {
     handler.PlatformView.VerticalScrollBarVisibility = scrollView.VerticalScrollBarVisibility.ToWindowsScrollBarVisibility();
 }
Ejemplo n.º 15
0
 public static void MapOrientation(IScrollViewHandler handler, IScrollView scrollView)
 {
     handler.PlatformView?.UpdateScrollBarVisibility(scrollView.Orientation, scrollView.HorizontalScrollBarVisibility);
 }
Ejemplo n.º 16
0
 public static void MapVerticalScrollBarVisibility(IScrollViewHandler handler, IScrollView scrollView)
 {
     handler.PlatformView.SetVerticalScrollBarVisibility(scrollView.HorizontalScrollBarVisibility);
 }
Ejemplo n.º 17
0
 static ContentViewGroup?FindInsetPanel(IScrollViewHandler handler)
 {
     return(handler.PlatformView.FindViewWithTag(InsetPanelTag) as ContentViewGroup);
 }
Ejemplo n.º 18
0
 public static void MapOrientation(IScrollViewHandler handler, IScrollView scrollView)
 {
     handler.PlatformView.SetOrientation(scrollView.Orientation);
 }
Ejemplo n.º 19
0
 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
 }
Ejemplo n.º 20
0
 public static void MapVerticalScrollBarVisibility(IScrollViewHandler handler, IScrollView scrollView)
 {
     handler.PlatformView?.UpdateVerticalScrollBarVisibility(scrollView.VerticalScrollBarVisibility);
 }
Ejemplo n.º 21
0
 public static void MapRequestScrollTo(IScrollViewHandler handler, IScrollView scrollView, object?args)
 {
 }
Ejemplo n.º 22
0
 // 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);
 }