예제 #1
0
        void ReleaseDesignerOutlets()
        {
            if (ActivityDescription != null)
            {
                ActivityDescription.Dispose();
                ActivityDescription = null;
            }

            if (ActivityLogo != null)
            {
                ActivityLogo.Dispose();
                ActivityLogo = null;
            }

            if (ActivityTitle != null)
            {
                ActivityTitle.Dispose();
                ActivityTitle = null;
            }

            if (CancelButton != null)
            {
                CancelButton.Dispose();
                CancelButton = null;
            }

            if (ContinueButton != null)
            {
                ContinueButton.Dispose();
                ContinueButton = null;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyboardUpNotification);

            ActivityTitle.ShouldReturn          += TextFieldShouldReturn;
            ActivityTitle.EditingDidBegin       += TextFieldEditingDidBegin;
            ActivityDescription.ShouldReturn    += TextFieldShouldReturn;
            ActivityDescription.EditingDidBegin += TextFieldEditingDidBegin;

            // Limit how long the title and description strings can be
            ActivityTitle.ShouldChangeCharacters += (textField, range, replacementString) =>
            {
                var newLength = textField.Text.Length + replacementString.Length - range.Length;
                return(newLength <= 36 || (replacementString.Length - range.Length <= 0));
            };

            ActivityDescription.ShouldChangeCharacters += (textField, range, replacementString) =>
            {
                var newLength = textField.Text.Length + replacementString.Length - range.Length;
                return(newLength <= 128 || (replacementString.Length - range.Length <= 0));
            };

            UITapGestureRecognizer tapGestureRecognizer =
                new UITapGestureRecognizer(() => View.EndEditing(true));

            View.AddGestureRecognizer(tapGestureRecognizer);

            UITapGestureRecognizer imageTapGesture = new UITapGestureRecognizer(ImageTapped)
            {
                NumberOfTapsRequired = 1
            };

            ActivityLogo.UserInteractionEnabled = true;
            ActivityLogo.AddGestureRecognizer(imageTapGesture);

            folderPath = Common.LocalData.Storage.GetCacheFolder("created");

            if (thisActivity != null)
            {
                // Load previously entered data into fields
                ActivityTitle.Text       = thisActivity.Name;
                ActivityDescription.Text = thisActivity.Description;
                if (!string.IsNullOrWhiteSpace(thisActivity.ImageUrl))
                {
                    previousImagePath = thisActivity.ImageUrl;
                    Console.WriteLine("Existing image path: " + previousImagePath);

                    if (thisActivity.ImageUrl.StartsWith("upload"))
                    {
                        ImageService.Instance.LoadUrl(ServerUtils.GetUploadUrl(previousImagePath))
                        .Transform(new CircleTransformation())
                        .Into(ActivityLogo);
                    }
                    else
                    {
                        string url = AppUtils.GetPathForLocalFile(previousImagePath);

                        var suppress = ImageService.Instance.InvalidateCacheEntryAsync(url, FFImageLoading.Cache.CacheType.All, true);
                        ImageService.Instance.LoadFile(url).Transform(new CircleTransformation()).Into(ActivityLogo);
                    }
                }
            }

            ContinueButton.TouchUpInside += ContinuePressed;
            CancelButton.TouchUpInside   += CancelPressed;
        }