void SelectImageFromGallery(ICardView target, string localUrl, string remoteUrl, string fileName,string cacheKey) { if (target == null) return; var vc = new GalleryImagePicker(); vc.Canceled += (sender, e) => { vc.DismissViewController(true, null); }; vc.FinishedPickingMedia += (object sender, UIImagePickerMediaPickedEventArgs e) => { switch (e.Info[UIImagePickerController.MediaType].ToString()) { case "public.image": Console.WriteLine("Image selected"); target.ToggleLoadingIndicators(true); UIImage editedImage = e.Info[UIImagePickerController.EditedImage] as UIImage; editedImage = ImageUtils.ScaledToSize(editedImage, new CGSize(200, 200)); var bytes = ImageUtils.ByteArrayFromImage(editedImage, 100); S3Utils.UploadPhoto(bytes,localUrl, remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.ClearDisk(); SDWebImageManager.SharedManager.ImageCache.ClearMemory(); Update(true); }, null); break; case "public.video": Console.WriteLine("Video selected"); break; } vc.DismissViewController(true, null); }; PresentViewController(vc, true, null); }
if (cardBack != null) cardBack.BindDataToView(SelectedCard, Editable); PerformFlipAnimationIfNecessary(); } public void PerformFlipAnimationIfNecessary() { var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).First(); var cardBack = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardBack)).First(); //animation not needed if (cardFront.Hidden == SelectedCard.IsFlipped) return; UIView.Transition(View, 0.5, UIViewAnimationOptions.TransitionFlipFromRight, () => { cardFront.Hidden = SelectedCard.IsFlipped; cardBack.Hidden = !SelectedCard.IsFlipped; }, null); } public void Flip() { if (SelectedCard == null) return; SelectedCard.Flip(); var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).First(); var cardBack = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardBack)).First(); UIView.Transition(View, 0.5, UIViewAnimationOptions.TransitionFlipFromRight, () => { cardFront.Hidden = SelectedCard.IsFlipped; cardBack.Hidden = !SelectedCard.IsFlipped; }, null); } void DownloadFacebookImage(ICardView target, string localUrl, string remoteUrl, string fileName, string cacheKey) { if (target == null) return; var me = RealmUserServices.GetMe(false); if (me == null) return; var url = me.GetFacebookProfilePictureUrl(); if (url == null) return; target.ToggleLoadingIndicators(true); SDWebImageManager.SharedManager.ImageDownloader.DownloadImage(NSUrl.FromString(url), SDWebImageDownloaderOptions.HighPriority, null, (image, data, error, finished) => { if (image == null || error != null) { target.ToggleLoadingIndicators(false); return; } var bytes = ImageUtils.ByteArrayFromImage(image, 100); S3Utils.UploadPhoto(bytes, localUrl,remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.RemoveImage(cacheKey, true, null); Update(true); }, null); }); }