Example #1
0
        protected virtual void UpdateDrawerLockMode(FlyoutBehavior behavior)
        {
            switch (behavior)
            {
            case FlyoutBehavior.Disabled:
                CloseDrawers();
                Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, false);
                _currentLockMode = LockModeLockedClosed;
                SetDrawerLockMode(_currentLockMode);
                _content.SetPadding(0, _content.PaddingTop, _content.PaddingRight, _content.PaddingBottom);
                break;

            case FlyoutBehavior.Flyout:
                _currentLockMode = LockModeUnlocked;
                SetDrawerLockMode(_currentLockMode);
                _content.SetPadding(0, _content.PaddingTop, _content.PaddingRight, _content.PaddingBottom);
                break;

            case FlyoutBehavior.Locked:
                Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, true);
                _currentLockMode = LockModeLockedOpen;
                SetDrawerLockMode(_currentLockMode);
                _content.SetPadding(_flyoutWidth, _content.PaddingTop, _content.PaddingRight, _content.PaddingBottom);
                break;
            }

            unchecked
            {
                SetScrimColor(behavior == FlyoutBehavior.Locked ? Color.Transparent.ToAndroid() : (int)DefaultScrimColor);
            }
        }
Example #2
0
        protected virtual void UpdateDrawerLockMode(FlyoutBehavior behavior)
        {
            AddFlyoutContentToLayoutIfNeeded(behavior);

            switch (behavior)
            {
            case FlyoutBehavior.Disabled:
                CloseDrawers();
                Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, false);
                _currentLockMode = LockModeLockedClosed;
                SetDrawerLockMode(_currentLockMode);
                _content.SetPadding(0, _content.PaddingTop, _content.PaddingRight, _content.PaddingBottom);
                break;

            case FlyoutBehavior.Flyout:
                _currentLockMode = LockModeUnlocked;
                SetDrawerLockMode(_currentLockMode);
                _content.SetPadding(0, _content.PaddingTop, _content.PaddingRight, _content.PaddingBottom);
                break;

            case FlyoutBehavior.Locked:
                Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, true);
                _currentLockMode = LockModeLockedOpen;
                SetDrawerLockMode(_currentLockMode);

                _content.SetPadding((int)FlyoutWidth, _content.PaddingTop, _content.PaddingRight, _content.PaddingBottom);
                break;
            }

            UpdateScrim(_scrimBrush);
        }
Example #3
0
        void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
        {
            switch (behavior)
            {
            case FlyoutBehavior.Disabled:
                IsPaneToggleButtonVisible = false;
                IsPaneVisible             = false;
                PaneDisplayMode           = Microsoft.UI.Xaml.Controls.NavigationViewPaneDisplayMode.LeftMinimal;
                IsPaneOpen = false;
                break;

            case FlyoutBehavior.Flyout:
                IsPaneVisible             = true;
                IsPaneToggleButtonVisible = true;
                bool shouldOpen = Shell.FlyoutIsPresented;
                PaneDisplayMode = Microsoft.UI.Xaml.Controls.NavigationViewPaneDisplayMode.LeftMinimal;                         //This will trigger opening the flyout
                IsPaneOpen      = shouldOpen;
                break;

            case FlyoutBehavior.Locked:
                IsPaneVisible             = true;
                IsPaneToggleButtonVisible = false;
                PaneDisplayMode           = Microsoft.UI.Xaml.Controls.NavigationViewPaneDisplayMode.Left;
                break;
            }
        }
Example #4
0
        void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
        {
            bool closeAfterUpdate = (behavior == FlyoutBehavior.Flyout && _behavior == FlyoutBehavior.Locked);

            _behavior = behavior;
            UpdateDrawerLockMode(behavior);

            if (closeAfterUpdate)
            {
                CloseDrawer(_flyoutContent.AndroidView, false);
            }
        }
Example #5
0
 void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
 {
     _flyoutBehavior = behavior;
     if (behavior == FlyoutBehavior.Locked)
     {
         IsOpen = true;
     }
     else if (behavior == FlyoutBehavior.Disabled)
     {
         IsOpen = false;
     }
     LayoutSidebar(false);
 }
Example #6
0
        void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
        {
            if (_flyoutBehavior == behavior)
            {
                return;
            }
            _flyoutBehavior = behavior;

            if (Page != null)
            {
                UpdateLeftBarButtonItem();
            }
        }
Example #7
0
 public static DrawerBehavior ToPlatform(this FlyoutBehavior behavior)
 {
     if (behavior == FlyoutBehavior.Disabled)
     {
         return(DrawerBehavior.Disabled);
     }
     else if (behavior == FlyoutBehavior.Locked)
     {
         return(DrawerBehavior.Locked);
     }
     else
     {
         return(DrawerBehavior.Drawer);
     }
 }
Example #8
0
        void AddFlyoutContentToLayoutIfNeeded(FlyoutBehavior behavior)
        {
            if (behavior == FlyoutBehavior.Disabled)
            {
                return;
            }

            if (_flyoutContent == null && ChildCount > 0)
            {
                _flyoutContent = _shellContext.CreateShellFlyoutContentRenderer();

                UpdateFlyoutSize();

                AddView(_flyoutContent.AndroidView);
            }
        }
Example #9
0
        void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
        {
            AddFlyoutContentToLayoutIfNeeded(behavior);

            if (_flyoutContent?.AndroidView == null)
            {
                return;
            }

            bool closeAfterUpdate = (behavior == FlyoutBehavior.Flyout && _behavior == FlyoutBehavior.Locked);

            _behavior = behavior;
            UpdateDrawerLockMode(behavior);

            if (closeAfterUpdate)
            {
                CloseDrawer(_flyoutContent.AndroidView, false);
            }
        }
        void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
        {
            switch (behavior)
            {
            case FlyoutBehavior.Disabled:
                PreferredDisplayMode = UISplitViewControllerDisplayMode.PrimaryHidden;
                PresentsWithGesture  = false;
                break;

            case FlyoutBehavior.Flyout:
                PreferredDisplayMode = UISplitViewControllerDisplayMode.PrimaryHidden;
                PresentsWithGesture  = true;
                _isPresented         = false;
                _context.Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, false);
                break;

            case FlyoutBehavior.Locked:
                PreferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible;
                break;
            }

            _flyoutBehavior = behavior;
        }
 public async void OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
 {
     _flyoutBehavior = behavior;
     await UpdateToolbarItems().ConfigureAwait(false);
 }
Example #12
0
 void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
 {
     UpdateFlyoutBehavior();
 }
Example #13
0
 public void OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
 {
     _flyoutBehavior = behavior;
     UpdateToolbarItems().FireAndForget();
 }
Example #14
0
        public virtual void LayoutViews(CGRect bounds, nfloat openPercent, UIView flyout, UIView shell, FlyoutBehavior behavior)
        {
            if (behavior == FlyoutBehavior.Locked)
            {
                openPercent = 1;
            }

            nfloat flyoutHeight;
            nfloat flyoutWidth;

            if (Width != -1d)
            {
                flyoutWidth = (nfloat)Width;
            }
            else if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                flyoutWidth = 320;
            }
            else
            {
                flyoutWidth = (nfloat)(Math.Min(bounds.Width, bounds.Height) * 0.8);
            }

            if (Height == -1d)
            {
                flyoutHeight = bounds.Height;
            }
            else
            {
                flyoutHeight = (nfloat)Height;
            }

            nfloat openLimit  = flyoutWidth;
            nfloat openPixels = openLimit * openPercent;

            if (behavior == FlyoutBehavior.Locked)
            {
                shell.Frame = new CGRect(bounds.X + flyoutWidth, bounds.Y, bounds.Width - flyoutWidth, flyoutHeight);
            }
            else
            {
                shell.Frame = bounds;
            }

            var shellWidth = shell.Frame.Width;

            if (shell.SemanticContentAttribute == UISemanticContentAttribute.ForceRightToLeft)
            {
                var positionY = shellWidth - openPixels;
                flyout.Frame = new CGRect(positionY, 0, flyoutWidth, flyoutHeight);
            }
            else
            {
                flyout.Frame = new CGRect(-openLimit + openPixels, 0, flyoutWidth, flyoutHeight);
            }
        }
Example #15
0
        public void LayoutViews(CGRect bounds, nfloat openPercent, UIView flyout, UIView shell, FlyoutBehavior behavior)
        {
            if (behavior == FlyoutBehavior.Locked)
            {
                openPercent = 1;
            }

            nfloat flyoutWidth = (nfloat)(Math.Min(bounds.Width, bounds.Height) * 0.8);
            nfloat openLimit   = flyoutWidth;
            nfloat openPixels  = openLimit * openPercent;

            if (behavior == FlyoutBehavior.Locked)
            {
                shell.Frame = new CGRect(bounds.X + flyoutWidth, bounds.Y, bounds.Width - flyoutWidth, bounds.Height);
            }
            else
            {
                shell.Frame = bounds;
            }

            var shellWidth = shell.Frame.Width;

            if (shell.SemanticContentAttribute == UISemanticContentAttribute.ForceRightToLeft)
            {
                var positionY = shellWidth - openPixels;
                flyout.Frame = new CGRect(positionY, 0, flyoutWidth, bounds.Height);
            }
            else
            {
                flyout.Frame = new CGRect(-openLimit + openPixels, 0, flyoutWidth, bounds.Height);
            }

            if (behavior != FlyoutBehavior.Locked)
            {
                var shellOpacity = (nfloat)(0.5 + (0.5 * (1 - openPercent)));
                shell.Layer.Opacity = (float)shellOpacity;
            }
        }
Example #16
0
 void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
 {
 }
 void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
 {
     _behavior = behavior;
     UpdateDrawerLockMode(behavior);
 }
Example #18
0
 public static Shell FlyoutBehavior(this Shell shell, FlyoutBehavior behavior)
 {
     shell.FlyoutBehavior = behavior;
     return(shell);
 }
Example #19
0
 public static void SetFlyoutBehavior(BindableObject obj, FlyoutBehavior value) => obj.SetValue(FlyoutBehaviorProperty, value);
Example #20
0
 public void LayoutViews(CGRect bounds, nfloat openPercent, UIView flyout, UIView shell, FlyoutBehavior behavior)
 {
     flyout.Frame = new CGRect(0, 0, 0, 0);
 }
Example #21
0
        public void LayoutViews(CGRect bounds, nfloat openPercent, UIView flyout, UIView shell, FlyoutBehavior behavior)
        {
            if (behavior == FlyoutBehavior.Locked)
            {
                openPercent = 1;
            }

            nfloat flyoutWidth = (nfloat)(Math.Min(bounds.Width, bounds.Height) * 0.8);
            nfloat openLimit   = flyoutWidth;
            nfloat openPixels  = openLimit * openPercent;

            if (behavior == FlyoutBehavior.Locked)
            {
                shell.Frame = new CGRect(bounds.X + flyoutWidth, bounds.Y, bounds.Width - flyoutWidth, bounds.Height);
            }
            else
            {
                shell.Frame = bounds;
            }

            flyout.Frame = new CGRect(-openLimit + openPixels, 0, flyoutWidth, bounds.Height);

            if (behavior != FlyoutBehavior.Locked)
            {
                var shellOpacity = (nfloat)(0.5 + (0.5 * (1 - openPercent)));
                shell.Layer.Opacity = (float)shellOpacity;
            }
        }
 public static T FlyoutBehavior <T>(this T shell, FlyoutBehavior flyoutBehavior) where T : IRxShell
 {
     shell.FlyoutBehavior = flyoutBehavior;
     return(shell);
 }