Ejemplo n.º 1
0
        public void TestVisibility()
        {
            View child1, child2;
            var  stack = new StackLayout
            {
                IsPlatformEnabled = true,
                Children          =
                {
                    (child1               = new View {
                        IsPlatformEnabled = true
                    }),
                    (child2               = new View {
                        IsPlatformEnabled = true
                    })
                }
            };

            stack.Layout(new Rectangle(0, 0, 100, 100));

            var size = stack.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity).Request;

            Assert.AreEqual(new Rectangle(0, 0, 100, 20), child1.Bounds);
            Assert.AreEqual(new Rectangle(0, 26, 100, 20), child2.Bounds);
            Assert.AreEqual(new Size(100, 46), size);

            child1.IsVisible = false;
            Assert.False(child1.IsVisible);
            Assert.AreEqual(new Rectangle(0, 0, 100, 20), child2.Bounds);
            size = stack.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity).Request;
            Assert.AreEqual(new Size(100, 20), size);
        }
Ejemplo n.º 2
0
        public void ReinflatesViewsCorrectly()
        {
            var child1 = new BoxView
            {
                IsPlatformEnabled    = true,
                VerticalOptions      = LayoutOptions.FillAndExpand,
                HeightRequest        = 400,
                MinimumHeightRequest = 10
            };

            var child2 = new BoxView
            {
                IsPlatformEnabled    = true,
                HeightRequest        = 40,
                MinimumHeightRequest = 40
            };

            var stack = new StackLayout
            {
                Spacing           = 0,
                IsPlatformEnabled = true,
                Children          = { child1, child2 }
            };

            stack.Layout(new Rectangle(0, 0, 100, 100));

            Assert.AreEqual(new Rectangle(0, 0, 100, 60), child1.Bounds);
            Assert.AreEqual(new Rectangle(0, 60, 100, 40), child2.Bounds);

            stack.GetSizeRequest(100, 100);
            stack.Layout(new Rectangle(0, 0, 100, 500));

            Assert.AreEqual(new Rectangle(0, 0, 100, 460), child1.Bounds);
            Assert.AreEqual(new Rectangle(0, 460, 100, 40), child2.Bounds);
        }
Ejemplo n.º 3
0
        public void GetMinimumSizeHorizontal()
        {
            var stack = new StackLayout
            {
                IsPlatformEnabled = true,
                Spacing           = 10,
                Orientation       = StackOrientation.Horizontal,
                Children          =
                {
                    new View {
                        WidthRequest = 100, HeightRequest = 100, IsPlatformEnabled = true
                    },
                    new View {
                        WidthRequest = 100, HeightRequest = 100, IsPlatformEnabled = true
                    },
                    new View {
                        WidthRequest = 100, HeightRequest = 100, MinimumWidthRequest = 10, IsPlatformEnabled = true
                    }
                }
            };

            var result = stack.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity);

            Assert.That(result.Minimum, Is.EqualTo(new Size(230, 100)));
        }
Ejemplo n.º 4
0
        public void OffOrientationMinimumSize()
        {
            var stack = new StackLayout {
                IsPlatformEnabled = true,
                Spacing           = 0
            };

            stack.Children.Add(new View {
                IsPlatformEnabled    = true,
                WidthRequest         = 100,
                HeightRequest        = 100,
                MinimumWidthRequest  = 10,
                MinimumHeightRequest = 10
            });

            var result = stack.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity);

            Assert.AreEqual(new Size(10, 10), result.Minimum);
        }
Ejemplo n.º 5
0
        public void TestSizeRequestVertical()
        {
            var stack = new StackLayout {
                IsPlatformEnabled = true,
                Children          =
                {
                    new View {
                        WidthRequest = 20, HeightRequest = 20, IsPlatformEnabled = true
                    },
                    new View {
                        WidthRequest = 30, HeightRequest = 30, IsPlatformEnabled = true
                    }
                }
            };

            var size = stack.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity).Request;

            Assert.AreEqual(new Size(30, 56), size);
        }
Ejemplo n.º 6
0
        public void TestLastChildNotVisible()
        {
            View child1, child2;
            var  stack = new StackLayout {
                IsPlatformEnabled = true,
                Children          =
                {
                    (child1          = new View {
                        WidthRequest =          20, HeightRequest = 20, IsPlatformEnabled = true
                    }),
                    (child2          = new View {
                        WidthRequest = 30, HeightRequest = 30, IsPlatformEnabled = true, IsVisible = false
                    })
                }
            };

            var r = stack.GetSizeRequest(100, 100);

            Assert.AreEqual(new SizeRequest(new Size(20, 20)), r);
        }
Ejemplo n.º 7
0
        public void TestSizeRequestHorizontal()
        {
            var stack = new StackLayout {
                Orientation       = StackOrientation.Horizontal,
                IsPlatformEnabled = true,
                Children          =
                {
                    new View {
                        WidthRequest = 20, HeightRequest = 20, IsPlatformEnabled = true
                    },
                    new View {
                        WidthRequest = 30, HeightRequest = 30, IsPlatformEnabled = true
                    }
                }
            };

            var size = stack.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity).Request;

            Assert.AreEqual(new Size(56, 30), size);
        }
Ejemplo n.º 8
0
        public void GetMinimumSizeVertical()
        {
            var stack = new StackLayout {
                Platform          = new UnitPlatform(),
                IsPlatformEnabled = true,
                Spacing           = 10,
                Children          =
                {
                    new View {
                        WidthRequest = 100, HeightRequest = 100, IsPlatformEnabled = true
                    },
                    new View {
                        WidthRequest = 100, HeightRequest = 100, IsPlatformEnabled = true
                    },
                    new View {
                        WidthRequest = 100, HeightRequest = 100, MinimumHeightRequest = 10, IsPlatformEnabled = true
                    }
                }
            };

            var result = stack.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity);

            Assert.That(result.Minimum, Is.EqualTo(new Size(100, 230)));
        }