Ejemplo n.º 1
0
        private void InsertViewsAtStart(_View owner, _View[] subviews)
        {
#if __IOS__
            for (int i = 0; i < subviews.Length; i++)
            {
                var subview = subviews[i];
                owner.InsertSubview(subview, i);
            }
#else
            for (int i = 0; i < subviews.Length; i++)
            {
                var subview = subviews[i];
                if (i == 0)
                {
                    // First view goes below everything
                    owner.AddSubview(subview, NSWindowOrderingMode.Below, null);
                }
                else
                {
                    // Other views go above previous
                    owner.AddSubview(subview, NSWindowOrderingMode.Above, subviews[i - 1]);
                }
            }
#endif
        }
Ejemplo n.º 2
0
        public void Insert(int index, IView child)
        {
            _ = NativeView ?? throw new InvalidOperationException($"{nameof(NativeView)} should have been set by base class.");
            _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");
            _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");

            NativeView.InsertSubview(child.ToNative(MauiContext), index);
        }
Ejemplo n.º 3
0
        public void Insert(int index, IView child)
        {
            _ = PlatformView ?? throw new InvalidOperationException($"{nameof(PlatformView)} should have been set by base class.");
            _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");
            _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");

            var targetIndex = VirtualView.GetLayoutHandlerIndex(child);

            PlatformView.InsertSubview(child.ToPlatform(MauiContext), targetIndex);
        }
Ejemplo n.º 4
0
        public void Add(IView child)
        {
            _ = NativeView ?? throw new InvalidOperationException($"{nameof(NativeView)} should have been set by base class.");
            _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");
            _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");

            var targetIndex = VirtualView.GetLayoutHandlerIndex(child);

            NativeView.InsertSubview(child.ToNative(MauiContext, true), targetIndex);
        }
Ejemplo n.º 5
0
        public void Update(int index, IView child)
        {
            _ = NativeView ?? throw new InvalidOperationException($"{nameof(NativeView)} should have been set by base class.");
            _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");
            _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");

            var existing = NativeView.Subviews[index];

            existing.RemoveFromSuperview();
            NativeView.InsertSubview(child.ToNative(MauiContext), index);
            NativeView.SetNeedsLayout();
        }
Ejemplo n.º 6
0
        public void Update(int index, IView child)
        {
            _ = PlatformView ?? throw new InvalidOperationException($"{nameof(PlatformView)} should have been set by base class.");
            _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");
            _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");

            var existing = PlatformView.Subviews[index];

            existing.RemoveFromSuperview();
            var targetIndex = VirtualView.GetLayoutHandlerIndex(child);

            PlatformView.InsertSubview(child.ToPlatform(MauiContext), targetIndex);
            PlatformView.SetNeedsLayout();
        }
Ejemplo n.º 7
0
        void EnsureZIndexOrder(IView child)
        {
            if (PlatformView.Subviews.Length == 0)
            {
                return;
            }

            PlatformView nativeChildView = child.ToPlatform(MauiContext !);
            var          currentIndex    = PlatformView.Subviews.IndexOf(nativeChildView);

            if (currentIndex == -1)
            {
                return;
            }

            var targetIndex = VirtualView.GetLayoutHandlerIndex(child);

            if (currentIndex != targetIndex)
            {
                PlatformView.Subviews.RemoveAt(currentIndex);
                PlatformView.InsertSubview(nativeChildView, targetIndex);
            }
        }