コード例 #1
0
        public void TestMarginLeft()
        {
            var view0 = new View {
                IsPlatformEnabled = true, WidthRequest = 10, Margin = new Thickness(10, 0, 0, 0),
            };
            var layout = new FlexLayout {
                IsPlatformEnabled = true,
                Children          =
                {
                    view0,
                },
                Direction = FlexDirection.Row,
            };

            layout.Layout(new Rectangle(0, 0, 100, 100));
            Assert.That(layout.Bounds, Is.EqualTo(new Rectangle(0, 0, 100, 100)));
            Assert.That(view0.Bounds, Is.EqualTo(new Rectangle(10, 0, 10, 100)));
        }
コード例 #2
0
        public void FlexLayoutWrapType()
        {
            tlog.Debug(tag, $"FlexLayoutWrapType START");

            var testingTarget = new FlexLayout();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <FlexLayout>(testingTarget, "Should return FlexLayout instance.");

            testingTarget.WrapType = FlexLayout.FlexWrapType.NoWrap;
            Assert.AreEqual(testingTarget.WrapType, FlexLayout.FlexWrapType.NoWrap, "Should be NoWrap.");

            testingTarget.WrapType = FlexLayout.FlexWrapType.Wrap;
            Assert.AreEqual(testingTarget.WrapType, FlexLayout.FlexWrapType.Wrap, "Should be Wrap.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"FlexLayoutWrapType END (OK)");
        }
コード例 #3
0
 public StackLayout GetStackLayout()
 {
     Entry entry = new Entry();
     Button button = new Button();
     FlexLayout flexLayout = new FlexLayout();
     entry.Keyboard = Keyboard.Numeric;
     entry.Placeholder = "$";
     entry.TextChanged += EntryTextChange;
     button.Text = "I am paid";
     button.BackgroundColor = Color.BlueViolet;
     button.TextColor = Color.White;
     button.Clicked += ClickBtn;
     stackLayout = new StackLayout();
     stackLayout.Children.Add(entry);
     flexLayout.Children.Add(button);
     stackLayout.Children.Add(flexLayout);
     return stackLayout; 
 }
コード例 #4
0
        public void FlexLayoutItemsAlignment()
        {
            tlog.Debug(tag, $"FlexLayoutItemsAlignment START");

            var testingTarget = new FlexLayout();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <FlexLayout>(testingTarget, "Should return FlexLayout instance.");

            testingTarget.ItemsAlignment = FlexLayout.AlignmentType.FlexStart;
            Assert.AreEqual(testingTarget.ItemsAlignment, FlexLayout.AlignmentType.FlexStart, "Should be FlexStart.");

            testingTarget.ItemsAlignment = FlexLayout.AlignmentType.FlexEnd;
            Assert.AreEqual(testingTarget.ItemsAlignment, FlexLayout.AlignmentType.FlexEnd, "Should be FlexEnd.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"FlexLayoutItemsAlignment END (OK)");
        }
コード例 #5
0
        public void TestAlignItemsStretch()
        {
            var layout = new FlexLayout
            {
                IsPlatformEnabled = true,

                Direction = FlexDirection.Column,
            };
            var view0 = new View {
                IsPlatformEnabled = true, HeightRequest = 10,
            };

            layout.Children.Add(view0);

            layout.Layout(new Rectangle(0, 0, 100, 100));
            Assert.That(layout.Bounds, Is.EqualTo(new Rectangle(0, 0, 100, 100)));
            Assert.That(view0.Bounds, Is.EqualTo(new Rectangle(0, 0, 100, 10)));
        }
コード例 #6
0
        private void PortraitViewCommon()
        {
            PageLayout.Direction   = FlexDirection.Column;
            AppInfo.IsVisible      = false;
            AppInfoImage.IsVisible = false;

            LoginFormFrame.BackgroundColor = Color.Transparent;

            Logo.VerticalOptions = LayoutOptions.EndAndExpand;

            LogoSection.Padding = new Thickness(0);

            FormTitle.HorizontalTextAlignment = TextAlignment.Center;

            FlexLayout.SetBasis(CompanyInfo, new FlexBasis(0.2f, true));
            FlexLayout.SetBasis(LoginForm, new FlexBasis(0.8f, true));
            FlexLayout.SetBasis(LogoSection, new FlexBasis(1, true));
        }
コード例 #7
0
        public void MonsterReadPage_AddItemsToDisplay_With_Data_Should_Remove_And_Pass()
        {
            // Arrange

            // Put some data into the box so it can be removed
            FlexLayout itemBox = (FlexLayout)page.Content.FindByName("ItemBox");

            itemBox.Children.Add(new Label());
            itemBox.Children.Add(new Label());

            // Act
            page.AddItemsToDisplay();

            // Reset

            // Assert
            Assert.AreEqual(1, itemBox.Children.Count()); // Got to here, so it happened...
        }
コード例 #8
0
        public MyTappedView2rdTryHost()
        {
            Content = new FlexLayout {
                Padding = new Thickness(10), Children = { new TappedView2rdTry() }
            };
            //Label label = new Label
            //{
            //    Text = "This is a very long label which I expect to scroll horizontally because it's in a ScrollView.",
            //    Font = Font.SystemFontOfSize(24),
            //};

            //this.Content = new ScrollView
            //{
            //    Content = label,
            //    //HorizontalOptions = LayoutOptions.Fill,
            //    Orientation = ScrollOrientation.Horizontal,
            //};
        }
コード例 #9
0
        public void TestRelayoutOnChildrenRemoved()
        {
            var layoutSize = new Size(300, 50);

            var layout = new FlexLayout
            {
                IsPlatformEnabled = true,
                Direction         = FlexDirection.Row
            };

            var label1 = new Label {
                IsPlatformEnabled = true
            };

            FlexLayout.SetGrow(label1, 1);
            layout.Children.Add(label1);

            var label2 = new Label {
                IsPlatformEnabled = true
            };

            FlexLayout.SetGrow(label2, 1);
            layout.Children.Add(label2);

            var label3 = new Label {
                IsPlatformEnabled = true
            };

            FlexLayout.SetGrow(label3, 1);
            layout.Children.Add(label3);

            layout.Layout(new Rect(0, 0, layoutSize.Width, layoutSize.Height));

            foreach (var view in layout.Children)
            {
                Assert.That(view.Frame.Width, Is.EqualTo(100));
            }

            layout.Children.Remove(label3);

            Assert.That(label1.Bounds.Width, Is.EqualTo(150));
            Assert.That(label2.Bounds.Width, Is.EqualTo(150));
            Assert.That(label3.Bounds.Width, Is.EqualTo(100));
        }
コード例 #10
0
        public void TestAlignItemsFlexEnd()
        {
            var layout = new FlexLayout
            {
                IsPlatformEnabled = true,

                AlignItems = FlexAlignItems.End,
                Direction  = FlexDirection.Column,
            };
            var view0 = new View {
                IsPlatformEnabled = true, WidthRequest = 10, HeightRequest = 10
            };

            layout.Children.Add(view0);

            layout.Layout(new Rect(0, 0, 100, 100));
            Assert.That(layout.Bounds, Is.EqualTo(new Rect(0, 0, 100, 100)));
            Assert.That(view0.Bounds, Is.EqualTo(new Rect(90, 0, 10, 10)));
        }
コード例 #11
0
        void init(Playlist playlist)
        {
            if (playlist != null && playlist.TracksSerialized != null)
            {
                List <Track> tracks = playlist.GetTracks();

                if (tracks != null && tracks.Count != 0)
                {
                    currentPlaylist = playlist;

                    foreach (Track track in tracks)
                    {
                        if (track != null)
                        {
                            Image image = new Image()
                            {
                                Source = "track_ico.png", WidthRequest = 50, HeightRequest = 50
                            };
                            Label label = new Label()
                            {
                                Text = prepTrackTitle(track.Name), VerticalTextAlignment = TextAlignment.Center, HeightRequest = 50, Margin = new Thickness(10, 0)
                            };

                            FlexLayout flexLayout = new FlexLayout();
                            flexLayout.Children.Add(image);
                            flexLayout.Children.Add(label);

                            TapGestureRecognizer gestureRecognizer = new TapGestureRecognizer();
                            gestureRecognizer.Tapped += trackButtonClicked;

                            Frame frame = new Frame()
                            {
                                HeightRequest = 50, Padding = 0, Content = flexLayout
                            };
                            frame.GestureRecognizers.Add(gestureRecognizer);

                            tracksDictionary.Add(frame, track);
                            TracksContainer.Children.Add(frame);
                        }
                    }
                }
            }
        }
コード例 #12
0
        private void MobileView(SKPaintSurfaceEventArgs args, OrientationValue deviceOrientation)
        {
            Username.Margin    = new Thickness(0, 15, 0, 0);
            Password.Margin    = new Thickness(0, 15, 0, 0);
            LoginButton.Margin = new Thickness(0, 15, 0, 0);

            FormTitle.FontSize = 25;

            if (deviceOrientation == OrientationValue.Landscape)
            {
                PaintLandScapeBackground(args);
                LandScapeViewCommon();

                FlexLayout.SetBasis(CompanyInfo, new FlexBasis(0.35f, true));
                FlexLayout.SetBasis(LoginForm, new FlexBasis(0.65f, true));
                FlexLayout.SetBasis(LogoSection, new FlexBasis(1, true));

                LoginFormFrame.HasShadow       = true;
                LoginFormFrame.Margin          = new Thickness(0, 30, 70, 30);
                LoginFormFrame.Padding         = new Thickness(20);
                LoginFormFrame.BackgroundColor = Color.White;

                AppInfo.IsVisible      = true;
                AppInfoImage.IsVisible = false;

                LogoSection.Padding = new Thickness(21, 0);

                LogoSectionInner.VerticalOptions = LayoutOptions.CenterAndExpand;
            }
            else
            {
                PaintPortraitBackground(args);
                PortraitViewCommon();

                LoginFormFrame.Padding   = new Thickness(20, 40);
                LoginFormFrame.Margin    = new Thickness(30, 0);
                LoginFormFrame.HasShadow = false;

                Logo.WidthRequest = 200;

                LogoSectionInner.VerticalOptions = LayoutOptions.EndAndExpand;
            }
        }
コード例 #13
0
        public void TestAlignSelfFlexEndOverrideFlexStart()
        {
            var layout = new FlexLayout {
                IsPlatformEnabled = true,

                AlignItems = FlexAlignItems.Start,
                Direction  = FlexDirection.Column,
            };
            var view0 = new View {
                IsPlatformEnabled = true, WidthRequest = 10, HeightRequest = 10
            };

            FlexLayout.SetAlignSelf(view0, FlexAlignSelf.End);
            layout.Children.Add(view0);

            layout.Layout(new Rectangle(0, 0, 100, 100));
            Assert.That(layout.Bounds, Is.EqualTo(new Rectangle(0, 0, 100, 100)));
            Assert.That(view0.Bounds, Is.EqualTo(new Rectangle(90, 0, 10, 10)));
        }
コード例 #14
0
        public void TestFlexLayoutIsIncludeChangeWorksOnSecondPass()
        {
            var layoutSize = new Size(300, 50);
            var platform   = new UnitPlatform();
            var layout     = new FlexLayout {
                Direction         = FlexDirection.Row,
                Platform          = platform,
                IsPlatformEnabled = true,
            };

            var label1 = new Label {
                Platform = platform, IsPlatformEnabled = true
            };

            FlexLayout.SetGrow(label1, 1);
            layout.Children.Add(label1);

            var label2 = new Label {
                Platform = platform, IsPlatformEnabled = true
            };

            FlexLayout.SetGrow(label2, 1);
            layout.Children.Add(label2);

            var label3 = new Label {
                Platform = platform, IsPlatformEnabled = true
            };

            FlexLayout.SetGrow(label3, 1);

            layout.Layout(new Rectangle(0, 0, layoutSize.Width, layoutSize.Height));

            Assert.AreEqual(150, label1.Bounds.Width);
            Assert.AreEqual(150, label2.Bounds.Width);
            Assert.AreEqual(-1, label3.Bounds.Width);

            layout.Children.Add(label3);

            layout.Layout(new Rectangle(0, 0, layoutSize.Width, layoutSize.Height));
            Assert.AreEqual(100, label1.Bounds.Width);
            Assert.AreEqual(100, label2.Bounds.Width);
            Assert.AreEqual(100, label3.Bounds.Width);
        }
コード例 #15
0
        public void MonsterReadPage_AddItemsToDisplay_With_Data_Should_Remove_And_Pass()
        {
            // Arrange

            // Put some data into the box so it can be removed
            FlexLayout itemBox = (FlexLayout)page.Content.FindByName("ItemBox");

            itemBox.Children.Add(new Label());
            itemBox.Children.Add(new Label());

            // Act
            // remove and load based on unique item, since this model doesn't have any should load nothing
            page.AddUniqueDropItemToDisplay();

            // Reset

            // Assert
            Assert.AreEqual(0, itemBox.Children.Count()); // Got to here, so it happened...
        }
コード例 #16
0
        public void TestAlignContentStretchRowWithSingleRow()
        {
            var platform = new UnitPlatform();
            var layout   = new FlexLayout {
                Platform          = platform,
                IsPlatformEnabled = true,
                Direction         = FlexDirection.Row,
                AlignContent      = FlexAlignContent.Stretch,
                Wrap          = FlexWrap.Wrap,
                WidthRequest  = 150,
                HeightRequest = 100
            };
            var view0 = new View {
                IsPlatformEnabled = true
            };

            view0.WidthRequest = 50;
            layout.Children.Add(view0);

            var view1 = new View {
                IsPlatformEnabled = true
            };

            view1.WidthRequest = 50;
            layout.Children.Add(view1);

            layout.Layout(new Rectangle(0, 0, 150, 100));

            Assert.AreEqual(0f, layout.X);
            Assert.AreEqual(0f, layout.Y);
            Assert.AreEqual(150f, layout.Width);
            Assert.AreEqual(100f, layout.Height);

            Assert.AreEqual(0f, view0.X);
            Assert.AreEqual(0f, view0.Y);
            Assert.AreEqual(50f, view0.Width);
            Assert.AreEqual(100f, view0.Height);

            Assert.AreEqual(50f, view1.X);
            Assert.AreEqual(0f, view1.Y);
            Assert.AreEqual(50f, view1.Width);
            Assert.AreEqual(100f, view1.Height);
        }
コード例 #17
0
        public void TestAlignSelfCenter()
        {
            var layout = new FlexLayout
            {
                IsPlatformEnabled = true,

                Direction = FlexDirection.Column,
            };
            var view0 = new View {
                IsPlatformEnabled = true, WidthRequest = 10, HeightRequest = 10
            };

            FlexLayout.SetAlignSelf(view0, FlexAlignSelf.Center);
            layout.Children.Add(view0);

            layout.Layout(new Rectangle(0, 0, 100, 100));
            Assert.That(layout.Bounds, Is.EqualTo(new Rectangle(0, 0, 100, 100)));
            Assert.That(view0.Bounds, Is.EqualTo(new Rectangle(45, 0, 10, 10)));
        }
コード例 #18
0
ファイル: FlexLayoutTests.cs プロジェクト: MIliev11/Samples
        //https://github.com/xamarin/Xamarin.Forms/issues/2551
        public void TestReverseWithGrow()
        {
            var label0 = new Label {
                IsPlatformEnabled = true,
            };

            FlexLayout.SetGrow(label0, 1);
            var layout = new FlexLayout {
                IsPlatformEnabled = true,
                Direction         = FlexDirection.ColumnReverse,
                Children          =
                {
                    label0,
                }
            };

            layout.Layout(new Rectangle(0, 0, 300, 300));
            Assert.That(label0.Bounds, Is.EqualTo(new Rectangle(0, 0, 300, 300)));
        }
コード例 #19
0
        private void Setup()
        {
            ContentView imageview = new ContentView {
                Content = this.ImageLogo,
            };

            // Label wrapping is buggy, so we put the wrapped label in 1x1 grid
            var gridSummary = new Grid {
                Padding    = new Thickness(20, 20, 30, 20),
                RowSpacing = 30
            };

            this.ContentViewInstructionWrapper.Content = this.LabelInstruction;
            gridSummary.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            gridSummary.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });
            gridSummary.Children.Add(this.LabelSummary, 0, 0);
            gridSummary.Children.Add(this.ContentViewInstructionWrapper, 0, 1);



            FlexLayout flexLayout = new FlexLayout {
                Direction      = FlexDirection.Column,
                JustifyContent = FlexJustify.Center,
                Children       =
                {
                    imageview,
                    this.LabelTitleTop,
                    this.LabelTitleBottom,
                    gridSummary,
                    this.ButtonCreateAccount,
                    this.ButtonLogin,
                },
            };

            this.ScrollViewContent.Content = flexLayout;


            Content = this.ScrollViewContent;
        }
コード例 #20
0
 void SetupRadioGroup(IList <string> values, FlexLayout parent, string selectedPropertyName)
 {
     for (int i = 0; i < values.Count; i++)
     {
         string      name   = values[i];
         RadioButton button = new RadioButton();
         button.LabelText = name;
         button.SetBinding(RadioButton.IsSelectedProperty,
                           new Binding(
                               selectedPropertyName,
                               source: BindingContext,
                               converter: new DrawerEnumToStringConverter(),
                               converterParameter: name,
                               mode: BindingMode.TwoWay
                               )
                           );
         parent.Children.Add(button);
     }
 }
コード例 #21
0
        public void DrawItems_Remove_Should_Pass()
        {
            // Arrange
            FlexLayout itemlistfoundframe = (FlexLayout)page.Content.FindByName("ItemListFoundFrame");

            BattleEngineViewModel.Instance.Engine.EngineSettings.CurrentAttacker = null;

            // add two elements to the list because when will be removed
            itemlistfoundframe.Children.Add(new FlexLayout());
            itemlistfoundframe.Children.Add(new FlexLayout());

            // Act
            page.DrawItems();

            // Reset

            // Assert
            Assert.AreEqual(0, itemlistfoundframe.Children.Count);
        }
コード例 #22
0
        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)));
        }
コード例 #23
0
        public FlexLayoutView()
        {
            StackLayout mainStack = new StackLayout();

            mainStack.Margin = new Thickness(0, 40, 0, 0);
            Label header = new Label()
            {
                Text              = "Flex",
                FontSize          = 40,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            FlexLayout flex = new FlexLayout()
            {
                AlignItems     = FlexAlignItems.Center,
                Direction      = FlexDirection.Column,
                JustifyContent = FlexJustify.Start
            };
            StackLayout container = new StackLayout();
            Label       lbl       = new Label();

            lbl.Text = "Control 1 en flex";
            Button btn = new Button();

            btn.Text = "Boton nuevo";
            Image img = new Image()
            {
                Source        = "https://pbs.twimg.com/media/CrmcAkBW8AA-gTX.jpg",
                WidthRequest  = 200,
                HeightRequest = 200
            };
            Entry entry = new Entry();

            entry.Text = "Caja de texto";
            container.Children.Add(lbl);
            container.Children.Add(btn);
            container.Children.Add(img);
            container.Children.Add(entry);
            flex.Children.Add(container);
            mainStack.Children.Add(header);
            mainStack.Children.Add(flex);
            this.Content = mainStack;
        }
コード例 #24
0
ファイル: FlexLayoutTests.cs プロジェクト: MIliev11/Samples
        public void TestMarginsWithWrap()
        {
            var label0 = new Label {
                IsPlatformEnabled = true,
                Margin            = 6,
            };
            var label1 = new Label {
                IsPlatformEnabled = true,
                Margin            = 6,
            };
            var label2 = new Label {
                IsPlatformEnabled = true,
            };

            FlexLayout.SetGrow(label0, 0);
            FlexLayout.SetBasis(label0, new FlexBasis(.5f, true));
            FlexLayout.SetGrow(label1, 0);
            FlexLayout.SetBasis(label1, new FlexBasis(.5f, true));
            FlexLayout.SetGrow(label2, 0);
            FlexLayout.SetBasis(label2, new FlexBasis(1f, true));
            var layout = new FlexLayout {
                IsPlatformEnabled = true,
                Direction         = FlexDirection.Row,
                Wrap         = FlexWrap.Wrap,
                AlignItems   = FlexAlignItems.Start,
                AlignContent = FlexAlignContent.Start,
                Children     =
                {
                    label0,
                    label1,
                    label2,
                }
            };

            var measure = layout.Measure(300, double.PositiveInfinity);

            Assert.That(measure.Request, Is.EqualTo(new Size(300, 52)));
            layout.Layout(new Rectangle(0, 0, 300, 300));
            Assert.That(label0.Bounds, Is.EqualTo(new Rectangle(6, 6, 138, 20)));
            Assert.That(label1.Bounds, Is.EqualTo(new Rectangle(156, 6, 138, 20)));
            Assert.That(label2.Bounds, Is.EqualTo(new Rectangle(0, 32, 300, 20)));
        }
コード例 #25
0
        public void TestIsVisible()
        //https://github.com/xamarin/Xamarin.Forms/issues/2593
        {
            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 layout = new FlexLayout {
                Platform          = platform,
                IsPlatformEnabled = true,
                Direction         = FlexDirection.Column,
                Children          =
                {
                    label0,
                    label1,
                    label2,
                }
            };

            layout.Layout(new Rectangle(0, 0, 300, 300));
            Assert.That(label0.Bounds, Is.EqualTo(new Rectangle(0, 0, 300, 20)));
            Assert.That(label1.Bounds, Is.EqualTo(new Rectangle(0, 20, 300, 20)));
            Assert.That(label2.Bounds, Is.EqualTo(new Rectangle(0, 40, 300, 20)));

            label1.IsVisible = false;
            Assert.That(label0.Bounds, Is.EqualTo(new Rectangle(0, 0, 300, 20)));
            Assert.That(label2.Bounds, Is.EqualTo(new Rectangle(0, 20, 300, 20)));

            label0.IsVisible = false;
            label1.IsVisible = true;
            Assert.That(label1.Bounds, Is.EqualTo(new Rectangle(0, 0, 300, 20)));
            Assert.That(label2.Bounds, Is.EqualTo(new Rectangle(0, 20, 300, 20)));
        }
コード例 #26
0
        public Practica2Collatz()
        {
            stack1 = new StackLayout()
            {
                Margin = new Thickness(0, 40, 0, 0)
            };

            Label header = new Label()
            {
                Text              = "COLLATZ ",
                TextColor         = Color.Black,
                FontSize          = 20,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            ScrollView scroll1 = new ScrollView();

            scroll1.Orientation = ScrollOrientation.Horizontal;

            //Añadimos el scroll al layout principal
            stack1.Children.Add(scroll1);


            FlexLayout contenedor = new FlexLayout();

            contenedor.Direction       = FlexDirection.Row;
            contenedor.BackgroundColor = Color.YellowGreen;
            contenedor.VerticalOptions = LayoutOptions.Center;

            for (int i = 0; i < 15; i++)
            {
                Button boton = new Button();
                boton.Text = i.ToString();
                boton.HorizontalOptions = LayoutOptions.Center;

                boton.Clicked += (sender, args) => CalculaCollazts(int.Parse(boton.Text));

                contenedor.Children.Add(boton);
            }
            scroll1.Content = contenedor;
            this.Content    = stack1; //IMPORTANTE
        }
コード例 #27
0
        private void TabletView(SKPaintSurfaceEventArgs args, OrientationValue deviceOrientation)
        {
            Username.Margin                  = new Thickness(0, 25, 0, 0);
            Password.Margin                  = new Thickness(0, 20, 0, 0);
            LoginButton.Margin               = new Thickness(0, 25, 0, 0);
            FormTitle.FontSize               = 30;
            LoginFormFrame.HasShadow         = false;
            LogoSectionInner.VerticalOptions = LayoutOptions.EndAndExpand;

            if (deviceOrientation == OrientationValue.Landscape)
            {
                PaintLandScapeBackground(args);
                LandScapeViewCommon();

                FlexLayout.SetBasis(CompanyInfo, new FlexBasis(0.55f, true));
                FlexLayout.SetBasis(LoginForm, new FlexBasis(0.45f, true));
                FlexLayout.SetBasis(LogoSection, new FlexBasis(0.35f, true));

                LoginFormFrame.Margin  = new Thickness(60, 0);
                LoginFormFrame.Padding = new Thickness(0);

                AppInfo.IsVisible      = true;
                AppInfoImage.IsVisible = true;

                Logo.HorizontalOptions = LayoutOptions.Start;

                FormTitle.HorizontalTextAlignment = TextAlignment.Start;

                LogoSection.Padding = new Thickness(60, 20, 120, 20);
            }
            else
            {
                PaintPortraitBackground(args);
                PortraitViewCommon();

                LoginFormFrame.Padding = new Thickness(30, 40);
                LoginFormFrame.Margin  = new Thickness(80);

                Logo.HorizontalOptions = LayoutOptions.CenterAndExpand;
                Logo.WidthRequest      = 300;
            }
        }
コード例 #28
0
ファイル: FlexLayoutTests.cs プロジェクト: MIliev11/Samples
        public void ChangingGrowTriggersLayout()
        //https://github.com/xamarin/Xamarin.Forms/issues/2821
        {
            var layout = new FlexLayout {
                IsPlatformEnabled = true,
                Direction         = FlexDirection.Column,
            };

            layout.Layout(new Rectangle(0, 0, 300, 300));
            for (var i = 0; i < 3; i++)
            {
                var box = new BoxView {
                    IsPlatformEnabled = true,
                };
                layout.Children.Add(box);
                FlexLayout.SetGrow(box, 1f);
            }

            Assert.That(layout.Children[2].Bounds, Is.EqualTo(new Rectangle(0, 200, 300, 100)));
        }
コード例 #29
0
        public void TestMarginBottom()
        {
            var view0 = new View {
                IsPlatformEnabled = true, HeightRequest = 10, Margin = new Thickness(0, 0, 0, 10),
            };
            var layout = new FlexLayout {
                IsPlatformEnabled = true,
                Children          =
                {
                    view0,
                },

                Direction      = FlexDirection.Column,
                JustifyContent = FlexJustify.End,
            };

            layout.Layout(new Rectangle(0, 0, 100, 100));
            Assert.That(layout.Bounds, Is.EqualTo(new Rectangle(0, 0, 100, 100)));
            Assert.That(view0.Bounds, Is.EqualTo(new Rectangle(0, 80, 100, 10)));
        }
        public void TestAlignItemsCenter()
        {
            var platform = new UnitPlatform();
            var layout   = new FlexLayout {
                Platform          = platform,
                IsPlatformEnabled = true,

                AlignItems = FlexAlignItems.Center,
                Direction  = FlexDirection.Column,
            };
            var view0 = new View {
                IsPlatformEnabled = true, WidthRequest = 10, HeightRequest = 10
            };

            layout.Children.Add(view0);

            layout.Layout(new Rectangle(0, 0, 100, 100));
            Assert.That(layout.Bounds, Is.EqualTo(new Rectangle(0, 0, 100, 100)));
            Assert.That(view0.Bounds, Is.EqualTo(new Rectangle(45, 0, 10, 10)));
        }