-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom header views #379
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code wise is looking good, and the behaviour works as described, but I'm bit worried about this:
Because the 'capture cell' (displaying a live feed of the device's camera, allowing the user to capture an image) also uses a collection view header, it can't be used at the same time as a custom header.
What will happen in places where we have the camera capture header active? for example in the picker for your profile photo in the WP apps?
Will we need to update that picker to hide that away?
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).