Example #1
0
        public override void ViewWillAppear(bool animated)
        {
            if (!IsMovingToParentViewController)
            {
                collectionView.ReloadData();
            }
            if (CurrentPostCategory != null)
            {
                NavigationItem.Title = CurrentPostCategory;
                var leftBarButton = new UIBarButtonItem(UIImage.FromBundle("ic_back_arrow"), UIBarButtonItemStyle.Plain, GoBack);
                leftBarButton.TintColor          = Constants.R15G24B30;
                NavigationItem.LeftBarButtonItem = leftBarButton;
                NavigationController.SetNavigationBarHidden(false, false);

                searchHeight.Constant           = 0;
                searchTopMargin.Constant        = 0;
                sliderCollectionOffset.Constant = 0;
            }
            else
            {
                if (DeviceModel.Model(DeviceHardware.HardwareModel) == "iPhone10,6")
                {
                    sliderCollectionOffset.Constant = 35;
                }
                NavigationController.SetNavigationBarHidden(true, false);
            }

            base.ViewWillAppear(animated);
        }
        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);
        }
Example #3
0
 public string GetModel()
 {
     return(DeviceModel.Model(DeviceHardware.HardwareModel));
 }