Ejemplo n.º 1
0
        /// <summary>
        /// Updates <see cref="_internalFlyoutLayoutBehavior"/> according to <see cref="FlyoutLayoutBehavior"/> set by the user and current screen orientation.
        /// </summary>
        void UpdateFlyoutLayoutBehavior()
        {
            var behavior = (_flyoutLayoutBehavior == FlyoutLayoutBehavior.Default) ? s_defaultFlyoutLayoutBehavior : _flyoutLayoutBehavior;

            // Screen orientation affects those 2 behaviors
            if (behavior == FlyoutLayoutBehavior.SplitOnLandscape || behavior == FlyoutLayoutBehavior.SplitOnPortrait)
            {
                var orientation = DeviceDisplay.MainDisplayInfo.Orientation;

                if ((orientation.IsLandscape() && behavior == FlyoutLayoutBehavior.SplitOnLandscape) || (orientation.IsPortrait() && behavior == FlyoutLayoutBehavior.SplitOnPortrait))
                {
                    behavior = FlyoutLayoutBehavior.Split;
                }
                else
                {
                    behavior = FlyoutLayoutBehavior.Popover;
                }
            }

            if (behavior != _internalFlyoutLayoutBehavior)
            {
                _internalFlyoutLayoutBehavior = behavior;
                ConfigureLayout();
            }
        }
Ejemplo n.º 2
0
        public virtual bool ShouldShowToolbarButton()
        {
            if (Device.Idiom == TargetIdiom.Phone)
            {
                return(true);
            }

            FlyoutLayoutBehavior behavior = FlyoutLayoutBehavior;
            var orientation = DeviceDisplay.MainDisplayInfo.Orientation;

            bool isSplitOnLandscape = (behavior == FlyoutLayoutBehavior.SplitOnLandscape || behavior == FlyoutLayoutBehavior.Default) && orientation.IsLandscape();
            bool isSplitOnPortrait  = behavior == FlyoutLayoutBehavior.SplitOnPortrait && orientation.IsPortrait();

            return(behavior != FlyoutLayoutBehavior.Split && !isSplitOnLandscape && !isSplitOnPortrait);
        }
Ejemplo n.º 3
0
        private FlyoutLayoutBehaviorType GetFlyoutLayoutBehavior(FlyoutLayoutBehavior flyoutBehavior)
        {
            switch (flyoutBehavior)
            {
            case FlyoutLayoutBehavior.Split:
            case FlyoutLayoutBehavior.SplitOnLandscape:
            case FlyoutLayoutBehavior.SplitOnPortrait:
                return(FlyoutLayoutBehaviorType.Split);

            case FlyoutLayoutBehavior.Popover:
                return(FlyoutLayoutBehaviorType.Popover);

            case FlyoutLayoutBehavior.Default:
                return(FlyoutLayoutBehaviorType.Default);

            default:
                throw new ArgumentOutOfRangeException(nameof(flyoutBehavior));
            }
        }
Ejemplo n.º 4
0
 public InnerDelegate(FlyoutLayoutBehavior flyoutPresentedDefaultState)
 {
     _flyoutPresentedDefaultState = flyoutPresentedDefaultState;
 }
Ejemplo n.º 5
0
        public Issue1461Page(FlyoutLayoutBehavior state, bool?initState)
        {
            var btn = new Button {
                Text = "hide me"
            };

            btn.Clicked += bnToggle_Clicked;
            Flyout       = new ContentPage
            {
                Title           = string.Format("Flyout sample for {0}", state),
                IconImageSource = "bank.png",
                Padding         = Device.RuntimePlatform == Device.iOS ? new Thickness(5, 60, 5, 5) : new Thickness(5),
                Content         =
                    new StackLayout
                {
                    Children =
                    {
                        new Label {
                            Text            = "Flyout Label",
                            AutomationId    = "Master_Label",
                            BackgroundColor = Color.Gray
                        },
                        btn
                    },
                    BackgroundColor = Color.WhiteSmoke
                },
                BackgroundColor = Color.Gray
            };

            if (initState.HasValue)
            {
                _showButton = initState.Value;
            }

            var lbl = new Label
            {
                HorizontalOptions = LayoutOptions.End,
                BindingContext    = this
            };

            lbl.SetBinding(Label.TextProperty, "IsPresented");

            var bnToggle = new Button
            {
                Text = "Toggle IsPresented",
            };

            var bnGoBack = new Button
            {
                Text = "Go Back",
            };

            bnGoBack.Clicked += bnGoBack_Clicked;
            bnToggle.Clicked += bnToggle_Clicked;

            Detail = new NavigationPage(new ContentPage
            {
                Title   = "Detail Title",
                Content = new StackLayout {
                    Spacing = 10, Children = { lbl, bnToggle, bnGoBack }
                }
            });

            FlyoutLayoutBehavior = state;
        }
Ejemplo n.º 6
0
 public static FlyoutPage FlyoutLayoutBehavior(this FlyoutPage page, FlyoutLayoutBehavior behavior)
 {
     page.FlyoutLayoutBehavior = behavior;
     return(page);
 }