Exemple #1
0
        private protected override void OnLoaded()
        {
            base.OnLoaded();

            // TODO: Find a proper way to decide whether a CommandBar exists on canvas (within Page), or is mapped to the UINavigationController's NavigationBar.

            CommandBar?commandBar = null;

            _commandBar?.TryGetTarget(out commandBar);

            if (_commandBar == null)
            {
                commandBar  = TemplatedParent as CommandBar;
                _commandBar = new WeakReference <CommandBar?>(commandBar);

                _navigationBar = commandBar?.GetRenderer(RendererFactory).Native;
            }
            else
            {
                _navigationBar = commandBar?.ResetRenderer(RendererFactory).Native;
            }

            if (_navigationBar == null)
            {
                throw new InvalidOperationException("No NavigationBar from renderer");
            }

            _navigationBar.SetNeedsLayout();

            var navigationBarSuperview = _navigationBar?.Superview;

            // Allows the UINavigationController's NavigationBar instance to be moved to the Page. This feature
            // is used in the context of the sample application to test NavigationBars outside of a NativeFramePresenter for
            // UI Testing. In general cases, this should not happen as the bar may be moved back to to this presenter while
            // another page is already visible, making this bar overlay on top of another.
            if (FeatureConfiguration.CommandBar.AllowNativePresenterContent && (navigationBarSuperview == null || navigationBarSuperview is NativeCommandBarPresenter))
            {
                Content = _navigationBar;
            }

            var statusBar = StatusBar.GetForCurrentView();

            statusBar.Showing += OnStatusBarChanged;
            statusBar.Hiding  += OnStatusBarChanged;

            _statusBarSubscription.Disposable = Disposable.Create(() =>
            {
                statusBar.Showing -= OnStatusBarChanged;
                statusBar.Hiding  -= OnStatusBarChanged;
            });

            // iOS doesn't automatically update the navigation bar position when the status bar visibility changes.
            void OnStatusBarChanged(StatusBar sender, object args)
            {
                _navigationBar !.SetNeedsLayout();
                _navigationBar !.Superview.SetNeedsLayout();
            }
        }
        public override void SetNeedsLayout()
        {
            base.SetNeedsLayout();

            _requiresMeasure = true;

            if (Superview != null)
            {
                Superview.SetNeedsLayout();
            }
        }
        public void RemoveFromSuperview()
        {
            if (Superview == null)
            {
                throw new InvalidOperationException("The View does not have a Superview");
            }


            Superview._subviews.Remove(this);
            Superview.SetNeedsLayout();
        }
        private protected override void OnLoaded()
        {
            base.OnLoaded();

            // TODO: Find a proper way to decide whether a CommandBar exists on canvas (within Page), or is mapped to the UINavigationController's NavigationBar.

            var commandBar = _commandBar?.Target;

            if (commandBar == null)
            {
                commandBar  = TemplatedParent as CommandBar;
                _commandBar = new WeakReference <CommandBar?>(commandBar);

                _navigationBar = commandBar?.GetRenderer(RendererFactory).Native;
            }
            else
            {
                _navigationBar = commandBar?.ResetRenderer(RendererFactory).Native;
            }

            if (_navigationBar == null)
            {
                throw new InvalidOperationException("No NavigationBar from renderer");
            }

            _navigationBar.SetNeedsLayout();

            var navigationBarSuperview = _navigationBar?.Superview;

            if (navigationBarSuperview == null || navigationBarSuperview is NativeCommandBarPresenter)             // Prevents the UINavigationController's NavigationBar instance from being moved to the Page
            {
                Content = _navigationBar;
            }

            var statusBar = StatusBar.GetForCurrentView();

            statusBar.Showing += OnStatusBarChanged;
            statusBar.Hiding  += OnStatusBarChanged;

            _statusBarSubscription.Disposable = Disposable.Create(() =>
            {
                statusBar.Showing -= OnStatusBarChanged;
                statusBar.Hiding  -= OnStatusBarChanged;
            });

            // iOS doesn't automatically update the navigation bar position when the status bar visibility changes.
            void OnStatusBarChanged(StatusBar sender, object args)
            {
                _navigationBar !.SetNeedsLayout();
                _navigationBar !.Superview.SetNeedsLayout();
            }
        }
Exemple #5
0
        private void OnContentChanged(UIElement oldValue, UIElement newValue)
        {
            if (oldValue != null)
            {
                oldValue.RemoveFromSuperview();
            }

            if (newValue != null)
            {
                AddSubview(newValue);
            }

            Superview?.SetNeedsLayout();
        }
Exemple #6
0
        public override void InvalidateIntrinsicContentSize()
        {
            base.InvalidateIntrinsicContentSize();

            if (Frame.Width == 0 && Frame.Height == 0)
            {
                // The Label hasn't actually been laid out on screen yet; no reason to request a layout
                return;
            }

            if (!Frame.Size.IsCloseTo(AddInsets(IntrinsicContentSize), (nfloat)0.001))
            {
                // The text or its attributes have changed enough that the size no longer matches the set Frame. It's possible
                // that the Label needs to be laid out again at a different size, so we request that the parent do so.
                Superview?.SetNeedsLayout();
            }
        }
Exemple #7
0
 public override void WillRemoveSubview(UIView uiview)
 {
     base.WillRemoveSubview(uiview);
     Superview?.SetNeedsLayout();
 }
Exemple #8
0
 public override void SubviewAdded(UIView uiview)
 {
     base.SubviewAdded(uiview);
     Superview?.SetNeedsLayout();
 }
Exemple #9
0
 public override void SetNeedsLayout()
 {
     base.SetNeedsLayout();
     Superview?.SetNeedsLayout();
 }
Exemple #10
0
 public override void SetTitle(string title, UIControlState forState)
 {
     base.SetTitle(title, forState);
     Superview.SetNeedsLayout();
     Layer.CornerRadius = Layer.Frame.Height / 2;
 }