Esempio n. 1
0
        public ChatInputView()
        {
            TextView                    = new UITextView();
            TextView.Changed           += OnTextChanged;
            TextView.Started           += OnTextChanged;
            TextView.Ended             += OnTextChanged;
            TextView.Layer.BorderColor  = InputBorderColor.CGColor;
            TextView.Layer.BorderWidth  = BorderWidth;
            TextView.Layer.CornerRadius = CornerRadius;
            TextView.BackgroundColor    = InputBackgroundColor;
            TextView.TranslatesAutoresizingMaskIntoConstraints = false;

            TextView.ScrollIndicatorInsets  = new UIEdgeInsets(CornerRadius, 0, CornerRadius, 0);
            TextView.TextContainerInset     = new UIEdgeInsets(4, 2, 4, 2);
            TextView.ContentInset           = new UIEdgeInsets(1, 0, 1, 0);
            TextView.ScrollEnabled          = true;
            TextView.ScrollsToTop           = false;
            TextView.UserInteractionEnabled = true;
            TextView.Font          = UIFont.SystemFontOfSize(16);
            TextView.TextAlignment = UITextAlignment.Natural;
            TextView.ContentMode   = UIViewContentMode.Redraw;


            SendButton = new SendButton();
            SendButton.SetImage(UIImage.FromBundle("sendTextIcon"), UIControlState.Normal);
            SendButton.TranslatesAutoresizingMaskIntoConstraints = false;

            AddSubviews(TextView, SendButton);

            var c1 = NSLayoutConstraint.FromVisualFormat("H:|-[input]-[button]-|",
                                                         NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                         "input", TextView,
                                                         "button", SendButton
                                                         );
//			var c2 = NSLayoutConstraint.FromVisualFormat ("V:|-[input]-|",
//				NSLayoutFormatOptions.DirectionLeadingToTrailing,
//				"input", TextView
//			);
//			AddConstraints (c2);
            var top = NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 7);
            var bot = NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1, -7);

            AddConstraint(top);
            AddConstraint(bot);
            // We want Send button was centered when Toolbar has MinHeight (pin button in this state)
            var c3 = NSLayoutConstraint.Create(SendButton, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1, -ToolbarMinHeight / 2);

            AddConstraints(c1);
            AddConstraint(c3);
        }
Esempio n. 2
0
		public ChatInputView()
		{
			TextView = new UITextView ();
			TextView.Changed += OnTextChanged;
			TextView.Started += OnTextChanged;
			TextView.Ended += OnTextChanged;
			TextView.Layer.BorderColor = InputBorderColor.CGColor;
			TextView.Layer.BorderWidth = BorderWidth;
			TextView.Layer.CornerRadius = CornerRadius;
			TextView.BackgroundColor = InputBackgroundColor;
			TextView.TranslatesAutoresizingMaskIntoConstraints = false;

			TextView.ScrollIndicatorInsets = new UIEdgeInsets (CornerRadius, 0, CornerRadius, 0);
			TextView.TextContainerInset = new UIEdgeInsets (4, 2, 4, 2);
			TextView.ContentInset = new UIEdgeInsets (1, 0, 1, 0);
			TextView.ScrollEnabled = true;
			TextView.ScrollsToTop = false;
			TextView.UserInteractionEnabled = true;
			TextView.Font = UIFont.SystemFontOfSize (16);
			TextView.TextAlignment = UITextAlignment.Natural;
			TextView.ContentMode = UIViewContentMode.Redraw;


			SendButton = new SendButton ();
			SendButton.SetImage (UIImage.FromBundle ("sendTextIcon"), UIControlState.Normal);
			SendButton.TranslatesAutoresizingMaskIntoConstraints = false;

			AddSubviews (TextView, SendButton);

			var c1 = NSLayoutConstraint.FromVisualFormat ("H:|-[input]-[button]-|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"input", TextView,
				"button", SendButton
			);
//			var c2 = NSLayoutConstraint.FromVisualFormat ("V:|-[input]-|",
//				NSLayoutFormatOptions.DirectionLeadingToTrailing,
//				"input", TextView
//			);
//			AddConstraints (c2);
			var top = NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 7);
			var bot = NSLayoutConstraint.Create(TextView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1, -7);
			AddConstraint (top);
			AddConstraint (bot);
			// We want Send button was centered when Toolbar has MinHeight (pin button in this state)
			var c3 = NSLayoutConstraint.Create(SendButton, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1, -ToolbarMinHeight / 2);
			AddConstraints (c1);
			AddConstraint (c3);
		}
Esempio n. 3
0
        public void ViewDidLoad(UIViewController viewController)
        {
            SendButton.TintColor = StyleHelper.Style.ButtonTintColor;
            SendButton.SetImage(UIImage.FromBundle(StyleHelper.Style.SendBundleName), UIControlState.Normal);
            SendButton.SetCommand(new RelayCommand(OnRaiseSend));

            AttachImageButton.TintColor = StyleHelper.Style.ButtonTintColor;
            AttachImageButton.SetImage(UIImage.FromBundle(StyleHelper.Style.AddImageBundleName), UIControlState.Normal);
            AttachImageButton.SetCommand(new RelayCommand(OnAddPhotoClicked));

            TakePhotoButton.TintColor = StyleHelper.Style.ButtonTintColor;
            TakePhotoButton.SetImage(UIImage.FromBundle(StyleHelper.Style.TakePhotoBundleName), UIControlState.Normal);
            TakePhotoButton.SetCommand(new RelayCommand(OnTakePhotoClicked));

            RemoveAttachButton.SetImage(UIImage.FromBundle(StyleHelper.Style.RemoveAttachBundleName),
                                        UIControlState.Normal);
            RemoveAttachButton.SetCommand(new RelayCommand(OnRemovePhotoClicked));

            AttachedImageView.Layer.MasksToBounds = false;
            AttachedImageView.Layer.CornerRadius  = 5;
            AttachedImageView.ClipsToBounds       = true;
            AttachedImageView.ContentMode         = UIViewContentMode.ScaleAspectFill;

            EditImageContainer.Hidden = true;
            EditImageContainerHeightConstraint.Constant = 0;

            _simpleImagePicker = new SimpleImagePicker(viewController,
                                                       Dependencies.Container.Resolve <IPermissionsManager>(), false);
            _attachedImageBinding = this.SetBinding(() => _simpleImagePicker.ViewModel.ImageCacheKey).WhenSourceChanges(
                () =>
            {
                if (string.IsNullOrEmpty(_simpleImagePicker.ViewModel.ImageCacheKey))
                {
                    CloseAttachPanel();
                    return;
                }

                OpenAttachPanel();
            });
            _simpleImagePicker.SetCommand(nameof(_simpleImagePicker.PickerWillOpen),
                                          new RelayCommand(RaisePickerWillOpen));
        }