feat: thumbnail image custom styles #232
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
There is now a new
customStyles
property that can be passed to the video player component:thumbnailImage
. This is required becausereact-native-video-player
uses theImageBackground
component fromreact-native
to render the thumbnail image. TheImageBackground
component has two separate props for styles:style
andimageStyle
. TheresizeMode
can only be passed to theImageBackground
component via theimageStyle
prop, not thestyle
prop (as it was being passed previously).NOTE: When using the
react-native-video-player
component in my app, I noticed that currently TypeScript incorrectly reports that the type ofcustomStyles.thumbnail
isImageStyle
, but it is actually defined asViewStyle
inindex.tsx
. I think that maybe theindex.d.ts
file needs to be generated again in order to make sure the types are correct in the npm package.fixes #231
Motivation
When I was using
react-native-video-player
in my app, I noticed that when I passedresizeMode
via thecustomStyles.thumbnail
prop, theresizeMode
was not being applied.Changes
customStyles.thumbnailImage
property and passed this to theThumbnail
ImageBackground
component asimageStyle
prop.customStyle.thumbnailImage
property.customStyles.thumbnailImage
to example app (resizeMode: 'cover'
).width
inonLayout
function insrc/index.ts
.Test plan
To manually test, run the example app and notice that the thumbnail covers the entire video container:
Then change
customStyles.thumbnailImage.resizeMode
to "contain", and notice that the thumbnail no longer covers the entire container:I don't think an automated test is required for this change.