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 }
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); }
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); }
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); }
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(); }
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(); }
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); } }