Skip to content

Commit

Permalink
Merge pull request #9345 from Expensify/OSBotify-cherry-pick-staging-…
Browse files Browse the repository at this point in the history
…9343

🍒 Cherry pick PR #9343 to staging 🍒
  • Loading branch information
OSBotify authored Jun 7, 2022
2 parents 7802867 + 4e51cca commit 35ec65a
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 52 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001017301
versionName "1.1.73-1"
versionCode 1001017302
versionName "1.1.73-2"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.1.73.1</string>
<string>1.1.73.2</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.1.73.1</string>
<string>1.1.73.2</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.1.73-1",
"version": "1.1.73-2",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ const ImageRenderer = (props) => {
Config.EXPENSIFY.URL_API_ROOT,
);

const imageWidth = htmlAttribs['data-expensify-width'] ? parseInt(htmlAttribs['data-expensify-width'], 10) : undefined;
const imageHeight = htmlAttribs['data-expensify-height'] ? parseInt(htmlAttribs['data-expensify-height'], 10) : undefined;

return (
<AttachmentModal
allowDownload
Expand All @@ -63,8 +60,6 @@ const ImageRenderer = (props) => {
previewSourceURL={previewSource}
style={styles.webViewStyles.tagStyles.img}
isAuthTokenRequired={isAttachment}
imageWidth={imageWidth}
imageHeight={imageHeight}
/>
</PressableWithoutFocus>
)}
Expand Down
38 changes: 5 additions & 33 deletions src/components/ThumbnailImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,26 @@ const propTypes = {
/** Do the urls require an authToken? */
isAuthTokenRequired: PropTypes.bool.isRequired,

/** Width of the thumbnail image */
imageWidth: PropTypes.number,

/** Height of the thumbnail image */
imageHeight: PropTypes.number,

...windowDimensionsPropTypes,
};

const defaultProps = {
style: {},
imageWidth: 200,
imageHeight: 200,
};

class ThumbnailImage extends PureComponent {
constructor(props) {
super(props);

this.updateImageSize = this.updateImageSize.bind(this);
const {thumbnailWidth, thumbnailHeight} = this.calculateThumbnailImageSize(props.imageWidth, props.imageHeight);

this.state = {
thumbnailWidth,
thumbnailHeight,
thumbnailWidth: 200,
thumbnailHeight: 200,
};
}

/**
* Compute the thumbnails width and height given original image dimensions.
*
* @param {Number} width - Width of the original image.
* @param {Number} height - Height of the original image.
* @returns {Object} - Object containing thumbnails width and height.
*/
calculateThumbnailImageSize(width, height) {
if (!width || !height) {
return {};
}

updateImageSize({width, height}) {
// Width of the thumbnail works better as a constant than it does
// a percentage of the screen width since it is relative to each screen
// Note: Clamp minimum width 40px to support touch device
Expand All @@ -73,17 +54,8 @@ class ThumbnailImage extends PureComponent {
} else {
thumbnailScreenHeight = Math.round(thumbnailScreenWidth * aspectRatio);
}
return {thumbnailWidth: thumbnailScreenWidth, thumbnailHeight: Math.max(40, thumbnailScreenHeight)};
}

/**
* Update the state with the computed thumbnail sizes.
*
* @param {{ width: number, height: number }} Params - width and height of the original image.
*/
updateImageSize({width, height}) {
const {thumbnailWidth, thumbnailHeight} = this.calculateThumbnailImageSize(width, height);
this.setState({thumbnailWidth, thumbnailHeight});
this.setState({thumbnailWidth: thumbnailScreenWidth, thumbnailHeight: Math.max(40, thumbnailScreenHeight)});
}

render() {
Expand Down
26 changes: 18 additions & 8 deletions src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {memo} from 'react';
import {ActivityIndicator, View} from 'react-native';
import {ActivityIndicator, ImageBackground, View} from 'react-native';
import PropTypes from 'prop-types';
import Str from 'expensify-common/lib/str';
import reportActionFragmentPropTypes from './reportActionFragmentPropTypes';
Expand Down Expand Up @@ -72,18 +72,28 @@ const ReportActionItemFragment = (props) => {
// If this is an attachment placeholder, return the placeholder component
if (props.isAttachment && props.loading) {
return (
Str.isImage(props.attachmentInfo.name)
? (
<RenderHTML html={`<comment><img src="${props.attachmentInfo.source}"/></comment>`} />
) : (
<View style={[styles.chatItemAttachmentPlaceholder]}>
<View style={[styles.chatItemAttachmentPlaceholder]}>
{Str.isImage(props.attachmentInfo.name)
? (
<ImageBackground
source={{uri: props.attachmentInfo.source}}
resizeMode="cover"
imageStyle={[styles.borderBottomRounded, styles.borderTopRounded]}
style={[styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter]}
>
<ActivityIndicator
size="large"
color={themeColors.uploadPreviewActivityIndicator}
/>
</ImageBackground>
) : (
<ActivityIndicator
size="large"
color={themeColors.textSupporting}
style={[styles.flex1]}
/>
</View>
)
)}
</View>
);
}

Expand Down

0 comments on commit 35ec65a

Please sign in to comment.