async void CommentButtonTapped(object sender, EventArgs e) { //show comments popup try { progressBar.ShowProgressbar("Loading comments"); List<Comment> comments = await PurposeColor.Service.ServiceHelper.GetComments(CurrentGemId, CurrentGemType, false); progressBar.HideProgressbar(); PurposeColor.screens.CommentsView commentsView = new PurposeColor.screens.CommentsView(masterLayout, comments, CurrentGemId, CurrentGemType, false, commentsLabel); commentsView.ClassId = Constants.COMMENTS_VIEW_CLASS_ID; commentsView.HeightRequest = App.screenHeight; commentsView.WidthRequest = App.screenWidth; masterLayout.AddChildToLayout(commentsView, 0, 0); } catch (Exception ex) { progressBar.HideProgressbar(); DisplayAlert(Constants.ALERT_TITLE, "Could not fetch comments, Please try again later.", Constants.ALERT_OK); } progressBar.HideProgressbar(); }
async void OnCommentButtonTapped(object sender, EventArgs e) { //show comments popup try { string gemID = ""; Image commentImg = sender as Image; Label commentLabel = sender as Label; if (commentImg != null) { if (commentImg.ClassId != null) gemID = commentImg.ClassId; } if (commentLabel != null) { if (commentLabel.ClassId != null) gemID = commentLabel.ClassId; } if( !string.IsNullOrEmpty( gemID ) ) { string[] delimiters = { "&&" }; string[] clasIDArray = gemID.Split(delimiters, StringSplitOptions.None); string selectedGemID = clasIDArray [0]; string selectedGemType = clasIDArray [1]; GemType currentGemType = GetGemType( selectedGemType ); progressBar.ShowProgressbar("Loading comments"); List<Comment> comments = await PurposeColor.Service.ServiceHelper.GetComments(selectedGemID, currentGemType, true); progressBar.HideProgressbar(); PurposeColor.screens.CommentsView commentsView = new PurposeColor.screens.CommentsView(masterLayout, comments, selectedGemID, currentGemType, true, commentLabel); commentsView.ClassId = Constants.COMMENTS_VIEW_CLASS_ID; commentsView.HeightRequest = App.screenHeight; commentsView.WidthRequest = App.screenWidth; masterLayout.AddChildToLayout(commentsView, 0, 0); } } catch (Exception ex) { progressBar.HideProgressbar(); DisplayAlert(Constants.ALERT_TITLE, "Could not fetch comments, Please try again later.", Constants.ALERT_OK); } progressBar.HideProgressbar(); }