Skip to content
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

#3019 move pointerEvents style from Image to View for Avatar #3129

Merged
Prev Previous commit
Next Next commit
#3019 apply styling guidelines
  • Loading branch information
dklymenk committed May 26, 2021
commit 0ac88b195839f7d59dcd7c5f9bb0c91a50d85f00
14 changes: 11 additions & 3 deletions src/components/Avatar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'underscore';
import React, {PureComponent} from 'react';
import {Image, View} from 'react-native';
import PropTypes from 'prop-types';
Expand All @@ -8,7 +9,10 @@ const propTypes = {
source: PropTypes.string,

/** Extra styles to pass */
styles: PropTypes.arrayOf(PropTypes.object),
style: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.object),
PropTypes.object,
]),

/** Extra styles to pass to View wrapper */
containerStyles: PropTypes.arrayOf(PropTypes.object),
Expand All @@ -19,7 +23,7 @@ const propTypes = {

const defaultProps = {
source: '',
styles: [],
style: [],
containerStyles: [],
size: 'default',
};
Expand All @@ -30,13 +34,17 @@ class Avatar extends PureComponent {
return null;
}

const propsStyle = _.isArray(this.props.style)
? this.props.style
: [this.props.style];

return (
<View style={[...this.props.containerStyles, styles.avatarWrapper]}>
<Image
source={{uri: this.props.source}}
style={[
this.props.size === 'small' ? styles.avatarSmall : styles.avatarNormal,
...this.props.styles,
...propsStyle,
]}
/>
</View>
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarWithIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class AvatarWithIndicator extends PureComponent {
style={[this.props.size === 'large' ? styles.avatarLarge : styles.sidebarAvatar]}
>
<Avatar
styles={[this.props.size === 'large' ? styles.avatarLarge : null]}
style={[this.props.size === 'large' ? styles.avatarLarge : null]}
source={this.props.source}
/>
<Animated.View style={StyleSheet.flatten(indicatorStyles)}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const DetailsPage = ({personalDetails, route, translate}) => {
<View style={styles.pageWrapper}>
<Avatar
containerStyles={[styles.avatarLarge, styles.mb3]}
styles={[styles.avatarLarge]}
style={[styles.avatarLarge]}
source={details.avatar}
/>
<Text style={[styles.displayName, styles.mt1, styles.mb6]} numberOfLines={1}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemSingle.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ReportActionItemSingle = ({
return (
<View style={wrapperStyles}>
<Avatar
styles={[styles.actionAvatar]}
style={[styles.actionAvatar]}
source={avatarUrl}
/>
<View style={[styles.chatItemRight]}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Profile/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class ProfilePage extends Component {
/>
<ScrollView style={styles.flex1} contentContainerStyle={styles.p5}>
<Avatar
styles={[styles.avatarLarge, styles.alignSelfCenter]}
style={[styles.avatarLarge, styles.alignSelfCenter]}
source={this.props.myPersonalDetails.avatar}
/>
<AttachmentPicker>
Expand Down