Skip to content

Feat/Image - custom overlay #616

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

Merged
merged 18 commits into from
Jan 13, 2020
Merged

Feat/Image - custom overlay #616

merged 18 commits into from
Jan 13, 2020

Conversation

ArnonZ
Copy link
Contributor

@ArnonZ ArnonZ commented Jan 12, 2020

  • Added support for rendering a custom overlay for Image component (can be stacked with already supported overlays).

/**
* Custom overlay content to be rendered on top of the image
*/
customContent: PropTypes.func
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better define it as an element prop type

@@ -44,22 +48,32 @@ export default class Overlay extends PureBaseComponent {
}
}

renderCustomContent = () => {
const {customContent} = this.props;
return <View style={styles.customContent}>{customContent()}</View>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better pass pointerEvents to the wrapping View to avoid touch block

return (
<View style={[styles.container]}>
{this.renderImage(styles.top)}
{this.renderImage(styles.bottom)}
{customContent && this.renderCustomContent()}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you render the custom content too many times, in this example

<Image
          customOverlay={() => <View><Text>A</Text></View> }
          overlayType={'vertical'}
          style={{width: 100, height: 100}}
          source={{
            uri:
              'https://images.pexels.com/photos/3326362/pexels-photo-3326362.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500'
          }}
        />

it will be rendered 3 times.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooooooh weeeeee...

return (
<Image
style={{
position: 'absolute',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving this big style chunk to a stylesheet

/**
* Render an overlay with custom content
*/
customOverlay: PropTypes.func
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming to customOverlayContent cause customOverlay sounds like you can provide custom gradient overlay

@ArnonZ ArnonZ requested a review from ethanshar January 12, 2020 22:23
<View style={styles.container}>
{type && <Image style={[styles.container, typeStyle]} resizeMode={'stretch'} source={image}/>}
{customContent && this.renderCustomContent()}
<View pointerEvents="none" style={styles.customContent}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use box-none so the next custom content won't be blocked


if (type === OVERLY_TYPES.VERTICAL) {
return (
<View style={[styles.container]}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using Fragment (<>) instead of the container View for both Vertical case and the other case

@ethanshar ethanshar merged commit 7d08c13 into master Jan 13, 2020
@ethanshar ethanshar deleted the feat/custom_overlay branch May 17, 2020 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants