public override void WillDisplayAssetItem(ImagePickerController controller, ImagePickerAssetCell cell, PHAsset asset) { switch (cell) { case var _ when cell is CustomVideoCell videoCell: videoCell.Label.Text = GetDurationFormatter().StringFromTimeInterval(asset.Duration); break; case var _ when cell is CustomImageCell imageCell: switch (asset.MediaSubtypes) { case PHAssetMediaSubtype.PhotoLive: imageCell.SubtypeImage.Image = UIImage.FromBundle("icon-live"); break; case PHAssetMediaSubtype.PhotoPanorama: imageCell.SubtypeImage.Image = UIImage.FromBundle("icon-pano"); break; default: { if (UIDevice.CurrentDevice.CheckSystemVersion(10, 2) && asset.MediaSubtypes == PHAssetMediaSubtype.PhotoDepthEffect) { imageCell.SubtypeImage.Image = UIImage.FromBundle("icon-depth"); } break; } } break; } }
private void PresentPickerModally(ImagePickerController vc) { _openedAsInputView = false; vc.NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Dismiss", UIBarButtonItemStyle.Done, DismissPresentedImagePicker); var nc = new UINavigationController(vc); PresentViewController(nc, true, null); }
private void PresentPickerAsInputView(ImagePickerController vc) { //if you want to present view as input view, you have to set flexible height //to adopt natural keyboard height or just set an layout constraint height //for specific height. vc.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight; _currentInputView = vc.View; _openedAsInputView = true; ReloadInputViews(); }
private void PresentButtonTapped(object sender, EventArgs e) { _presentButton.Selected = !_presentButton.Selected; if (!_presentButton.Selected) { UpdateNavigationItem(0); _imagePicker.Release(); _currentInputView = null; ReloadInputViews(); return; } _imagePicker = _imagePickerConfigurationHandlerClass.CreateImagePicker(); _imagePickerController = new ImagePickerControllerDelegate() { DidSelectActionItemAction = DidSelectActionItemAt, DidDeselectAssetAction = UpdateSelectedItems, DidSelectAssetAction = UpdateSelectedItems }; _imagePicker.Delegate = _imagePickerController; _imagePicker.DataSource = _imagePickerControllerDataSource; // presentation // before we present VC we can ask for authorization to photo library, // if we don't do it now, Image Picker will ask for it automatically // after it's presented. PHPhotoLibrary.RequestAuthorization(handler => { DispatchQueue.MainQueue.DispatchAsync(() => { // we can present VC regardless of status because we support // non granted states in Image Picker. Please check `ImagePickerControllerDataSource` // for more info. if (_imagePickerConfigurationHandlerClass.PresentsModally) { _imagePicker.LayoutConfiguration.ScrollDirection = UICollectionViewScrollDirection.Vertical; PresentPickerModally(_imagePicker); } else { _imagePicker.LayoutConfiguration.ScrollDirection = UICollectionViewScrollDirection.Horizontal; PresentPickerAsInputView(_imagePicker); } }); }); }
public override void WillDisplayActionItem(ImagePickerController controller, UICollectionViewCell cell, int index) { if (cell is IconWithTextCell iconWithTextCell) { iconWithTextCell.TitleLabel.TextColor = UIColor.Black; switch (index) { case 0: iconWithTextCell.TitleLabel.Text = "Camera"; iconWithTextCell.ImageView.Image = UIImageExtensions.FromBundle(BundleAssets.ButtonCamera); break; case 1: iconWithTextCell.TitleLabel.Text = "Photos"; iconWithTextCell.ImageView.Image = UIImageExtensions.FromBundle(BundleAssets.ButtonPhotoLibrary); break; } } }
public override void DidDeselectAsset(ImagePickerController controller, PHAsset asset) { DidDeselectAssetAction?.Invoke(controller.SelectedAssets); }
public override void DidSelectActionItemAt(ImagePickerController controller, int index) { DidSelectActionItemAction?.Invoke(index); }
/// <summary> /// Called right before an asset item collection view cell is displayed. Use this method /// to configure your cell based on asset media type, subtype, etc. /// </summary> /// <param name="controller">Controller.</param> /// <param name="cell">Cell.</param> /// <param name="asset">Asset.</param> public virtual void WillDisplayAssetItem(ImagePickerController controller, ImagePickerAssetCell cell, PHAsset asset) { }
/// <summary> /// Called right before an action item collection view cell is displayed. Use this method /// to configure your cell. /// </summary> /// <param name="controller">Controller.</param> /// <param name="cell">Cell.</param> /// <param name="index">Index.</param> public virtual void WillDisplayActionItem(ImagePickerController controller, UICollectionViewCell cell, int index) { }
/// <summary> /// Called when user unselect previously selected asset. /// </summary> /// <param name="controller">Controller.</param> /// <param name="asset">Asset.</param> public virtual void DidDeselectAsset(ImagePickerController controller, PHAsset asset) { }
/// <summary> /// Called when user taps on an action item, index is either 0 or 1 depending which was tapped /// </summary> /// <param name="controller">Controller.</param> /// <param name="index">Index.</param> public virtual void DidSelectActionItemAt(ImagePickerController controller, int index) { }