Skip to content

Commit

Permalink
Merge pull request #7933 from Expensify/revert-7723-feat/7584-image-p…
Browse files Browse the repository at this point in the history
…laceholder

(cherry picked from commit 88735de)
  • Loading branch information
roryabraham authored and OSBotify committed Feb 28, 2022
1 parent cbaa328 commit 57bc125
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions src/components/ImageWithSizeCalculation.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, {PureComponent} from 'react';
import {Image, ActivityIndicator} from 'react-native';
import {Image} from 'react-native';
import PropTypes from 'prop-types';
import Log from '../libs/Log';
import styles from '../styles/styles';
import makeCancellablePromise from '../libs/MakeCancellablePromise';
import themeColors from '../styles/themes/default';

const propTypes = {
/** Url for image to display */
Expand All @@ -30,14 +29,6 @@ const defaultProps = {
* it can be appropriately resized.
*/
class ImageWithSizeCalculation extends PureComponent {
constructor(props) {
super(props);

this.state = {
isLoading: true,
};
}

componentDidMount() {
this.calculateImageSize();
}
Expand Down Expand Up @@ -94,26 +85,15 @@ class ImageWithSizeCalculation extends PureComponent {

render() {
return (
<>
<Image
style={[
styles.w100,
styles.h100,
this.state.isLoading && styles.dNone,
this.props.style,
]}
source={{uri: this.props.url}}
resizeMode="contain"
onLoadEnd={() => this.setState({isLoading: false})}
/>
{this.state.isLoading && (
<ActivityIndicator
size="large"
style={[styles.flex1]}
color={themeColors.textSupporting}
/>
)}
</>
<Image
style={[
styles.w100,
styles.h100,
this.props.style,
]}
source={{uri: this.props.url}}
resizeMode="contain"
/>
);
}
}
Expand Down

0 comments on commit 57bc125

Please sign in to comment.