public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { var commentCell = collectionView.DequeueReusableCell(CommentViewController.commentCellId, indexPath) as CommentCell; var imageView = commentCell.GetImageView(); imageView.Image = UIImage.FromBundle("Profile"); if (!string.IsNullOrEmpty(comments[indexPath.Row].profilePicture)) { Utils.SetImageFromNSUrlSession(comments[indexPath.Row].profilePicture, imageView, this, PictureType.Profile); } commentCell.surveyCommentModel = comments[indexPath.Row]; commentCell.UpdateCell(comments[indexPath.Row].userName, comments[indexPath.Row].text, comments[indexPath.Row].commentDate, commentViewController.NavigationController, comments[indexPath.Row].userId); var longPress = new UICommentLongPressGestureRecognizer(commentViewController, new Selector("HandleLongPressSelector:")); longPress.Params = new List <object>() { comments[indexPath.Row] }; commentCell.AddGestureRecognizer(longPress); if (comments[indexPath.Row].userLiked == true) { commentCell.updateLikeButton(false); } else if (comments[indexPath.Row].userLiked == null || comments[indexPath.Row].userLiked == false) { commentCell.updateLikeButton(true); } commentCell.updateLikeCount(comments[indexPath.Row].totalLikes); return(commentCell); }
private void HandleLongPressSelector(UICommentLongPressGestureRecognizer gestureRecognizer) { if (gestureRecognizer.State == UIGestureRecognizerState.Began) { View.EndEditing(true); this.comment = (SurveyCommentModel)gestureRecognizer.Params.ToArray()[0]; commentAction = UIAlertController.Create("Comment Menu", "Select your action", UIAlertControllerStyle.ActionSheet); if (commentAction.Actions.Count() <= 0) { if (!this.comment.userId.Equals(LoginController.userModel.id))// not comment owner { commentAction.AddAction(UIAlertAction.Create("Report Comment", UIAlertActionStyle.Destructive, alert => ReportComment())); commentAction.AddAction(UIAlertAction.Create("Report Comment User", UIAlertActionStyle.Destructive, alert => ReportCommentUser())); } else { commentAction.AddAction(UIAlertAction.Create("Delete Comment", UIAlertActionStyle.Destructive, alert => DeleteCommentSelector())); } commentAction.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null)); } var mainWindow = UIApplication.SharedApplication.KeyWindow; var viewController = mainWindow?.RootViewController; while (viewController?.PresentedViewController != null) { viewController = viewController.PresentedViewController; } if (viewController == null) { viewController = this; } viewController.PresentViewController(commentAction, true, null); } }