public ItemDefaultTemplateAdaptor(ItemsView itemsView) : base(itemsView)
        {
            ItemTemplate = new DataTemplate(() =>
            {
                var label = new XLabel
                {
                    TextColor = Color.Black,
                };
                label.SetBinding(XLabel.TextProperty, new Binding(".", converter: new ToTextConverter()));

                return(new StackLayout
                {
                    BackgroundColor = Color.White,
                    Padding = 30,
                    Children =
                    {
                        label
                    }
                });
            });
        }
Exemple #2
0
        protected override void Init()
        {
            var span = new Span
            {
                Text =
                    " Mi augue molestie ligula lobortis enim Velit, in. \n Imperdiet eu dignissim odio. Massa erat Hac inceptos facilisis nibh " +
                    " Interdum massa Consectetuer risus sociis molestie facilisi enim. Class gravida. \n Gravida sociosqu cras Quam velit, suspendisse" +
                    "  leo auctor odio integer primis dui potenti dolor faucibus augue justo morbi ornare sem. "
            };

            var formattedString = new FormattedString();

            formattedString.Spans.Add(span);

            var label = new System.Maui.Label
            {
                LineBreakMode   = LineBreakMode.TailTruncation,
                VerticalOptions = LayoutOptions.Start,
                FormattedText   = formattedString,
                MaxLines        = 3
                                  //max line is less than the text reproduce and textViewExtensions couldn't identify when
                                  //it's already pass the MaxLines range because of the paragraph('\n' character).
            };

            var labelDescription = new Label
            {
                Text            = "If you opened this page, the app didn't crash and you can read three lines in the label above, this test has passed",
                VerticalOptions = LayoutOptions.StartAndExpand
            };

            var layout = new System.Maui.StackLayout();

            layout.Children.Add(label);
            layout.Children.Add(labelDescription);

            Content = layout;
        }
Exemple #3
0
        public EmbeddingControls()
        {
            PlayImage = new ImageButton
            {
                Source    = ImageSource.FromResource(PlayImagePath, typeof(EmbeddingControls).Assembly),
                IsVisible = false
            };
            PlayImage.Clicked += OnImageButtonClicked;
            AbsoluteLayout.SetLayoutFlags(PlayImage, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(PlayImage, new Rectangle(0.5, 0.5, 0.25, 0.25));

            PauseImage = new ImageButton
            {
                Source    = ImageSource.FromResource(PauseImagePath, typeof(EmbeddingControls).Assembly),
                IsVisible = false
            };
            PauseImage.Clicked += OnImageButtonClicked;
            AbsoluteLayout.SetLayoutFlags(PauseImage, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(PauseImage, new Rectangle(0.5, 0.5, 0.25, 0.25));

            var bufferingLabel = new XLabel
            {
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label), false),
                HorizontalTextAlignment = XTextAlignment.Center,
                TextColor = Color.FromHex("#eeeeeeee")
            };

            bufferingLabel.SetBinding(XLabel.TextProperty, new Binding
            {
                Path         = "BufferingProgress",
                StringFormat = "{0:0%}"
            });
            bufferingLabel.SetBinding(IsVisibleProperty, new Binding
            {
                Path = "IsBuffering",
            });
            AbsoluteLayout.SetLayoutFlags(bufferingLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(bufferingLabel, new Rectangle(0.5, 0.5, 0.25, 0.25));

            var progressBoxView = new BoxView
            {
                Color = Color.FromHex($"#4286f4")
            };

            progressBoxView.SetBinding(AbsoluteLayout.LayoutBoundsProperty, new Binding
            {
                Path      = "Progress",
                Converter = new ProgressToBoundTextConverter()
            });
            AbsoluteLayout.SetLayoutFlags(progressBoxView, AbsoluteLayoutFlags.All);

            var posLabel = new XLabel
            {
                Margin   = new Thickness(10, 0, 0, 0),
                FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(XLabel)),
                HorizontalTextAlignment = XTextAlignment.Start
            };

            posLabel.SetBinding(XLabel.TextProperty, new Binding
            {
                Path      = "Position",
                Converter = new MillisecondToTextConverter()
            });
            AbsoluteLayout.SetLayoutFlags(posLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(posLabel, new Rectangle(0, 0, 1, 1));

            var durationLabel = new XLabel
            {
                Margin   = new Thickness(0, 0, 10, 0),
                FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(XLabel)),
                HorizontalTextAlignment = XTextAlignment.End
            };

            durationLabel.SetBinding(XLabel.TextProperty, new Binding
            {
                Path      = "Duration",
                Converter = new MillisecondToTextConverter()
            });
            AbsoluteLayout.SetLayoutFlags(durationLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(durationLabel, new Rectangle(0, 0, 1, 1));

            var progressInnerLayout = new AbsoluteLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = 23,
                BackgroundColor   = Color.FromHex("#80000000"),
                Children          =
                {
                    progressBoxView,
                    posLabel,
                    durationLabel
                }
            };

            var progressLayout = new StackLayout
            {
                Children =
                {
                    new StackLayout {
                        VerticalOptions = LayoutOptions.FillAndExpand
                    },
                    new StackLayout
                    {
                        Margin            = Device.Idiom == TargetIdiom.Watch ? new Thickness(80, 0, 80, 0) : 20,
                        VerticalOptions   = LayoutOptions.End,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        BackgroundColor   = Color.FromHex("#50000000"),
                        Children          = { progressInnerLayout }
                    }
                }
            };

            AbsoluteLayout.SetLayoutFlags(progressLayout, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(progressLayout, new Rectangle(0, 0, 1, 1));

            Content = new AbsoluteLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Children          =
                {
                    progressLayout,
                    PlayImage,
                    PauseImage,
                    bufferingLabel
                }
            };
        }