public void TestOrderingElements()
        {
            var platform = new UnitPlatform();
            var label0   = new Label {
                Platform = platform, IsPlatformEnabled = true
            };
            var label1 = new Label {
                Platform = platform, IsPlatformEnabled = true
            };
            var label2 = new Label {
                Platform = platform, IsPlatformEnabled = true
            };
            var label3 = new Label {
                Platform = platform, IsPlatformEnabled = true
            };

            FlexLayout.SetOrder(label3, 0);
            FlexLayout.SetOrder(label2, 1);
            FlexLayout.SetOrder(label1, 2);
            FlexLayout.SetOrder(label0, 3);

            var layout = new FlexLayout {
                Platform          = platform,
                IsPlatformEnabled = true,
                Direction         = FlexDirection.Column,
                Children          =
                {
                    label0,
                    label1,
                    label2,
                    label3
                }
            };

            layout.Layout(new Rectangle(0, 0, 912, 912));

            Assert.That(layout.Bounds, Is.EqualTo(new Rectangle(0, 0, 912, 912)));
            Assert.That(label3.Bounds, Is.EqualTo(new Rectangle(0, 0, 912, 20)));
            Assert.That(label2.Bounds, Is.EqualTo(new Rectangle(0, 20, 912, 20)));
            Assert.That(label1.Bounds, Is.EqualTo(new Rectangle(0, 40, 912, 20)));
            Assert.That(label0.Bounds, Is.EqualTo(new Rectangle(0, 60, 912, 20)));
        }
 public static TView Order <TView>(this TView view, int value) where TView : View
 {
     FlexLayout.SetOrder(view, value);
     return(view);
 }
Exemplo n.º 3
0
 public static TView Order <TView>(this TView view, int value) where TView : View
 {
     VerifyExperimental();
     FlexLayout.SetOrder(view, value);
     return(view);
 }
Exemplo n.º 4
0
 public void Order() => AssertExperimental(() =>
 {
     FlexLayout.SetOrder(Bindable, 0);
     Bindable.Order(1);
     Assert.That(FlexLayout.GetOrder(Bindable), Is.EqualTo(1));
 });
Exemplo n.º 5
0
 public void Order()
 {
     FlexLayout.SetOrder(Bindable, 0);
     Bindable.Order(1);
     Assert.That(FlexLayout.GetOrder(Bindable), Is.EqualTo(1));
 }
        public FlexLayoutDemoPage()
        {
            FlexLayout flexLayout = new FlexLayout();

            foreach (DataItem item in data)
            {
                FlexLayout itemFlexLayout = new FlexLayout
                {
                    Direction = FlexDirection.Column,
                    Children  =
                    {
                        new Label
                        {
                            Text      = item.Header,
                            Margin    = new Thickness(0, 8),
                            FontSize  = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                            TextColor = Color.Blue,
                        },
                        new Label
                        {
                            Text   = item.Description,
                            Margin = new Thickness(0, 4),
                        },
                    }
                };

                foreach (string bullet in item.Bullets)
                {
                    itemFlexLayout.Children.Add(new Label
                    {
                        Text   = "  \u2022 " + bullet,
                        Margin = new Thickness(0, 4)
                    });
                }

                var x = ImageSource.FromResource("");

                Image image = new Image
                {
                    Source        = ImageSource.FromResource("FormsGallery.Images." + item.Image),
                    WidthRequest  = item.ImageWidth,
                    HeightRequest = 180
                };

                FlexLayout.SetOrder(image, -1);
                FlexLayout.SetAlignSelf(image, FlexAlignSelf.Center);
                itemFlexLayout.Children.Add(image);

                Label blankLabel = new Label();
                FlexLayout.SetGrow(blankLabel, 1);
                itemFlexLayout.Children.Add(blankLabel);

                itemFlexLayout.Children.Add(new Button
                {
                    Text            = "LEARN MORE",
                    FontSize        = Device.GetNamedSize(NamedSize.Large, typeof(Button)),
                    TextColor       = Color.White,
                    BackgroundColor = Color.Green,
                    CornerRadius    = 20
                });

                flexLayout.Children.Add(new Frame
                {
                    WidthRequest    = 300,
                    HeightRequest   = 480,
                    BackgroundColor = Color.LightYellow,
                    BorderColor     = Color.Blue,
                    Margin          = new Thickness(10),
                    CornerRadius    = 15,
                    Content         = itemFlexLayout
                });
            }

            // Build the page.
            Title   = "FlexLayout Demo";
            Content = new ScrollView
            {
                Orientation = ScrollOrientation.Both,
                Content     = flexLayout
            };
        }