public override void ViewDidLoad() { base.ViewDidLoad(); commentTextView.Layer.BorderColor = Helpers.Constants.R244G244B246.CGColor; commentTextView.Layer.BorderWidth = 1f; commentTextView.Layer.CornerRadius = 20f; commentTextView.TextContainerInset = new UIEdgeInsets(10, 20, 10, 15); commentTextView.Font = Helpers.Constants.Regular14; _commentsTextViewDelegate = new CommentsTextViewDelegate(); commentTextView.Delegate = _commentsTextViewDelegate; sendButton.Layer.BorderColor = Helpers.Constants.R244G244B246.CGColor; sendButton.Layer.BorderWidth = 1f; sendButton.Layer.CornerRadius = sendButton.Frame.Width / 2; sendButton.TouchDown += CreateComment; _tableSource = new CommentsTableViewSource(_presenter, Post); _tableSource.CellAction += CellAction; _tableSource.TagAction += TagAction; commentsTable.Bounces = false; commentsTable.Source = _tableSource; commentsTable.LayoutMargins = UIEdgeInsets.Zero; commentsTable.RegisterClassForCellReuse(typeof(DescriptionTableViewCell), nameof(DescriptionTableViewCell)); commentsTable.RegisterNibForCellReuse(UINib.FromName(nameof(DescriptionTableViewCell), NSBundle.MainBundle), nameof(DescriptionTableViewCell)); commentsTable.RegisterClassForCellReuse(typeof(CommentTableViewCell), nameof(CommentTableViewCell)); commentsTable.RegisterNibForCellReuse(UINib.FromName(nameof(CommentTableViewCell), NSBundle.MainBundle), nameof(CommentTableViewCell)); commentsTable.RowHeight = UITableView.AutomaticDimension; commentsTable.EstimatedRowHeight = 150f; Offset = 0; Activeview = bottomView; if (Post.Children == 0) { OpenKeyboard(); } SetPlaceholder(); SetBackButton(); GetComments(); }
private void CreateView() { _commentTextView = new UITextView(); _commentTextView.Layer.BorderColor = Helpers.Constants.R244G244B246.CGColor; _commentTextView.Layer.BorderWidth = 1f; _commentTextView.Layer.CornerRadius = 20f; _commentTextView.TextContainerInset = new UIEdgeInsets(10, 20, 10, 15); _commentTextView.Font = Constants.Regular14; _commentTextView.Bounces = false; _commentTextView.ShowsVerticalScrollIndicator = false; _commentsTextViewDelegate = new CommentsTextViewDelegate(); _commentsTextViewDelegate.ChangedAction += (gh) => { _commentViewHeight.Constant = _commentTextViewHeight.Constant = gh; if (_postToEdit != null && _postToEdit.Editing) { _saveButton.Enabled = _postToEdit.Body != _commentTextView.Text; } }; _commentTextView.Delegate = _commentsTextViewDelegate; _sendButton = new UIButton(); _sendButton.Layer.BorderColor = Constants.R244G244B246.CGColor; _sendButton.Layer.BorderWidth = 1f; _sendButton.Layer.CornerRadius = 20f; _sendButton.SetImage(UIImage.FromBundle("ic_send_comment"), UIControlState.Normal); _sendButton.TouchDown += CreateComment; _sendProgressBar = new UIActivityIndicatorView(); _sendProgressBar.Color = Constants.R231G72B0; _sendProgressBar.HidesWhenStopped = true; _commentView = new UIStackView(new UIView[] { _commentTextView, _sendButton, _sendProgressBar }); _commentView.Alignment = UIStackViewAlignment.Center; _commentView.Spacing = 10; _sendProgressBar.AutoSetDimension(ALDimension.Width, 40); _sendProgressBar.AutoSetDimension(ALDimension.Height, 40); var backgroundView = new UIView(); backgroundView.TranslatesAutoresizingMaskIntoConstraints = false; _commentView.InsertSubview(backgroundView, 0); backgroundView.AutoPinEdgesToSuperviewEdges(); _sendButton.AutoSetDimension(ALDimension.Width, 40); _sendButton.AutoSetDimension(ALDimension.Height, 40); _commentsTable = new UITableView(); _rootView = new UIStackView(new UIView[] { _commentsTable, _commentView }); _rootView.Axis = UILayoutConstraintAxis.Vertical; View.AddSubview(_rootView); _rootView.AutoPinEdgeToSuperviewEdge(ALEdge.Top); if (DeviceModel.Model(DeviceHardware.HardwareModel) == "iPhone10,6") { _rootView.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom, 34); } else { _rootView.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom); } _rootView.AutoPinEdgeToSuperviewEdge(ALEdge.Left); _rootView.AutoPinEdgeToSuperviewEdge(ALEdge.Right); _commentTextViewHeight = _commentTextView.AutoSetDimension(ALDimension.Height, 40, NSLayoutRelation.GreaterThanOrEqual); _commentViewHeight = _commentView.AutoSetDimension(ALDimension.Height, 40, NSLayoutRelation.GreaterThanOrEqual); _commentView.LayoutMargins = new UIEdgeInsets(10, 15, 10, 15); _commentView.LayoutMarginsRelativeArrangement = true; _saveButton = new UIButton(); _saveButton.SetTitle("Save", UIControlState.Normal); _saveButton.SetTitleColor(UIColor.FromRGB(255, 44, 5), UIControlState.Normal); _saveButton.TouchDown += SaveTap; _saveButton.Layer.BorderColor = Constants.R244G244B246.CGColor; _saveButton.Layer.BorderWidth = 1f; _saveButton.Layer.CornerRadius = 20f; _saveButton.Font = Constants.Semibold14; _editProgressBar = new UIActivityIndicatorView(); _editProgressBar.Color = Constants.R231G72B0; _editProgressBar.HidesWhenStopped = true; _cancelButton = new UIButton(); _cancelButton.SetTitle("Cancel", UIControlState.Normal); _cancelButton.SetTitleColor(UIColor.Black, UIControlState.Normal); _cancelButton.TouchDown += CancelTap; _cancelButton.Layer.BorderColor = Constants.R244G244B246.CGColor; _cancelButton.Layer.BorderWidth = 1f; _cancelButton.Layer.CornerRadius = 20f; _cancelButton.Font = Constants.Regular14; _buttonsContainer = new UIStackView(new UIView[] { _cancelButton, _saveButton, _editProgressBar }); _buttonsContainer.AutoSetDimension(ALDimension.Height, 50); _buttonsContainer.Spacing = 15; _buttonsContainer.Distribution = UIStackViewDistribution.FillEqually; _buttonsContainer.LayoutMargins = new UIEdgeInsets(0, 15, 10, 15); _buttonsContainer.LayoutMarginsRelativeArrangement = true; _buttonsContainer.Hidden = true; _rootView.AddArrangedSubview(_buttonsContainer); _tableProgressBar = new UIActivityIndicatorView(); _tableProgressBar.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge; _tableProgressBar.Color = Constants.R231G72B0; _tableProgressBar.HidesWhenStopped = true; _rootView.AddSubview(_tableProgressBar); _tableProgressBar.AutoAlignAxis(ALAxis.Horizontal, _commentsTable); _tableProgressBar.AutoAlignAxis(ALAxis.Vertical, _commentsTable); }