private void CreateView() { GetPostSize(); SetImage(); var photoTitleSeparator = new UIView(); photoTitleSeparator.BackgroundColor = Constants.R245G245B245; titleTextField = new UITextView(); titleTextField.ScrollEnabled = false; titleTextField.Font = Constants.Semibold14; titleEditImage = new UIImageView(); titleEditImage.Image = UIImage.FromBundle("ic_edit"); var titleDescriptionSeparator = new UIView(); titleDescriptionSeparator.BackgroundColor = Constants.R245G245B245; descriptionTextField = new UITextView(); descriptionTextField.ScrollEnabled = false; descriptionTextField.Font = Constants.Regular14; descriptionEditImage = new UIImageView(); descriptionEditImage.Image = UIImage.FromBundle("ic_edit"); var descriptionHashtagSeparator = new UIView(); descriptionHashtagSeparator.BackgroundColor = Constants.R245G245B245; tagField = new UILabel(); tagField.Text = "Hashtag"; tagField.Font = Constants.Regular14; tagField.TextColor = Constants.R151G155B158; tagField.UserInteractionEnabled = true; var tap = new UITapGestureRecognizer(OpenTagPicker); tagField.AddGestureRecognizer(tap); hashtagImage = new UIImageView(); hashtagImage.Image = UIImage.FromBundle("ic_hash"); var hashtagCollectionSeparator = new UIView(); hashtagCollectionSeparator.BackgroundColor = Constants.R245G245B245; postPhotoButton = new UIButton(); postPhotoButton.SetTitle(AppSettings.LocalizationManager.GetText(LocalizationKeys.PublishButtonText), UIControlState.Normal); postPhotoButton.SetTitle("", UIControlState.Disabled); postPhotoButton.Layer.CornerRadius = 25; postPhotoButton.TitleLabel.Font = Constants.Semibold14; postPhotoButton.TouchDown += PostPhoto; loadingView = new UIActivityIndicatorView(); loadingView.Color = UIColor.White; loadingView.HidesWhenStopped = true; mainScroll.Bounces = false; mainScroll.AddSubview(photoTitleSeparator); mainScroll.AddSubview(titleTextField); mainScroll.AddSubview(titleEditImage); mainScroll.AddSubview(titleDescriptionSeparator); mainScroll.AddSubview(descriptionTextField); mainScroll.AddSubview(descriptionEditImage); mainScroll.AddSubview(descriptionHashtagSeparator); mainScroll.AddSubview(tagField); mainScroll.AddSubview(hashtagImage); mainScroll.AddSubview(hashtagCollectionSeparator); mainScroll.AddSubview(tagsCollectionView); mainScroll.AddSubview(postPhotoButton); mainScroll.AddSubview(loadingView); if (photoView != null) { photoTitleSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, photoView, 15f); } else { photoTitleSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, photoCollection, 15f); } photoTitleSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Left, _separatorMargin); photoTitleSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Right, _separatorMargin); photoTitleSeparator.AutoSetDimension(ALDimension.Height, 1f); photoTitleSeparator.AutoSetDimension(ALDimension.Width, UIScreen.MainScreen.Bounds.Width - _separatorMargin * 2); titleTextField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, photoTitleSeparator, 17f); titleTextField.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator, -5f); titleEditImage.AutoSetDimensionsToSize(new CGSize(18, 18)); titleEditImage.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator); titleEditImage.AutoPinEdge(ALEdge.Left, ALEdge.Right, titleTextField, 5f); titleEditImage.AutoAlignAxis(ALAxis.Horizontal, titleTextField); titleDescriptionSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, titleTextField, 17f); titleDescriptionSeparator.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator); titleDescriptionSeparator.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator); titleDescriptionSeparator.AutoSetDimension(ALDimension.Height, 1f); descriptionTextField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, titleDescriptionSeparator, 17f); descriptionTextField.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator, -5f); descriptionEditImage.AutoSetDimensionsToSize(new CGSize(18, 18)); descriptionEditImage.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator); descriptionEditImage.AutoPinEdge(ALEdge.Left, ALEdge.Right, descriptionTextField, 5f); descriptionEditImage.AutoAlignAxis(ALAxis.Horizontal, descriptionTextField); descriptionHashtagSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, descriptionTextField, 17f); descriptionHashtagSeparator.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator); descriptionHashtagSeparator.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator); descriptionHashtagSeparator.AutoSetDimension(ALDimension.Height, 1f); tagField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, descriptionHashtagSeparator); tagField.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator); tagField.AutoSetDimension(ALDimension.Height, 70f); hashtagImage.AutoSetDimensionsToSize(new CGSize(15, 17)); hashtagImage.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator); hashtagImage.AutoPinEdge(ALEdge.Left, ALEdge.Right, tagField, 5f); hashtagImage.AutoAlignAxis(ALAxis.Horizontal, tagField); hashtagCollectionSeparator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, tagField); hashtagCollectionSeparator.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator); hashtagCollectionSeparator.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator); hashtagCollectionSeparator.AutoSetDimension(ALDimension.Height, 1f); tagsCollectionView.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, hashtagCollectionSeparator, 25f); tagsCollectionView.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator); tagsCollectionView.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator); tagsCollectionHeight = tagsCollectionView.AutoSetDimension(ALDimension.Height, 0f); postPhotoButton.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, tagsCollectionView, 40f); postPhotoButton.AutoPinEdge(ALEdge.Left, ALEdge.Left, photoTitleSeparator); postPhotoButton.AutoPinEdge(ALEdge.Right, ALEdge.Right, photoTitleSeparator); postPhotoButton.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom, 35f); postPhotoButton.AutoSetDimension(ALDimension.Height, 50f); loadingView.AutoAlignAxis(ALAxis.Horizontal, postPhotoButton); loadingView.AutoAlignAxis(ALAxis.Vertical, postPhotoButton); }
protected void ShowCustomAlert(LocalizationKeys key, UIView viewToStartEditing) { var message = AppSettings.LocalizationManager.GetText(key); var popup = new UIView(); popup.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height); popup.BackgroundColor = UIColor.Black.ColorWithAlpha(0.5f); popup.UserInteractionEnabled = true; var blur = UIBlurEffect.FromStyle(UIBlurEffectStyle.ExtraLight); var blurView = new UIVisualEffectView(blur); blurView.ClipsToBounds = true; blurView.Layer.CornerRadius = 15; popup.AddSubview(blurView); blurView.AutoCenterInSuperview(); blurView.AutoSetDimension(ALDimension.Width, _alertWidth); var okButton = new UIButton(); okButton.SetTitle("Ok", UIControlState.Normal); okButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); blurView.ContentView.AddSubview(okButton); okButton.AutoPinEdge(ALEdge.Bottom, ALEdge.Bottom, blurView); okButton.AutoPinEdge(ALEdge.Left, ALEdge.Left, blurView); okButton.AutoPinEdge(ALEdge.Right, ALEdge.Right, blurView); okButton.AutoSetDimension(ALDimension.Height, 50); var textView = new UITextView(); textView.DataDetectorTypes = UIDataDetectorType.Link; textView.UserInteractionEnabled = true; textView.Editable = false; textView.Font = Constants.Semibold16; textView.TextAlignment = UITextAlignment.Center; textView.Text = message; textView.BackgroundColor = UIColor.Clear; blurView.ContentView.AddSubview(textView); textView.AutoPinEdge(ALEdge.Top, ALEdge.Top, blurView, 7); textView.AutoPinEdge(ALEdge.Left, ALEdge.Left, blurView, _textSideMargin); textView.AutoPinEdge(ALEdge.Right, ALEdge.Right, blurView, -_textSideMargin); var size = textView.SizeThatFits(new CGSize(_alertWidth - _textSideMargin * 2, 0)); textView.AutoSetDimension(ALDimension.Height, size.Height + 7); var separator = new UIView(); separator.BackgroundColor = UIColor.LightGray; blurView.ContentView.AddSubview(separator); separator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, textView, 0); separator.AutoPinEdge(ALEdge.Bottom, ALEdge.Top, okButton); separator.AutoPinEdge(ALEdge.Left, ALEdge.Left, blurView); separator.AutoPinEdge(ALEdge.Right, ALEdge.Right, blurView); separator.AutoSetDimension(ALDimension.Height, 1); ((InteractivePopNavigationController)NavigationController).IsPushingViewController = true; okButton.TouchDown += (sender, e) => { viewToStartEditing?.BecomeFirstResponder(); ((InteractivePopNavigationController)NavigationController).IsPushingViewController = false; popup.RemoveFromSuperview(); }; NavigationController.View.EndEditing(true); NavigationController.View.AddSubview(popup); blurView.Transform = CGAffineTransform.Scale(CGAffineTransform.MakeIdentity(), 0.001f, 0.001f); UIView.Animate(0.1, () => { blurView.Transform = CGAffineTransform.Scale(CGAffineTransform.MakeIdentity(), 1.1f, 1.1f); }, () => { UIView.Animate(0.1, () => { blurView.Transform = CGAffineTransform.Scale(CGAffineTransform.MakeIdentity(), 0.9f, 0.9f); }, () => { UIView.Animate(0.1, () => { blurView.Transform = CGAffineTransform.MakeIdentity(); }, null); }); }); }
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); }); }