Ejemplo n.º 1
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));
        }