public void InitializeControls() { MainStackLayout = new StackLayout { Padding = 0, Spacing = 1, }; azkarStackLayout = new StackLayout { Padding = 0, Spacing = 1, }; mistakesStackLayout = new StackLayout { Padding = 0, Spacing = 1, }; ahkamStackLayout = new StackLayout { Padding = 0, Spacing = 1, }; virtueStackLayout = new StackLayout { Padding = 0, Spacing = 1, }; ///////////////////////////////////////////////////// // Image of place and description ///////////////////////////////////////////////////// imgMedia = new Image { Source = postData.GetImageUri(), Aspect = Aspect.Fill, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, }; imgMapPlaceIcon = new ClickableImage { Source = PLACE_MAP_ICON_URI, VerticalOptions = LayoutOptions.Start, TranslationY = -30, Scale = .9, }; imgMapViewIcon = new ClickableImage { Source = MAP_VIEW_ICON_URI, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Start, TranslationX = -10, TranslationY = 10, IsVisible = false, Scale = .8, }; if (Device.OS == TargetPlatform.iOS) { imgMapPlaceIcon.Scale = .45; imgMapPlaceIcon.TranslationY = -72; imgMapViewIcon.Scale = .45; imgMapViewIcon.TranslationX = +5; imgMapViewIcon.TranslationY = -5; } imgMapPlaceIcon.Clicked += ImgMapPlaceIcon_Clicked; imgMapViewIcon.Clicked += ImgMapViewIcon_Clicked; lblPlaceTitle = new Label() { Text = postData.Title, VerticalOptions = LayoutOptions.FillAndExpand, XAlign = TextAlignment.End, YAlign = TextAlignment.Start, FontSize = ZadSpecialDesigen.GetFontSizeOfTitle(), TextColor = ZadSpecialDesigen.ZadGreen, //BackgroundColor = ZadSpecialDesigen.ZadWhite, }; lblPlaceDescription = new Label() { Text = postData.Description, VerticalOptions = LayoutOptions.FillAndExpand, FontSize = ZadSpecialDesigen.GetFontSizeOfTitle(), XAlign = TextAlignment.End, YAlign = TextAlignment.Start, TextColor = ZadSpecialDesigen.GetTextColorOfDescription(), //BackgroundColor = Color.FromHex("#F3F7F8"),//// }; gridMedia = new Grid() { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowSpacing = 0, ColumnSpacing = 0, RowDefinitions = { new RowDefinition { Height = new GridLength(250, GridUnitType.Absolute) }, new RowDefinition { Height = GridLength.Auto }, }, BackgroundColor = Color.FromHex("#F3F7F8"), }; var stackDescription = new StackLayout() { Padding = ZadSpecialDesigen.GetPaddingOfDescription(), BackgroundColor = Color.FromHex("#F3F7F8"),//// }; stackDescription.VerticalOptions = LayoutOptions.Fill; //stackDescription.HorizontalOptions = LayoutOptions.FillAndExpand; stackDescription.Children.Add(lblPlaceTitle); stackDescription.Children.Add(lblPlaceDescription); //// image for loading status which apper under the media image and it will be disappear when the image media cove over it. gridMedia.Children.Add(new StackLayout { Padding = 100, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Children = { new Image { Source = DEFAULT_LOADING_IMAGE, } }, }, 0, 0); gridMedia.Children.Add(imgMedia, 0, 0); gridMedia.Children.Add(imgMapViewIcon, 0, 0); gridMedia.Children.Add(stackDescription, 0, 1); gridMedia.Children.Add(imgMapPlaceIcon, 0, 1); MainStackLayout.Children.Add(gridMedia); MainStackLayout.Children.Add(azkarStackLayout); MainStackLayout.Children.Add(mistakesStackLayout); MainStackLayout.Children.Add(ahkamStackLayout); MainStackLayout.Children.Add(virtueStackLayout); ///////////////////////////////////////////////////// /////// Related Post Layout ///////////////////////////////////////////////////// FillRelatedPostsLayout(PostType.Place); ///////////////////////////////////////////////////// /////// Footer toolBar Area ///////////////////////////////////////////////////// imgAzkar = new ClickableImage { Source = AZKAR_FOOTER_ICON_URI, }; imgAhkam = new ClickableImage { Source = AHKAM_FOOTER_ICON_URI, }; imgMistakes = new ClickableImage { Source = MISTAKES_FOOTER_ICON_URI, }; imgVirtue = new ClickableImage { Source = VIRTUE_FOOTER_ICON_URI }; imgFavorite = new ClickableImage { Source = Helper.GetUnFavoriteIconUri() }; imgAzkar.Clicked += ImgAzkar_Clicked; imgAhkam.Clicked += ImgAhkam_Clicked; imgMistakes.Clicked += ImgMistakes_Clicked; imgVirtue.Clicked += ImgVirtue_Clicked; imgFavorite.Clicked += ImgFavorite_Clicked; if (!azkar.HasData()) { imgAzkar.Disabled = true; } if (!mistakes.HasData()) { imgMistakes.Disabled = true; } if (!ahkam.HasData()) { imgAhkam.Disabled = true; } if (!virtue.HasData()) { imgVirtue.Disabled = true; } gridToolBar = new Grid() { ColumnSpacing = 20, Padding = 5, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(.20, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(.20, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(.20, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(.20, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(.20, GridUnitType.Star) }, }, BackgroundColor = Color.FromHex("#189597"), }; gridToolBar.Children.Add(imgAzkar, 0, 0); gridToolBar.Children.Add(imgAhkam, 1, 0); gridToolBar.Children.Add(imgMistakes, 2, 0); gridToolBar.Children.Add(imgVirtue, 3, 0); gridToolBar.Children.Add(imgFavorite, 4, 0); }
protected async void InitializeControls() { Image imgMedia; Label lblDescription; Grid gridTextLayout; Grid gridToolBar; Grid gridMedia; ///////////////////////////////////////////////////// // Media Area show media wheather it's video or image ///////////////////////////////////////////////////// string imageUri = postData.GetImageUri(); imgMedia = new Image { Aspect = Aspect.AspectFit, Source = imageUri, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = ZadSpecialDesigen.DefaultNoneImageColor, }; // /*//////////////////////////////////////////////////////////////////////////////////////// gridMedia = new Grid() { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, ColumnSpacing = 0, RowSpacing = 0, BackgroundColor = Color.Black, RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } }, ColumnDefinitions = { new ColumnDefinition { BindingContext = new GridLength(1, GridUnitType.Star) } }, }; /// if media type is audio or video initialize webview with source if (postData.DataType == DataType.Video || postData.DataType == DataType.Audio) { if (webViewPlayer == null) //for first time { webViewPlayer = new WebView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Source = await GetHTMLWebViewSource(), }; } else { webViewPlayer.Source = await GetHTMLWebViewSource(); } var webStackLayout = new StackLayout { BackgroundColor = Color.Black, Children = { webViewPlayer }, }; gridMedia.Children.Add(webStackLayout); } else { gridMedia.Children.Add(imgMedia); } ///////////////////////////////////////////////////// // Text Area for title and description (Paragraph) ///////////////////////////////////////////////////// lblDescription = new Label() { Text = postData.Description, FontSize = ZadSpecialDesigen.GetFontSizeOfDescription(), XAlign = TextAlignment.End, YAlign = TextAlignment.Start, TextColor = Color.FromHex("#666666"), BackgroundColor = Color.White }; StackLayout descriptionLayout = new StackLayout { Padding = ZadSpecialDesigen.GetPaddingOfDescription(), }; descriptionLayout.Children.Add(lblDescription); gridTextLayout = new Grid() { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowSpacing = 0, ColumnSpacing = 0, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto }, }, BackgroundColor = Color.White }; gridTextLayout.Children.Add( new TitleIconStackLayout(postData.Title, this.TitleIconUri, Color.FromHex("#F0F4F5"), Color.FromHex("#19716B")) , 0, 0); gridTextLayout.Children.Add(descriptionLayout, 0, 1); ///////////////////////////////////////////////////// // Footer ToolBar Area for shared and favorite ///////////////////////////////////////////////////// var imgShare = new ClickableImage { Source = DEFAULT_ICON_SHARE, }; imgFavorite = new ClickableImage { Source = Helper.GetUnFavoriteIconUri(), }; imgShare.Clicked += ImgShare_Clicked; imgFavorite.Clicked += ImgFavorite_Clicked; gridToolBar = new Grid() { RowSpacing = 0, VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = new GridLength(.1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(.1, GridUnitType.Star) }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(30, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(20, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(20, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(30, GridUnitType.Star) }, }, BackgroundColor = Color.FromHex("#199595"), }; gridToolBar.Children.Add(imgFavorite, 1, 1); gridToolBar.Children.Add(imgShare, 2, 1); //////////////////////////////////////////////////////////// ///////////////////// Main grid ////////////////////////// ////////////////////////////////////////////////////////// var scrollview = new ScrollView { Content = gridTextLayout, }; Grid MainGrid = new Grid() { Padding = new Thickness(0, -6, 0, 0), HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, ColumnSpacing = 0, RowSpacing = 0, RowDefinitions = { new RowDefinition { Height = new GridLength(0.46, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(0.46, GridUnitType.Star) }, new RowDefinition { Height = new GridLength(0.08, GridUnitType.Star) }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } } }; MainGrid.Children.Add(gridMedia, 0, 0); MainGrid.Children.Add(scrollview, 0, 1); MainGrid.Children.Add(gridToolBar, 0, 2); base.MainBodyScrollView.IsVisible = false; base.MainForAdjDataView.Children.Add(MainGrid); base.MainForAdjDataView.Padding = 0; base.MainForAdjDataView.Spacing = 0; if (postData.Description == null || postData.Description == "") // no content { gridTextLayout.Children.Add(Helper.NoContentLable); } }