xotahal / react-native-material-ui

Highly customizable material design components for React Native
MIT License
3.78k stars 609 forks source link

Avatar image mask not working? #451

Closed schystz closed 5 years ago

schystz commented 5 years ago

When setting the image prop of Avatar, the image is not masked to the circle background. I am expecting something like this:

Screen Shot 2019-07-29 at 12 28 58 AM

...but I am getting this instead:

Screen Shot 2019-07-29 at 12 25 21 AM

Below is my the code for the above screenshot.

<Avatar style={{ container: { alignSelf: 'center' } }} image={this.avatarImage()} size={100} />

private avatarImage() {
    return (
      <Image
        style={{ width: 80, height: 80 }}
        source={{ uri: this.props.store.user.picture }}
      />
    )
  }

Is the masking not supported at the moment? Otherwise, can you please let me know how to achieve it? Thank you!

schystz commented 5 years ago

Simply applied a border radius to the Image and that gets the result I expected:

<Image
        style={{ width: 100, height: 100, borderRadius: 50 }}
        source={{ uri: this.props.store.user. picture }}
      />