public FeedCellBuilder(UIView contentView) { _contentView = contentView; _moreButton = new UIButton(); _moreButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst); _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal); //_moreButton.BackgroundColor = UIColor.Black; _contentView.AddSubview(_moreButton); _avatarImage = new UIImageView(new CGRect(leftMargin, 20, 30, 30)); _contentView.AddSubview(_avatarImage); var authorX = _avatarImage.Frame.Right + 10; _author = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _moreButton.Frame.Left - authorX, 18)); _author.Font = Constants.Semibold14; //_author.BackgroundColor = UIColor.Yellow; _author.LineBreakMode = UILineBreakMode.TailTruncation; _author.TextColor = Constants.R15G24B30; _contentView.AddSubview(_author); _timestamp = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _moreButton.Frame.Left - authorX, 16)); _timestamp.Font = Constants.Regular12; //_timestamp.BackgroundColor = UIColor.Green; _timestamp.LineBreakMode = UILineBreakMode.TailTruncation; _timestamp.TextColor = Constants.R151G155B158; _contentView.AddSubview(_timestamp); _photoScroll = new UIScrollView(); _photoScroll.ShowsHorizontalScrollIndicator = false; _photoScroll.Bounces = false; _photoScroll.PagingEnabled = true; _photoScroll.Scrolled += (sender, e) => { var pageWidth = _photoScroll.Frame.Size.Width; _pageControl.CurrentPage = (int)Math.Floor((_photoScroll.ContentOffset.X - pageWidth / 2) / pageWidth) + 1; }; contentView.AddSubview(_photoScroll); _pageControl = new UIPageControl(); _pageControl.Hidden = true; _pageControl.UserInteractionEnabled = false; contentView.AddSubview(_pageControl); _likes = new UILabel(); _likes.Font = Constants.Semibold14; _likes.LineBreakMode = UILineBreakMode.TailTruncation; _likes.TextColor = Constants.R15G24B30; _likes.UserInteractionEnabled = true; _contentView.AddSubview(_likes); _flags = new UILabel(); _flags.Font = Constants.Semibold14; //_flags.BackgroundColor = UIColor.Orange; _flags.LineBreakMode = UILineBreakMode.TailTruncation; _flags.TextColor = Constants.R15G24B30; _flags.UserInteractionEnabled = true; _contentView.AddSubview(_flags); _rewards = new UILabel(); _rewards.Font = Constants.Semibold14; //_rewards.BackgroundColor = UIColor.Orange; _rewards.LineBreakMode = UILineBreakMode.TailTruncation; _rewards.TextColor = Constants.R15G24B30; _rewards.UserInteractionEnabled = true; _contentView.AddSubview(_rewards); _like = new UIImageView(); _like.ContentMode = UIViewContentMode.Center; _contentView.AddSubview(_like); _verticalSeparator = new UIView(); _verticalSeparator.BackgroundColor = Constants.R244G244B246; _contentView.AddSubview(_verticalSeparator); _topSeparator = new UIView(); _topSeparator.BackgroundColor = Constants.R244G244B246; _contentView.AddSubview(_topSeparator); var _noLinkAttribute = new UIStringAttributes { Font = Constants.Regular14, ForegroundColor = Constants.R151G155B158, }; var at = new NSMutableAttributedString(); at.Append(new NSAttributedString("...", _noLinkAttribute)); _attributedLabel = new TTTAttributedLabel(); _attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link; var prop = new NSDictionary(); _attributedLabel.LinkAttributes = prop; _attributedLabel.ActiveLinkAttributes = prop; _attributedLabel.Font = Constants.Regular14; _attributedLabel.Lines = 3; _attributedLabel.UserInteractionEnabled = true; _attributedLabel.Enabled = true; _attributedLabel.AttributedTruncationToken = at; //_attributedLabel.BackgroundColor = UIColor.Blue; _contentView.AddSubview(_attributedLabel); _comments = new UILabel(); _comments.Font = Constants.Regular14; //_comments.BackgroundColor = UIColor.DarkGray; _comments.LineBreakMode = UILineBreakMode.TailTruncation; _comments.TextColor = Constants.R151G155B158; _comments.UserInteractionEnabled = true; _comments.TextAlignment = UITextAlignment.Center; _contentView.AddSubview(_comments); _bottomSeparator = new UIView(); _bottomSeparator.BackgroundColor = Constants.R244G244B246; _contentView.AddSubview(_bottomSeparator); _profileTapView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, likeButtonWidthConst)); _profileTapView.UserInteractionEnabled = true; _contentView.AddSubview(_profileTapView); _likersTapView = new UIView(); _likersTapView.UserInteractionEnabled = true; _contentView.AddSubview(_likersTapView); likersY = underPhotoPanelHeight / 2 - likersImageSide / 2; likersCornerRadius = likersImageSide / 2; var liketap = new UITapGestureRecognizer(LikeTap); _like.AddGestureRecognizer(liketap); _sliderView = new SliderView(UIScreen.MainScreen.Bounds.Width); _sliderView.LikeTap += () => { LikeTap(); }; BaseViewController.SliderAction += (isSliderOpening) => { if (_sliderView.Superview != null && !isSliderOpening) { _sliderView.Close(); } }; var likelongtap = new UILongPressGestureRecognizer((UILongPressGestureRecognizer obj) => { if (AppSettings.User.IsAuthenticated && !_currentPost.Vote) { if (obj.State == UIGestureRecognizerState.Began) { if (!BasePostPresenter.IsEnableVote || BaseViewController.IsSliderOpen) { return; } BaseViewController.IsSliderOpen = true; _sliderView.Show(_contentView); } } }); _like.AddGestureRecognizer(likelongtap); UITapGestureRecognizer tap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Preview, _currentPost); }); _photoScroll.AddGestureRecognizer(tap); var profileTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); var headerTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); _profileTapView.AddGestureRecognizer(headerTap); _rewards.AddGestureRecognizer(profileTap); var commentTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Comments, _currentPost); }); _comments.AddGestureRecognizer(commentTap); var netVotesTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Voters, _currentPost); }); _likersTapView.AddGestureRecognizer(netVotesTap); var flagersTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Flagers, _currentPost); }); _flags.AddGestureRecognizer(flagersTap); _moreButton.TouchDown += FlagButton_TouchDown; }
protected CommentTableViewCell(IntPtr handle) : base(handle) { _avatar = new UIImageView(); _avatar.ContentMode = UIViewContentMode.ScaleAspectFill; _avatar.Layer.CornerRadius = 15; _avatar.ClipsToBounds = true; ContentView.AddSubview(_avatar); _avatar.AutoSetDimensionsToSize(new CGSize(30, 30)); _avatar.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 15); _avatar.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 10); _loginLabel = new UILabel(); _loginLabel.Font = Constants.Semibold14; ContentView.AddSubview(_loginLabel); _loginLabel.AutoPinEdge(ALEdge.Left, ALEdge.Right, _avatar, 10); _loginLabel.AutoAlignAxis(ALAxis.Horizontal, _avatar); _timestamp = new UILabel(); _timestamp.Font = Constants.Regular12; _timestamp.TextColor = Constants.R151G155B158; ContentView.AddSubview(_timestamp); _timestamp.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 14); _timestamp.AutoPinEdge(ALEdge.Left, ALEdge.Right, _loginLabel); _timestamp.SetContentHuggingPriority(251, UILayoutConstraintAxis.Horizontal); _timestamp.AutoAlignAxis(ALAxis.Horizontal, _avatar); _commentText = new UITextView(); _commentText.Editable = false; _commentText.ScrollEnabled = false; _commentText.Font = Constants.Regular14; _commentText.BackgroundColor = UIColor.Clear; ContentView.AddSubview(_commentText); _commentText.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, _avatar); _commentText.AutoPinEdge(ALEdge.Left, ALEdge.Left, _avatar, -4); _like = new UIImageView(); _like.ContentMode = UIViewContentMode.Center; _like.UserInteractionEnabled = true; ContentView.AddSubview(_like); _like.AutoSetDimensionsToSize(new CGSize(40, 50)); _like.AutoAlignAxis(ALAxis.Horizontal, _commentText); _like.AutoPinEdge(ALEdge.Left, ALEdge.Right, _commentText); _like.AutoPinEdge(ALEdge.Right, ALEdge.Right, _timestamp, 11); _profileTapView = new UIView(); _profileTapView.UserInteractionEnabled = true; ContentView.AddSubview(_profileTapView); _profileTapView.AutoPinEdgeToSuperviewEdge(ALEdge.Left); _profileTapView.AutoPinEdgeToSuperviewEdge(ALEdge.Top); _profileTapView.AutoPinEdge(ALEdge.Right, ALEdge.Right, _loginLabel); _profileTapView.AutoPinEdge(ALEdge.Bottom, ALEdge.Top, _commentText); _bottomView = new UIStackView(); _bottomView.Axis = UILayoutConstraintAxis.Horizontal; _bottomView.Distribution = UIStackViewDistribution.Fill; _bottomView.Alignment = UIStackViewAlignment.Leading; _bottomView.Spacing = 19; ContentView.AddSubview(_bottomView); _bottomView.AutoSetDimension(ALDimension.Height, 50); _bottomView.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom); _bottomView.AutoPinEdge(ALEdge.Left, ALEdge.Left, _avatar); _bottomView.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, _commentText); _bottomView.AutoPinEdge(ALEdge.Right, ALEdge.Right, _timestamp); _replyLabel = new UILabel(); _replyLabel.Text = "Reply"; _replyLabel.Font = Constants.Regular12; _replyLabel.TextColor = Constants.R151G155B158; _replyLabel.UserInteractionEnabled = true; _bottomView.AddArrangedSubview(_replyLabel); _replyLabel.SetContentHuggingPriority(251, UILayoutConstraintAxis.Horizontal); _replyLabel.SetContentCompressionResistancePriority(750, UILayoutConstraintAxis.Horizontal); _likesLabel = new UILabel(); _likesLabel.Font = Constants.Regular12; _likesLabel.TextColor = Constants.R151G155B158; _likesLabel.UserInteractionEnabled = true; _bottomView.AddArrangedSubview(_likesLabel); _likesLabel.SetContentHuggingPriority(251, UILayoutConstraintAxis.Horizontal); _flagsLabel = new UILabel(); _flagsLabel.Font = Constants.Regular12; _flagsLabel.TextColor = Constants.R151G155B158; _flagsLabel.UserInteractionEnabled = true; _bottomView.AddArrangedSubview(_flagsLabel); _flagsLabel.SetContentHuggingPriority(251, UILayoutConstraintAxis.Horizontal); _costLabel = new UILabel(); _costLabel.Font = Constants.Regular12; _costLabel.Hidden = true; #if DEBUG _costLabel.Hidden = false; #endif _costLabel.TextColor = Constants.R151G155B158; _bottomView.AddArrangedSubview(_costLabel); _costLabel.SetContentHuggingPriority(251, UILayoutConstraintAxis.Horizontal); var hugView = new UIView(); _bottomView.AddArrangedSubview(hugView); hugView.SetContentHuggingPriority(250, UILayoutConstraintAxis.Horizontal); var tap = new UITapGestureRecognizer(() => { if (SwipeState == MGSwipeState.None) { CellAction?.Invoke(ActionType.Profile, _currentPost); } }); var costTap = new UITapGestureRecognizer(() => { if (SwipeState == MGSwipeState.None) { CellAction?.Invoke(ActionType.Profile, _currentPost); } }); var replyTap = new UITapGestureRecognizer(() => { if (SwipeState == MGSwipeState.None) { CellAction?.Invoke(ActionType.Reply, _currentPost); } }); var likersTap = new UITapGestureRecognizer(() => { if (SwipeState == MGSwipeState.None) { CellAction?.Invoke(ActionType.Voters, _currentPost); } }); var flagersTap = new UITapGestureRecognizer(() => { if (SwipeState == MGSwipeState.None) { CellAction?.Invoke(ActionType.Flagers, _currentPost); } }); _replyLabel.AddGestureRecognizer(replyTap); _profileTapView.AddGestureRecognizer(tap); _costLabel.AddGestureRecognizer(costTap); _likesLabel.AddGestureRecognizer(likersTap); _flagsLabel.AddGestureRecognizer(flagersTap); var liketap = new UITapGestureRecognizer(LikeTap); _like.AddGestureRecognizer(liketap); _sliderView = new SliderView(UIScreen.MainScreen.Bounds.Width); _sliderView.LikeTap += () => { LikeTap(); }; BaseViewController.SliderAction += (isSliderOpening) => { if (_sliderView.Superview != null && !isSliderOpening) { RightButtons = rigthButtons; _sliderView.Close(); } }; var likelongtap = new UILongPressGestureRecognizer((UILongPressGestureRecognizer obj) => { if (AppSettings.User.IsAuthenticated && !_currentPost.Vote) { if (obj.State == UIGestureRecognizerState.Began) { if (!BasePostPresenter.IsEnableVote || BaseViewController.IsSliderOpen) { return; } rigthButtons = RightButtons; RightButtons = new UIView[0]; _sliderView.Frame = new CGRect(4, ContentView.Frame.Height / 2 - 35, UIScreen.MainScreen.Bounds.Width - 8, 70); BaseViewController.IsSliderOpen = true; _sliderView.Show(this); } } }); _like.AddGestureRecognizer(likelongtap); RightSwipeSettings.Transition = MGSwipeTransition.Border; deleteButton = MGSwipeButton.ButtonWithTitle("", UIImage.FromBundle("ic_delete"), UIColor.FromRGB(250, 250, 250), 26, (tableCell) => { CellAction?.Invoke(ActionType.Delete, _currentPost); return(true); }); editButton = MGSwipeButton.ButtonWithTitle("", UIImage.FromBundle("ic_edit"), UIColor.FromRGB(250, 250, 250), 26, (arg0) => { CellAction?.Invoke(ActionType.Edit, _currentPost); _currentPost.Editing = true; ContentView.BackgroundColor = UIColor.FromRGB(255, 235, 143).ColorWithAlpha(0.5f); return(true); }); flagButton = MGSwipeButton.ButtonWithTitle("", UIImage.FromBundle("ic_flag"), UIColor.FromRGB(250, 250, 250), 26, (arg0) => { CellAction?.Invoke(ActionType.Flag, _currentPost); return(true); }); }
protected SliderFeedCollectionViewCell(IntPtr handle) : base(handle) { _contentView = ContentView; _closeButton = new UIButton(); _closeButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst); _closeButton.SetImage(UIImage.FromBundle("ic_close_black"), UIControlState.Normal); //_closeButton.BackgroundColor = UIColor.Yellow; _contentView.AddSubview(_closeButton); _moreButton = new UIButton(); _moreButton.Frame = new CGRect(_closeButton.Frame.Left - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst); _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal); //_moreButton.BackgroundColor = UIColor.Black; _contentView.AddSubview(_moreButton); _avatarImage = new UIImageView(); _avatarImage.Frame = new CGRect(leftMargin, 20, 30, 30); _contentView.AddSubview(_avatarImage); authorX = _avatarImage.Frame.Right + 10; _author = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _closeButton.Frame.Left - authorX, 18)); _author.Font = Constants.Semibold14; //_author.BackgroundColor = UIColor.Yellow; _author.LineBreakMode = UILineBreakMode.TailTruncation; _author.TextColor = Constants.R15G24B30; _contentView.AddSubview(_author); _timestamp = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _closeButton.Frame.Left - authorX, 16)); _timestamp.Font = Constants.Regular12; //_timestamp.BackgroundColor = UIColor.Green; _timestamp.LineBreakMode = UILineBreakMode.TailTruncation; _timestamp.TextColor = Constants.R151G155B158; _contentView.AddSubview(_timestamp); _contentScroll = new UIScrollView(); _contentScroll.Frame = new CGRect(0, _avatarImage.Frame.Bottom + 20, _contentView.Frame.Width, _contentView.Frame.Height - (_avatarImage.Frame.Bottom + 20)); _contentScroll.ShowsVerticalScrollIndicator = false; _contentScroll.Bounces = false; //_contentScroll.BackgroundColor = UIColor.LightGray; _contentView.AddSubview(_contentScroll); _photoScroll = new UIScrollView(); _photoScroll.ShowsHorizontalScrollIndicator = false; _photoScroll.Bounces = false; _photoScroll.PagingEnabled = true; _photoScroll.Scrolled += (sender, e) => { var pageWidth = _photoScroll.Frame.Size.Width; _pageControl.CurrentPage = (int)Math.Floor((_photoScroll.ContentOffset.X - pageWidth / 2) / pageWidth) + 1; }; _photoScroll.Layer.CornerRadius = 10; _contentScroll.AddSubview(_photoScroll); _pageControl = new UIPageControl(); _pageControl.Hidden = true; _pageControl.UserInteractionEnabled = false; _contentScroll.AddSubview(_pageControl); _likes = new UILabel(); _likes.Font = Constants.Semibold14; _likes.LineBreakMode = UILineBreakMode.TailTruncation; _likes.TextColor = Constants.R15G24B30; _likes.UserInteractionEnabled = true; _contentScroll.AddSubview(_likes); //_likes.BackgroundColor = UIColor.Purple; _flags = new UILabel(); _flags.Font = Constants.Semibold14; //_flags.BackgroundColor = UIColor.Orange; _flags.LineBreakMode = UILineBreakMode.TailTruncation; _flags.TextColor = Constants.R15G24B30; _flags.UserInteractionEnabled = true; _contentScroll.AddSubview(_flags); _rewards = new UILabel(); _rewards.Font = Constants.Semibold14; //_rewards.BackgroundColor = UIColor.Orange; _rewards.LineBreakMode = UILineBreakMode.TailTruncation; _rewards.TextColor = Constants.R15G24B30; _rewards.UserInteractionEnabled = true; _contentScroll.AddSubview(_rewards); _like = new UIImageView(); _like.ContentMode = UIViewContentMode.Center; //_like.BackgroundColor = UIColor.Orange; _contentScroll.AddSubview(_like); _verticalSeparator = new UIView(); _verticalSeparator.BackgroundColor = Constants.R244G244B246; _contentScroll.AddSubview(_verticalSeparator); _topSeparator = new UIView(); _topSeparator.BackgroundColor = Constants.R244G244B246; _contentScroll.AddSubview(_topSeparator); _comments = new UILabel(); _comments.Font = Constants.Regular14; //_comments.BackgroundColor = UIColor.DarkGray; _comments.LineBreakMode = UILineBreakMode.TailTruncation; _comments.TextColor = Constants.R151G155B158; _comments.UserInteractionEnabled = true; _comments.TextAlignment = UITextAlignment.Center; _contentScroll.AddSubview(_comments); _bottomSeparator = new UIView(); _bottomSeparator.BackgroundColor = Constants.R244G244B246; _contentScroll.AddSubview(_bottomSeparator); _profileTapView = new UIView(new CGRect(0, 0, _contentView.Frame.Width / 2, likeButtonWidthConst)); _profileTapView.UserInteractionEnabled = true; _contentView.AddSubview(_profileTapView); _likersTapView = new UIView(); _likersTapView.UserInteractionEnabled = true; _contentScroll.AddSubview(_likersTapView); likersY = underPhotoPanelHeight / 2 - likersImageSide / 2; likersCornerRadius = likersImageSide / 2; var liketap = new UITapGestureRecognizer(LikeTap); _like.AddGestureRecognizer(liketap); _sliderView = new SliderView(_contentScroll.Frame.Width); _sliderView.LikeTap += () => { LikeTap(); }; BaseViewController.SliderAction += (isOpening) => { if (_sliderView.Superview != null && !isOpening) { _sliderView.Close(); } }; var likelongtap = new UILongPressGestureRecognizer((UILongPressGestureRecognizer obj) => { if (AppSettings.User.HasPostingPermission && !_currentPost.Vote) { if (obj.State == UIGestureRecognizerState.Began) { if (!BasePostPresenter.IsEnableVote) { return; } BaseViewController.IsSliderOpen = true; _sliderView.Show(_contentScroll); } } }); _like.AddGestureRecognizer(likelongtap); UITapGestureRecognizer tap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Preview, _currentPost); }); _photoScroll.AddGestureRecognizer(tap); var profileTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); var headerTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Profile, _currentPost); }); _profileTapView.AddGestureRecognizer(headerTap); _rewards.AddGestureRecognizer(profileTap); var commentTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Comments, _currentPost); }); _comments.AddGestureRecognizer(commentTap); var netVotesTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Voters, _currentPost); }); _likersTapView.AddGestureRecognizer(netVotesTap); var flagersTap = new UITapGestureRecognizer(() => { CellAction?.Invoke(ActionType.Flagers, _currentPost); }); _flags.AddGestureRecognizer(flagersTap); _moreButton.TouchDown += FlagButton_TouchDown; _closeButton.TouchDown += Close_TouchDown; }