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.");

            NativeView.AddView(child.ToNative(MauiContext), 0);
        }
Esempio n. 2
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.");

            NativeView.RemoveViewAt(index);
            NativeView.AddView(child.ToNative(MauiContext), index);
        }
Esempio n. 3
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.");

            var targetIndex = VirtualView.GetLayoutHandlerIndex(child);

            NativeView.AddView(child.ToNative(MauiContext), targetIndex);
        }
Esempio n. 4
0
        void UpdateContent()
        {
            _ = NativeView ?? throw new InvalidOperationException($"{nameof(NativeView)} should have been set by base class.");
            _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");
            _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} should have been set by base class.");

            NativeView.RemoveAllViews();

            if (VirtualView.PresentedContent is IView view)
            {
                NativeView.AddView(view.ToNative(MauiContext));
            }
        }
Esempio n. 5
0
        public override void SetVirtualView(IView view)
        {
            base.SetVirtualView(view);

            _ = 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.CrossPlatformMeasure = VirtualView.Measure;
            NativeView.CrossPlatformArrange = VirtualView.Arrange;

            NativeView.AddView(VirtualView.Content.ToNative(MauiContext));
        }
Esempio n. 6
0
        public override void SetVirtualView(IView view)
        {
            base.SetVirtualView(view);

            _ = 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.CrossPlatformMeasure = VirtualView.Measure;
            NativeView.CrossPlatformArrange = VirtualView.Arrange;
            NativeView.RemoveAllViews();
            //var wrap = ViewGroup.LayoutParams.WrapContent;
            NativeView.AddView(VirtualView.Content.ToNative(MauiContext));             // , new ViewGroup.LayoutParams(wrap, wrap));
        }
Esempio n. 7
0
        public override void SetVirtualView(IView view)
        {
            base.SetVirtualView(view);

            _ = 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.CrossPlatformMeasure = VirtualView.CrossPlatformMeasure;
            NativeView.CrossPlatformArrange = VirtualView.CrossPlatformArrange;

            NativeView.RemoveAllViews();

            foreach (var child in VirtualView.OrderByZIndex())
            {
                NativeView.AddView(child.ToNative(MauiContext));
            }
        }
Esempio n. 8
0
        public override void SetVirtualView(IView view)
        {
            base.SetVirtualView(view);

            var newContent = VirtualView.Content?.ToNative(MauiContext);

            if (_content == null || newContent != _content)
            {
                if (_content != null)
                {
                    NativeView.RemoveView(_content);
                }

                _content = newContent;

                if (_content != null)
                {
                    NativeView.AddView(_content);
                }
            }
        }
Esempio n. 9
0
        void UpdateFlyout()
        {
            _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");
            _ = VirtualView.Flyout.ToNative(MauiContext);

            var newFlyoutView = VirtualView.Flyout.GetNative(true);

            if (_flyoutView == newFlyoutView)
            {
                return;
            }

            if (_flyoutView != null)
            {
                _flyoutView.RemoveFromParent();
            }

            _flyoutView = newFlyoutView;
            if (_flyoutView == null)
            {
                return;
            }

            _flyoutView.LayoutParameters =
                new DrawerLayout.LayoutParams(
                    DrawerLayout.LayoutParams.WrapContent,
                    DrawerLayout.LayoutParams.MatchParent,
                    (int)GravityFlags.Start);

            NativeView.AddView(_flyoutView);


            if (VirtualView.Flyout.Background == null && Context?.Theme != null)
            {
                var colors = Context.Theme.ObtainStyledAttributes(new[] { global::Android.Resource.Attribute.ColorBackground });
                _flyoutView.SetBackgroundColor(new global::Android.Graphics.Color(colors.GetColor(0, 0)));
            }
        }
Esempio n. 10
0
        void EnsureZIndexOrder(IView child)
        {
            if (NativeView.ChildCount == 0)
            {
                return;
            }

            AView nativeChildView = child.ToNative(MauiContext !);
            var   currentIndex    = IndexOf(NativeView, nativeChildView);

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

            var targetIndex = VirtualView.GetLayoutHandlerIndex(child);

            if (currentIndex != targetIndex)
            {
                NativeView.RemoveViewAt(currentIndex);
                NativeView.AddView(nativeChildView, targetIndex);
            }
        }