async void ProfileSettingsPage_Appearing (object sender, EventArgs e) { progressBar.ShowProgressbar ("Retriving user details.."); if(userIdForProfileInfo > 0) { await GetProfileInfo (); } galleryInput = new Image() { Source = Device.OnPlatform("icn_gallery.png", "icn_gallery.png", "//Assets//icn_gallery.png"), Aspect = Aspect.AspectFit }; if (Device.OS == TargetPlatform.WinPhone) { galleryInput.WidthRequest = App.screenWidth * ICON_SIZE / 100; galleryInput.HeightRequest = App.screenWidth * ICON_SIZE / 100; } galleryInputStack = new StackLayout { Padding = new Thickness(5, 10, 5, 10), Spacing = 0, Children = { galleryInput } }; galleryInputStack.ClassId = "gallery"; galleryInputStackTapRecognizer = new TapGestureRecognizer(); galleryInputStack.GestureRecognizers.Add(galleryInputStackTapRecognizer); galleryInputStackTapRecognizer.Tapped += async (se, ee) => { try { StackLayout send = se as StackLayout; SourceChooser chooser = new SourceChooser(masterLayout, send.ClassId, this); chooser.ClassId = "mediachooser"; masterLayout.AddChildToLayout(chooser, 0, 0); } catch (Exception ex) { var test = ex.Message; } }; mainTitleBar.imageAreaTapGestureRecognizer.Tapped += imageAreaTapGestureRecognizer_Tapped; masterLayout.AddChildToLayout(mainTitleBar, 0, 0); masterLayout.AddChildToLayout(subTitleBar, 0, 10); statusEntry = new CustomEntry { Placeholder = "Status note", HeightRequest = Device.OnPlatform(50, 50, 75), BackgroundColor = Constants.PAGE_BG_COLOR_LIGHT_GRAY, TextColor = Color.Black, WidthRequest = App.screenWidth * 80 / 100, }; statusLabel = new Label { TextColor = Color.Black, HeightRequest = Device.OnPlatform (50, 50, 75), //WidthRequest = App.screenWidth * 80 / 100, HorizontalOptions = LayoutOptions.Center, FontSize = App.screenDensity >= 2 ? 18 : 15, XAlign = TextAlignment.Center }; if(!string.IsNullOrEmpty(userInfo.StatusNote)) { statusLabel.Text = userInfo.StatusNote.Trim (); } profilePic = new Image { Source = Constants.SERVICE_BASE_URL + (!string.IsNullOrEmpty(userInfo.ProfileImageUrl)? userInfo.ProfileImageUrl : "admin/uploads/default/noprofile.png"), HeightRequest = 110, WidthRequest = 100, Aspect = Aspect.AspectFill, HorizontalOptions = LayoutOptions.End }; if (userIdForProfileInfo <= 0 || userIdForProfileInfo.ToString () == currentUser.UserId) // display info of current logged in user. { #region Profile image tap TapGestureRecognizer profileImageTapRecognizer = new TapGestureRecognizer (); profileImageTapRecognizer.Tapped += ProfileImage_Tapped; profilePic.GestureRecognizers.Add (profileImageTapRecognizer); #endregion #region Ststus entry if (userInfo.StatusNote != null) { statusEntry.Text = userInfo.StatusNote.Trim (); } else { statusEntry.Text = "Please provide your status message.."; } statusEntry.Completed += StatusEntry_Completed; #endregion #region Community Sharing CommunitySharingLabel = new Label { Text = "Share to community", FontSize = App.screenDensity >= 2 ? 15 : 12, TextColor = Color.Gray, }; communityShareIcon = new Image (); communityStatusBtn = new StackLayout (); communityStatusBtn.WidthRequest = 50; communityStatusBtn.HeightRequest = 50; communityStatusBtn.BackgroundColor = Color.Transparent; communityStatusBtn.VerticalOptions = LayoutOptions.Center; //communityShareIcon.IsEnabled = false; if (currentUser.AllowCommunitySharing) { communityShareIcon.Source = Device.OnPlatform ("tic_active.png", "tic_active.png", "//Assets//tic_active.png"); } else { communityShareIcon.Source = Device.OnPlatform ("tick_box.png", "tick_box.png", "//Assets//tick_box.png"); } communityShareIcon.Aspect = Aspect.AspectFill; communityShareIcon.WidthRequest = 20; communityShareIcon.HeightRequest = 20; communityShareIcon.ClassId = "Cshare"; communityShareIcon.HorizontalOptions = LayoutOptions.Center; communityShareIcon.VerticalOptions = LayoutOptions.End; //communityShareIcon.TranslationY = 15; communityStatusBtn.Children.Add (communityShareIcon); communityShareTap = new TapGestureRecognizer (); communityShareTap.Tapped += UpdateShareToCommunityStatus; communityStatusBtn.GestureRecognizers.Add (communityShareTap); masterLayout.AddChildToLayout (CommunitySharingLabel, 10, 65); masterLayout.AddChildToLayout (communityStatusBtn, Device.OnPlatform(55,50,50), 65); #endregion #region Allow Follow Label followLabel = new Label { Text = "Allow others to follow", FontSize = App.screenDensity >= 2 ? 15 : 12, TextColor = Color.Gray, }; allowFollowIcon = new Image (); if (currentUser.AllowFollowers) { allowFollowIcon.Source = Device.OnPlatform ("tic_active.png", "tic_active.png", "//Assets//tic_active.png"); } else { allowFollowIcon.Source = Device.OnPlatform ("tick_box.png", "tick_box.png", "//Assets//tick_box.png"); } allowFollowIcon.Aspect = Aspect.AspectFill; allowFollowIcon.WidthRequest = 20; allowFollowIcon.HeightRequest = 20; allowFollowIcon.HorizontalOptions = LayoutOptions.Center; allowFollowIcon.VerticalOptions = LayoutOptions.End; followStatusBtn = new StackLayout (); followStatusBtn.WidthRequest = 50; followStatusBtn.HeightRequest = 50; followStatusBtn.BackgroundColor = Color.Transparent; followStatusBtn.VerticalOptions = LayoutOptions.Center; followStatusBtn.Children.Add (allowFollowIcon); followIconTap = new TapGestureRecognizer (); followIconTap.Tapped += UpdateFollowStatus; followStatusBtn.GestureRecognizers.Add (followIconTap); masterLayout.AddChildToLayout (followLabel, 10, 70); masterLayout.AddChildToLayout (followStatusBtn, Device.OnPlatform(55,50,50), 70); #endregion statusEntry.IsVisible = true; statusLabel.IsVisible = false; } else { statusEntry.IsVisible = false; //statusEntry.BackgroundColor = Constants.PAGE_BG_COLOR_LIGHT_GRAY; statusLabel.IsVisible = true; statusEntry.IsEnabled = false; if (userInfo.StatusNote != null) { statusEntry.Text = userInfo.StatusNote.Trim (); } else { statusEntry.IsVisible = false; } } profilePic.ClassId = "camera"; masterLayout.AddChildToLayout(profilePic, 35, 20); Label userDisplayName = new Label { Text = !string.IsNullOrEmpty (userInfo.DisplayName) ? userInfo.DisplayName : (!string.IsNullOrEmpty (userInfo.UserName) ? userInfo.UserName : ""), //WidthRequest = App.screenWidth * 0.80, HorizontalOptions = LayoutOptions.Center, XAlign = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, FontSize = App.screenDensity >= 2 ? 20 : 15, TextColor = Color.Black, FontAttributes = FontAttributes.Bold }; Label emailLabel = new Label { Text = !string.IsNullOrEmpty (userInfo.Email) ? userInfo.Email : "", //WidthRequest = App.screenWidth * 0.50, HorizontalOptions = LayoutOptions.Center, XAlign = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, FontSize = App.screenDensity >= 2 ? 12 : 10, TextColor = Color.Gray, FontAttributes = FontAttributes.None }; Image verifiedBadge = new Image { Source = "verified_icon.png", HeightRequest = App.screenHeight * .05, WidthRequest = App.screenWidth * .05, HorizontalOptions = LayoutOptions.Start, BackgroundColor = Color.Transparent, IsVisible = userInfo.VerifiedStatus != 0 }; StackLayout nameEmailStack = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.Center, WidthRequest = App.screenWidth * 0.80, Spacing = 3, Children = {new StackLayout{ Spacing = 2,Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Center, Children = {userDisplayName, verifiedBadge}}, emailLabel, new StackLayout{Children = {statusLabel}, Padding = 10, HorizontalOptions = LayoutOptions.Center, Orientation = StackOrientation.Vertical} } }; int xpos = 62; if (App.screenDensity > 2) { xpos = 64; masterLayout.AddChildToLayout (nameEmailStack, 10, 40); masterLayout.AddChildToLayout (statusEntry, 10, 50); //masterLayout.AddChildToLayout (statusLabel, 10, 50); } else { masterLayout.AddChildToLayout(nameEmailStack,10, 42); masterLayout.AddChildToLayout(statusEntry, 10, 52); //masterLayout.AddChildToLayout (statusLabel, 10, 52); } Content = masterLayout; progressBar.HideProgressbar (); }
async void ProfileImage_Tapped (object sender, EventArgs e) { try { // show image selection options. string id = (sender as Image).ClassId; SourceChooser chooser = new SourceChooser(masterLayout, id, this); chooser.ClassId = "mediachooser"; masterLayout.AddChildToLayout(chooser, 0, 0); } catch (Exception ex) { DisplayAlert("Camera", ex.Message + " Please try again later", "ok"); } }