Closed frosty closed 2 years ago
Thanks for the comment @SergioEstevao! So in the case where a camera capture header and a custom header are enabled, only the custom header will display.
In my upcoming PR for WordPress-iOS, I've only added the permissions alert to screens that don't currently use the capture cell – Media Library +, Gutenberg, Stories. In the other areas, we could just add "Take a photo" to the action sheet that appears before displaying the media picker and not use the capture cell there any more. This may actually be clearer for the user and is would be more consistent across the app.
This PR adds support for custom header views in the media picker collection view. This will be used in WordPress-iOS to show an info panel at the top of the picker if a user has only provided limited access to their photo library.
Three methods have been added to the media picker delegate protocol:
mediaPickerController(_:configureCustomHeaderView:)
mediaPickerControllerReferenceSizeForCustomHeaderView(_:)
mediaPickerControllerShouldShowCustomHeaderView(_:)
These in combination allow a delegate to control whether a custom header view is displayed, configure the view if necessary before it's displayed, and provide a reference size which will be used to display the view at the correct size.
In order for these to have an effect, the custom header type must be registered using a new method on
WPMediaPickerViewController
:registerClassForCustomHeaderView(_:)
. The class must be a subclass ofUICollectionReusableView
.I've added an option to the demo app to show an example custom header:
There are a few small caveats around the current implementation:
To test
configureCustomHeaderView
delegate method (the demo header class has a red background on initialization).