protected override void OnSizeAllocated(double width, double height) { base.OnSizeAllocated(width, height); //must be called if (currentWidth != width || currentHeight != height) { currentWidth = width; currentHeight = height; //portrait if (currentHeight > currentWidth) { ContentLayout.Direction = FlexDirection.Column; BookedLayout.Padding = new Thickness(0, 10, 0, 5); FreeLayout.Padding = new Thickness(0, 10, 0, 5); HeaderLayout.HeightRequest = Device.RuntimePlatform == Device.Android ? 40 : 50; if (Device.Idiom == TargetIdiom.Phone) { //FlexLayout.SetGrow(BookedLayout, 0.6f); //FlexLayout.SetGrow(FreeLayout, 0.6f); //FlexLayout.SetGrow(PullToRefresh, 1); FlexLayout.SetBasis(BookedLayout, new FlexBasis(0.4f, true)); FlexLayout.SetBasis(FreeLayout, new FlexBasis(0.4f, true)); FlexLayout.SetBasis(PullToRefresh, new FlexBasis(0.6f, true)); } else { //FlexLayout.SetGrow(BookedLayout, 0.8f); //FlexLayout.SetGrow(FreeLayout, 0.8f); //FlexLayout.SetGrow(PullToRefresh, 1); FlexLayout.SetBasis(BookedLayout, new FlexBasis(0.45f, true)); FlexLayout.SetBasis(FreeLayout, new FlexBasis(0.45f, true)); FlexLayout.SetBasis(PullToRefresh, new FlexBasis(0.55f, true)); } } else { ContentLayout.Direction = FlexDirection.Row; HeaderLayout.HeightRequest = 40; BookedLayout.Padding = new Thickness(0, 10, 0, 10); FreeLayout.Padding = new Thickness(0, 10, 0, 10); //FlexLayout.SetGrow(BookedLayout, 1); //FlexLayout.SetGrow(FreeLayout, 1); //FlexLayout.SetGrow(PullToRefresh, 1f); FlexLayout.SetBasis(BookedLayout, new FlexBasis(0.55f, true)); FlexLayout.SetBasis(FreeLayout, new FlexBasis(0.55f, true)); FlexLayout.SetBasis(PullToRefresh, new FlexBasis(0.45f, true)); } } }
public void TestAlignContentStretchRowWithFlex() { var platform = new UnitPlatform(); var layout = new FlexLayout { Platform = platform, IsPlatformEnabled = true, AlignContent = FlexAlignContent.Stretch, Direction = FlexDirection.Row, Wrap = FlexWrap.Wrap, }; var view0 = new View { IsPlatformEnabled = true, WidthRequest = 50 }; layout.Children.Add(view0); var view1 = new View { IsPlatformEnabled = true, WidthRequest = 50 }; FlexLayout.SetGrow(view1, 1); FlexLayout.SetShrink(view1, 1); FlexLayout.SetBasis(view1, 0); layout.Children.Add(view1); var view2 = new View { IsPlatformEnabled = true, WidthRequest = 50 }; layout.Children.Add(view2); var view3 = new View { IsPlatformEnabled = true, WidthRequest = 50 }; FlexLayout.SetGrow(view3, 1); FlexLayout.SetShrink(view3, 1); FlexLayout.SetBasis(view3, 0); layout.Children.Add(view3); var view4 = new View { IsPlatformEnabled = true, WidthRequest = 50 }; layout.Children.Add(view4); layout.Layout(new Rectangle(0, 0, 150, 100)); Assert.That(layout.Bounds, Is.EqualTo(new Rectangle(0, 0, 150, 100))); Assert.That(view0.Bounds, Is.EqualTo(new Rectangle(0, 0, 50, 100))); Assert.That(view1.Bounds, Is.EqualTo(new Rectangle(50, 0, 0, 100))); Assert.That(view2.Bounds, Is.EqualTo(new Rectangle(50, 0, 50, 100))); Assert.That(view3.Bounds, Is.EqualTo(new Rectangle(100, 0, 0, 100))); Assert.That(view4.Bounds, Is.EqualTo(new Rectangle(100, 0, 50, 100))); }
private static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue) { var control = (MaterialChipsGroup)bindable; control.flexContainer.Children.Clear(); if (!Equals(newValue, null) && newValue is IEnumerable) { foreach (var item in (IEnumerable)newValue) { // TODO: apply ChipsFlexLayoutBasis??? var materialChips = new MaterialChips { HorizontalOptions = LayoutOptions.FillAndExpand, Text = item.ToString(), FontSize = control.FontSize, FontFamily = control.FontFamily, CornerRadius = control.CornerRadius, Padding = control.ChipsPadding, Margin = control.ChipsMargin, BackgroundColor = control.BackgroundColor, TextColor = control.TextColor, SelectedBackgroundColor = control.SelectedBackgroundColor, SelectedTextColor = control.SelectedTextColor, DisabledBackgroundColor = control.DisabledBackgroundColor, DisabledTextColor = control.DisabledTextColor, DisabledSelectedBackgroundColor = control.DisabledSelectedBackgroundColor, DisabledSelectedTextColor = control.DisabledSelectedTextColor }; if (control.IsMultipleSelection) { if (control.SelectedItems != null && control.SelectedItems.Any()) { materialChips.IsSelected = control.SelectedItems.Contains(materialChips.Text); } } else { if (control.SelectedItem != null) { materialChips.IsSelected = materialChips.Text.Equals(control.SelectedItem); } } materialChips.IsSelectedChanged += control.MaterialChips_IsSelectedChanged; control.flexContainer.Children.Add(materialChips); if (control.ChipsFlexLayoutPercentageBasis > 0 && control.ChipsFlexLayoutPercentageBasis <= 1) { FlexLayout.SetBasis(materialChips, new FlexBasis((float)control.ChipsFlexLayoutPercentageBasis, true)); } } } }
// Label 4 event handlers void OnLabel4AutoSwitchToggled(object sender, ToggledEventArgs args) { if (args.Value) { System.Diagnostics.Debug.WriteLine("Switch 4 On"); FlexLayout.SetBasis(label4, FlexBasis.Auto); } else { System.Diagnostics.Debug.WriteLine("Switch 4 Off"); FlexLayout.SetBasis(label4, new FlexBasis((float)slider4.Value, relativeSwitch4.IsToggled)); } }
public void TestMarginsWithWrap() { var platform = new UnitPlatform(); var label0 = new Label { Platform = platform, IsPlatformEnabled = true, Margin = 6, }; var label1 = new Label { Platform = platform, IsPlatformEnabled = true, Margin = 6, }; var label2 = new Label { Platform = platform, 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 { Platform = platform, 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))); }
async void LoadBitmapCollection() { using (HttpClient webClient = new HttpClient()) { try { // Download the list of stock photos Uri uri = new Uri("https://raw.githubusercontent.com/xamarin/docs-archive/master/Images/stock/small/stock.json"); byte[] data = await webClient.GetByteArrayAsync(uri); // Convert to a Stream object using (Stream stream = new MemoryStream(data)) { // Deserialize the JSON into an ImageList object var jsonSerializer = new DataContractJsonSerializer(typeof(ImageList)); ImageList imageList = (ImageList)jsonSerializer.ReadObject(stream); // Create an Image object for each bitmap foreach (string filepath in imageList.Photos) { Debug.WriteLine($"Image: {filepath}"); if (!string.IsNullOrEmpty(filepath)) { Image image = new Image { Source = ImageSource.FromUri(new Uri(filepath)), Aspect = Aspect.AspectFill, MaximumHeightRequest = 100 }; FlexLayout.SetBasis(image, new Microsoft.Maui.Layouts.FlexBasis(0.2f)); flexLayout.Add(image); } } } } catch { flexLayout.Add(new Label { Text = "Cannot access list of bitmap files" }); } } activityIndicator.IsRunning = false; activityIndicator.IsVisible = false; }
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)); }
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; } }
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; } }
public MatchOverviewPage() { NavigationPage.SetHasNavigationBar(this, false); SportFrame footballFrame = new SportFrame("#9CD4AC", "#C2E0C1", "Футбол", "ball.png", footballEvents); FlexLayout.SetBasis(footballFrame, 500); SportFrame hockeyFrame = new SportFrame("#4AA2BD", "#AECED8", "Хоккей", "puck.png", hockeyEvents); hockeyFrame.Margin = new Thickness(0, 25, 0, 0); FlexLayout.SetBasis(hockeyFrame, 500); SportFrame basketBallFrame = new SportFrame("#F59965", "#F2B18C", "Баскетбол", "bsball.png", basketballEvents); basketBallFrame.Margin = new Thickness(0, 25, 0, 0); FlexLayout.SetBasis(basketBallFrame, 500); Content = new ScrollView() { Orientation = ScrollOrientation.Vertical, VerticalScrollBarVisibility = ScrollBarVisibility.Never, Padding = new Thickness(25), Content = new FlexLayout() { Direction = FlexDirection.Row, Wrap = FlexWrap.Wrap, AlignItems = FlexAlignItems.Start, AlignContent = FlexAlignContent.Start, JustifyContent = FlexJustify.SpaceEvenly, Children = { footballFrame, hockeyFrame, basketBallFrame } } }; }
public FlexHeightShrinkPage() { InitializeComponent(); var flexRoot = new FlexLayout { Direction = FlexDirection.Column }; var upperFlex = new FlexLayout { BackgroundColor = Color.Red }; upperFlex.Children.Add(new Label { Text = "Upper" }); FlexLayout.SetGrow(upperFlex, 1); flexRoot.Children.Add(upperFlex); var bottomFlex = new FlexLayout { BackgroundColor = Color.Yellow }; bottomFlex.Children.Add(new Label { Text = "Bottom" }); FlexLayout.SetBasis(bottomFlex, 100); flexRoot.Children.Add(bottomFlex); Content = flexRoot; }
public static TView Basis <TView>(this TView view, FlexBasis value) where TView : View { VerifyExperimental(); FlexLayout.SetBasis(view, value); return(view); }
public void Basis() { FlexLayout.SetBasis(Bindable, FlexBasis.Auto); Bindable.Basis(50); Assert.That(FlexLayout.GetBasis(Bindable), Is.EqualTo(new FlexBasis(50))); }
public static TView Basis <TView>(this TView view, FlexBasis value) where TView : View { FlexLayout.SetBasis(view, value); return(view); }
public void Basis() => AssertExperimental(() => { FlexLayout.SetBasis(Bindable, FlexBasis.Auto); Bindable.Basis(50); Assert.That(FlexLayout.GetBasis(Bindable), Is.EqualTo(new FlexBasis(50))); });
public void TestAlignContentStretchRowWithFlexNoShrink() { 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, WidthRequest = 50 }; layout.Children.Add(view0); var view1 = new View { IsPlatformEnabled = true, WidthRequest = 50 }; FlexLayout.SetGrow(view1, 1); FlexLayout.SetShrink(view1, 1); FlexLayout.SetBasis(view1, 0); layout.Children.Add(view1); var view2 = new View { IsPlatformEnabled = true, WidthRequest = 50 }; layout.Children.Add(view2); var view3 = new View { IsPlatformEnabled = true, WidthRequest = 50 }; FlexLayout.SetGrow(view3, 1); FlexLayout.SetBasis(view3, 0); layout.Children.Add(view3); var view4 = new View { IsPlatformEnabled = true, WidthRequest = 50 }; layout.Children.Add(view4); 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(0f, view1.Width); Assert.AreEqual(100f, view1.Height); Assert.AreEqual(50f, view2.X); Assert.AreEqual(0f, view2.Y); Assert.AreEqual(50f, view2.Width); Assert.AreEqual(100f, view2.Height); Assert.AreEqual(100f, view3.X); Assert.AreEqual(0f, view3.Y); Assert.AreEqual(0f, view3.Width); Assert.AreEqual(100f, view3.Height); Assert.AreEqual(100f, view4.X); Assert.AreEqual(0f, view4.Y); Assert.AreEqual(50f, view4.Width); Assert.AreEqual(100f, view4.Height); }
public void TestAlignContentFlexStartWithFlex() { var platform = new UnitPlatform((visual, width, height) => new SizeRequest(new Size(0, 0))); var layout = new FlexLayout { Platform = platform, IsPlatformEnabled = true, WidthRequest = 100, HeightRequest = 120, Direction = FlexDirection.Column, Wrap = FlexWrap.Wrap, AlignItems = FlexAlignItems.Start, }; var view0 = new View { IsPlatformEnabled = true }; FlexLayout.SetGrow(view0, 1); FlexLayout.SetBasis(view0, 0); view0.WidthRequest = 50; layout.Children.Add(view0); var view1 = new View { IsPlatformEnabled = true }; FlexLayout.SetGrow(view1, 1); FlexLayout.SetBasis(view1, 0); view1.WidthRequest = 50; view1.HeightRequest = 10; layout.Children.Add(view1); var view2 = new View { IsPlatformEnabled = true }; view2.WidthRequest = 50; layout.Children.Add(view2); var view3 = new View { IsPlatformEnabled = true }; FlexLayout.SetGrow(view3, 1); FlexLayout.SetShrink(view3, 1); FlexLayout.SetBasis(view3, 0); view3.WidthRequest = 50; layout.Children.Add(view3); var view4 = new View { IsPlatformEnabled = true }; view4.WidthRequest = 50; layout.Children.Add(view4); layout.Layout(new Rectangle(0, 0, 100, 120)); Assert.That(layout.Bounds, Is.EqualTo(new Rectangle(0, 0, 100, 120))); Assert.That(view0.Bounds, Is.EqualTo(new Rectangle(0, 0, 50, 40))); Assert.That(view1.Bounds, Is.EqualTo(new Rectangle(0, 40, 50, 40))); Assert.That(view2.Bounds, Is.EqualTo(new Rectangle(0, 80, 50, 0))); Assert.That(view3.Bounds, Is.EqualTo(new Rectangle(0, 80, 50, 40))); Assert.That(view4.Bounds, Is.EqualTo(new Rectangle(0, 120, 50, 0))); }
private void SelfInit() { var tapRecognizer = new TapGestureRecognizer(); tabContainer = new FlexLayout { BackgroundColor = SelectedTextBGColor, Padding = new Thickness(0, 0, 0, TabMargin * 2) }; tabLabels = new List <Label>(); int i = 0; try{ TabSource.ForEach(t => { var label = new Label { Text = t.ToString(), TextColor = TabTextColor, WidthRequest = TabWidth, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, BackgroundColor = TabBGColor, Margin = new Thickness(TabMargin, 0), ClassId = i.ToString(), FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), GestureRecognizers = { tapRecognizer } }; tabLabels.Add(label); tabContainer.Children.Add(label); i++; }); }catch { } tapRecognizer.Tapped += async(o, args) => { await detail.FadeTo(0, 100); Label selectedLabel = tabContainer.Children.Where(l => l.ClassId == selected).FirstOrDefault() as Label; selectedLabel.BackgroundColor = TabBGColor; selectedLabel.TextColor = TabTextColor; Label label = o as Label; selected = label.ClassId; label.BackgroundColor = SelectedTextBGColor; label.TextColor = SelectedTextColor; //detail.Text = DetailSrouce[int.Parse(selected)]; await detail.FadeTo(1, 100); }; detail = new Editor { BackgroundColor = Color.Azure }; FlexLayout.SetBasis(detail, new FlexBasis(0.9f, true)); FlexLayout.SetGrow(detail, 1f); var scrollView = new ScrollView { Content = tabContainer, Orientation = ScrollOrientation.Horizontal }; FlexLayout.SetBasis(scrollView, new FlexBasis(0.1f, true)); frame = new Frame { Padding = new Thickness(1), HasShadow = true, BorderColor = Color.FromHex("#101A40") }; frame.Content = new FlexLayout { Direction = FlexDirection.Column, JustifyContent = FlexJustify.Start, Children = { scrollView, detail }, }; selected = "0"; try { tabContainer.Children[0].BackgroundColor = SelectedTextBGColor; } catch { } }
public MainPageCS() { #region Football StackLayout footballHeader = new StackLayout { Padding = new Thickness(16), Orientation = StackOrientation.Horizontal, Children = { new Image { Margin = new Thickness(24, 0, 0, 0), HeightRequest = 35, WidthRequest = 35, VerticalOptions = LayoutOptions.Center, Source = ImageSource.FromResource("FBIOperation.Images.ball.png", typeof(MainPageCS).GetTypeInfo().Assembly) }, new Entry { BackgroundColor = Color.Transparent, Text = "Футбол", FontSize = 24, FontAttributes = FontAttributes.Bold, TextColor = Color.White, VerticalOptions = LayoutOptions.Center, WidthRequest = 180, HorizontalOptions = LayoutOptions.Start, Margin = new Thickness(14, 0, 0, 0) }, new Button { Text = "X", BorderWidth = 3, BorderColor = Color.FromHex("#FFD7CO"), TextColor = Color.FromHex("#FFD7CO"), FontAttributes = FontAttributes.Bold, HeightRequest = 40, WidthRequest = 40, CornerRadius = 20, VerticalOptions = LayoutOptions.Center, BackgroundColor = Color.Transparent, HorizontalOptions = LayoutOptions.EndAndExpand, Margin = new Thickness(0, 0, 24, 0) } } }; StackLayout footballStackBody = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new Label { Text = "Итог", TextColor = Color.FromHex("#F3F3F3"), FontSize = 20, Margin = new Thickness(0, 5), HorizontalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.FillAndExpand }, new BoxView { BackgroundColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 1.5 } } }; for (int i = 0; i < footballItogCountItems; i++) { footballStackBody.Children.Add(new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 0, Padding = new Thickness(0, 4), Children = { new Label { Text = "ФК Москва", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, TextColor = Color.FromHex("#F3F3F3") }, new Label { Text = "0 : 1", FontSize = 22, FontAttributes = FontAttributes.Bold, HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, 0, 26, 0), TextColor = Color.FromHex("#F3F3F3") }, new Label { Text = "Сатурн", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, TextColor = Color.FromHex("#F3F3F3") } } }); if (i != 9) { footballStackBody.Children.Add(new BoxView { BackgroundColor = Color.White, HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 1.5 }); } } Frame footballBody = new Frame { HasShadow = false, BackgroundColor = Color.FromHex("#C6E8CB"), VerticalOptions = LayoutOptions.FillAndExpand, CornerRadius = 30, Padding = new Thickness(0), HeightRequest = 500, Content = new ScrollView { VerticalScrollBarVisibility = ScrollBarVisibility.Never, Content = footballStackBody } }; Frame footballFrame = new Frame() { Margin = Device.RuntimePlatform == Device.Android ? new Thickness(16, 16) : Device.RuntimePlatform == Device.UWP ? new Thickness(24, 16) : new Thickness(8), HeightRequest = 400, CornerRadius = 50, BackgroundColor = Color.FromHex("#9CD4AC"), Padding = new Thickness(0), Content = new StackLayout { Children = { footballHeader, footballBody } } }; FlexLayout.SetBasis(footballFrame, new FlexBasis(600)); #endregion #region Hockey Image puckImage = new Image() { Source = ImageSource.FromResource("FBIOperation.Images.puck.png", typeof(MainPageCS).GetTypeInfo().Assembly), HeightRequest = 35, WidthRequest = 35, Margin = new Thickness(40, 16, 0, 16), VerticalOptions = LayoutOptions.Center }; Grid.SetRow(puckImage, 0); Grid.SetColumn(puckImage, 0); Label hockeyHeaderLabel = new Label() { Text = "Хоккей", TextColor = Color.FromHex("#F3F3F3"), FontSize = 24, FontAttributes = FontAttributes.Bold, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(16, 16, 0, 16) }; Grid.SetRow(hockeyHeaderLabel, 0); Grid.SetColumn(hockeyHeaderLabel, 1); Switch hockeySwitch = new Switch() { IsToggled = true, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.EndAndExpand, Margin = new Thickness(0, 0, 60, 0), OnColor = Color.LightGray, ThumbColor = Color.Gray }; Grid.SetRow(hockeySwitch, 0); Grid.SetColumn(hockeySwitch, 2); Label hockeyItogLabel = new Label { Text = "Итог", TextColor = Color.FromHex("#F3F3F3"), FontSize = 20, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.FillAndExpand }; Grid.SetColumn(hockeyItogLabel, 0); Grid.SetColumnSpan(hockeyItogLabel, 3); Grid.SetRow(hockeyItogLabel, 0); Label hockeyHomeTeamLabel1 = new Label { Text = "ФК Москва", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyHomeTeamLabel1, 1); Grid.SetColumn(hockeyHomeTeamLabel1, 0); Label hockeyScoreLabel1 = new Label() { Text = "0 : 1", FontSize = 22, FontAttributes = FontAttributes.Bold, TextColor = Color.FromHex("#F3F3F3"), HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("AECED8") }; Grid.SetRow(hockeyScoreLabel1, 1); Grid.SetColumn(hockeyScoreLabel1, 1); Label hockeyGuestTeamLabel1 = new Label() { Text = "Сатурн", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyGuestTeamLabel1, 1); Grid.SetColumn(hockeyGuestTeamLabel1, 2); #region Labels Label hockeyHomeTeamLabel2 = new Label { Text = "ФК Москва", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyHomeTeamLabel2, 2); Grid.SetColumn(hockeyHomeTeamLabel2, 0); Label hockeyScoreLabel2 = new Label() { Text = "0 : 1", FontSize = 22, FontAttributes = FontAttributes.Bold, TextColor = Color.FromHex("#F3F3F3"), HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("AECED8") }; Grid.SetRow(hockeyScoreLabel2, 2); Grid.SetColumn(hockeyScoreLabel2, 1); Label hockeyGuestTeamLabel2 = new Label() { Text = "Сатурн", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyGuestTeamLabel2, 2); Grid.SetColumn(hockeyGuestTeamLabel2, 2); Label hockeyHomeTeamLabel3 = new Label { Text = "ФК Москва", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyHomeTeamLabel3, 3); Grid.SetColumn(hockeyHomeTeamLabel3, 0); Label hockeyScoreLabel3 = new Label() { Text = "0 : 1", FontSize = 22, FontAttributes = FontAttributes.Bold, TextColor = Color.FromHex("#F3F3F3"), HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("AECED8") }; Grid.SetRow(hockeyScoreLabel3, 3); Grid.SetColumn(hockeyScoreLabel3, 1); Label hockeyGuestTeamLabel3 = new Label() { Text = "Сатурн", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyGuestTeamLabel3, 3); Grid.SetColumn(hockeyGuestTeamLabel3, 2); Label hockeyHomeTeamLabel4 = new Label { Text = "ФК Москва", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyHomeTeamLabel4, 4); Grid.SetColumn(hockeyHomeTeamLabel4, 0); Label hockeyScoreLabel4 = new Label() { Text = "0 : 1", FontSize = 22, FontAttributes = FontAttributes.Bold, TextColor = Color.FromHex("#F3F3F3"), HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("AECED8") }; Grid.SetRow(hockeyScoreLabel4, 4); Grid.SetColumn(hockeyScoreLabel4, 1); Label hockeyGuestTeamLabel4 = new Label() { Text = "Сатурн", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyGuestTeamLabel4, 4); Grid.SetColumn(hockeyGuestTeamLabel4, 2); Label hockeyHomeTeamLabel5 = new Label { Text = "ФК Москва", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyHomeTeamLabel5, 5); Grid.SetColumn(hockeyHomeTeamLabel5, 0); Label hockeyScoreLabel5 = new Label() { Text = "0 : 1", FontSize = 22, FontAttributes = FontAttributes.Bold, TextColor = Color.FromHex("#F3F3F3"), HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("AECED8") }; Grid.SetRow(hockeyScoreLabel5, 5); Grid.SetColumn(hockeyScoreLabel5, 1); Label hockeyGuestTeamLabel5 = new Label() { Text = "Сатурн", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyGuestTeamLabel5, 5); Grid.SetColumn(hockeyGuestTeamLabel5, 2); Label hockeyHomeTeamLabel6 = new Label { Text = "ФК Москва", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyHomeTeamLabel6, 6); Grid.SetColumn(hockeyHomeTeamLabel6, 0); Label hockeyScoreLabel6 = new Label() { Text = "0 : 1", FontSize = 22, FontAttributes = FontAttributes.Bold, TextColor = Color.FromHex("#F3F3F3"), HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("AECED8") }; Grid.SetRow(hockeyScoreLabel6, 6); Grid.SetColumn(hockeyScoreLabel6, 1); Label hockeyGuestTeamLabel6 = new Label() { Text = "Сатурн", HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("#AECED8"), TextColor = Color.FromHex("F3F3F3") }; Grid.SetRow(hockeyGuestTeamLabel6, 6); Grid.SetColumn(hockeyGuestTeamLabel6, 2); #endregion Grid hockeyBodyGrid = new Grid() { BackgroundColor = Color.White, RowSpacing = 1, ColumnSpacing = 0, RowDefinitions = { new RowDefinition() { Height = GridLength.Star }, new RowDefinition() { Height = GridLength.Star }, new RowDefinition() { Height = GridLength.Star }, new RowDefinition() { Height = GridLength.Star }, new RowDefinition() { Height = GridLength.Star }, new RowDefinition() { Height = GridLength.Star }, new RowDefinition() { Height = GridLength.Star }, }, ColumnDefinitions = { new ColumnDefinition() { Width = GridLength.Star }, new ColumnDefinition() { Width = GridLength.Auto }, new ColumnDefinition() { Width = GridLength.Star }, }, Children = { hockeyItogLabel, hockeyHomeTeamLabel1, hockeyScoreLabel1, hockeyGuestTeamLabel1, hockeyHomeTeamLabel2, hockeyScoreLabel2, hockeyGuestTeamLabel2, hockeyHomeTeamLabel3, hockeyScoreLabel3, hockeyGuestTeamLabel3, hockeyHomeTeamLabel4, hockeyScoreLabel4, hockeyGuestTeamLabel4, hockeyHomeTeamLabel5, hockeyScoreLabel5, hockeyGuestTeamLabel5, hockeyHomeTeamLabel6, hockeyScoreLabel6, hockeyGuestTeamLabel6, } }; Frame hockeyBodyFrame = new Frame() { HasShadow = false, BackgroundColor = Color.FromHex("#AECED8"), VerticalOptions = LayoutOptions.FillAndExpand, CornerRadius = 30, Padding = new Thickness(0), HeightRequest = 500, Content = hockeyBodyGrid }; Grid.SetRow(hockeyBodyFrame, 1); Grid.SetColumn(hockeyBodyFrame, 0); Grid.SetColumnSpan(hockeyBodyFrame, 3); Grid hockeyMainGrid = new Grid { ColumnDefinitions = { new ColumnDefinition() { Width = new GridLength(75, GridUnitType.Absolute) }, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, }, RowDefinitions = { new RowDefinition() { Height = GridLength.Auto }, new RowDefinition() { Height = GridLength.Star }, }, Children = { puckImage, hockeyHeaderLabel, hockeySwitch, hockeyBodyFrame } }; Frame hockeyFrame = new Frame { Margin = Device.RuntimePlatform == Device.Android ? new Thickness(16, 16) : Device.RuntimePlatform == Device.UWP ? new Thickness(24, 16) : new Thickness(8), HeightRequest = 400, CornerRadius = 50, BackgroundColor = Color.FromHex("#4AA2BD"), Padding = new Thickness(0), Content = new StackLayout { Children = { hockeyMainGrid } } }; FlexLayout.SetBasis(hockeyFrame, new FlexBasis(600)); #endregion #region BasketBall FlexLayout basketballRowHolder = new FlexLayout() { Direction = FlexDirection.Column }; for (int i = 0; i < basketballItogCountItems; i++) { FlexLayout basketballRow = new FlexLayout() { Direction = FlexDirection.Row, JustifyContent = FlexJustify.SpaceEvenly, AlignItems = FlexAlignItems.Center, Children = { new Label { Text = "ФК Москва", TextColor = Color.FromHex("#F3F3F3") }, new Label { Text = "0 : 1", FontSize = 22, FontAttributes = FontAttributes.Bold, Margin = new Thickness(0, 0, 26, 0), TextColor = Color.FromHex("#F3F3F3") }, new Label { Text = "Сатурн", TextColor = Color.FromHex("#F3F3F3") } } }; FlexLayout.SetBasis(basketballRow, new FlexBasis(50)); BoxView rowSeparator = new BoxView() { BackgroundColor = Color.White }; FlexLayout.SetAlignSelf(rowSeparator, FlexAlignSelf.Stretch); FlexLayout.SetBasis(rowSeparator, 2f); basketballRowHolder.Children.Add(basketballRow); basketballRowHolder.Children.Add(rowSeparator); } BoxView basketBallSeparator0 = new BoxView() { BackgroundColor = Color.White }; FlexLayout.SetAlignSelf(basketBallSeparator0, FlexAlignSelf.Stretch); FlexLayout.SetBasis(basketBallSeparator0, 2f); Label basketballNameLabel = new Label() { Text = "Итог", TextColor = Color.FromHex("#F3F3F3"), FontSize = 20, Margin = new Thickness(0, 10), FontAttributes = FontAttributes.Bold }; FlexLayout.SetAlignSelf(basketballNameLabel, FlexAlignSelf.Center); Frame basketballBodyFrame = new Frame() { HasShadow = false, BackgroundColor = Color.FromHex("#F2B18C"), CornerRadius = 30, Padding = new Thickness(0), Content = new FlexLayout() { Direction = FlexDirection.Column, Children = { basketballNameLabel, basketBallSeparator0, new ScrollView() { Content = basketballRowHolder } } } }; FlexLayout.SetGrow(basketballBodyFrame, 1); Label basketballHeaderLabel = new Label() { Text = "Баскетбол", FontSize = 24, FontAttributes = FontAttributes.Bold, TextColor = Color.White, Margin = new Thickness(16, 16, 0, 16) }; FlexLayout.SetGrow(basketballHeaderLabel, 1); FlexLayout basketballHeader = new FlexLayout() { Direction = FlexDirection.Row, AlignItems = FlexAlignItems.Start, JustifyContent = FlexJustify.Start, Children = { new Image() { Source = ImageSource.FromResource("FBIOperation.Images.bsball.png", typeof(MainPageCS).GetTypeInfo().Assembly), Margin = new Thickness(40, 16, 0, 16), HeightRequest = 35, WidthRequest = 35 }, basketballHeaderLabel, new CheckBox() { IsChecked = false, BackgroundColor = Color.Transparent, Color = Color.FromHex("#F2B18C"), Margin = new Thickness(0, 16, 40, 16) } } }; FlexLayout.SetBasis(basketballHeader, new FlexBasis(130)); Frame basketBallFrame = new Frame() { Margin = Device.RuntimePlatform == Device.Android ? new Thickness(16, 16) : Device.RuntimePlatform == Device.UWP ? new Thickness(24, 16) : new Thickness(8), HeightRequest = 400, CornerRadius = 50, Padding = new Thickness(0), Content = new FlexLayout() { Direction = FlexDirection.Column, BackgroundColor = Color.FromHex("#E5824B"), JustifyContent = FlexJustify.Start, Wrap = FlexWrap.NoWrap, AlignItems = FlexAlignItems.Start, Children = { basketballHeader, basketballBodyFrame } } }; FlexLayout.SetBasis(basketBallFrame, new FlexBasis(600)); #endregion Content = new ScrollView { Content = new FlexLayout { Direction = FlexDirection.Row, Wrap = FlexWrap.Wrap, AlignItems = FlexAlignItems.Start, AlignContent = FlexAlignContent.SpaceEvenly, JustifyContent = FlexJustify.SpaceAround, Margin = Device.RuntimePlatform == Device.Android ? new Thickness(8) : Device.RuntimePlatform == Device.UWP ? new Thickness(48) : new Thickness(8), Children = { footballFrame, hockeyFrame, basketBallFrame } } }; }
void OnLabel4SliderValueChanged(object sender, ValueChangedEventArgs args) { FlexLayout.SetBasis(label4, new FlexBasis((float)args.NewValue, relativeSwitch4.IsToggled)); }
public P8ImageTest() { FlexLayout layout = new FlexLayout(); Frame image_frame = new Frame(); image_frame.WidthRequest = 500; image_frame.HeightRequest = 500; CircleImgSource cis = new CircleImgSource(); P8Image image = new P8Image(cis); FlexLayout.SetAlignSelf(image, FlexAlignSelf.Stretch); // FlexLayout.SetGrow(image, 2f); FlexLayout.SetBasis(image_frame, new FlexBasis(0.9f)); // FlexLayout.SetBasis(image, new FlexBasis(600f)); Binding bindI = new Binding { Source = layout, Path = "Width" }; image.SetBinding(WidthRequestProperty, bindI); image_frame.Content = image; layout.Children.Add(image_frame); // image.HeightRequest = 100; image.BackgroundColor = Color.LightBlue; layout.Direction = FlexDirection.Column; layout.AlignItems = FlexAlignItems.Start; layout.JustifyContent = FlexJustify.Center; layout.Children.Add(image); FlexLayout layout1 = new FlexLayout(); layout.HeightRequest = 100; Label width_label = new Label { Text = "Width: " }; Label label = new Label(); label.SetBinding(Label.TextProperty, new Binding(source: image, path: "Width")); layout1.Children.Add(width_label); layout1.Children.Add(label); Label height_label = new Label { Text = " Height: " }; layout1.Children.Add(height_label); Label height_labela_value = new Label(); height_labela_value.SetBinding(Label.TextProperty, new Binding { Source = image, Path = "Height" }); layout1.Children.Add(height_labela_value); FlexLayout.SetBasis(layout1, new FlexBasis(1)); Frame bottom_frame = new Frame(); bottom_frame.Content = layout1; layout.Children.Add(bottom_frame); this.Content = layout; }