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 } }); }); }
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 } }; }