Skip to content

Commit

Permalink
Align android image style / source logic with ios
Browse files Browse the repository at this point in the history
  • Loading branch information
danilobuerger committed Sep 10, 2022
1 parent 4e70376 commit 884018a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Libraries/Image/Image.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ export type ImageComponentStatics = $ReadOnly<{|
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
* LTI update could not be added via codemod */
const BaseImage = (props: ImagePropsType, forwardedRef) => {
let source = getImageSourcesFromImageProps(props);
let source = getImageSourcesFromImageProps(props) || {
uri: undefined,
width: undefined,
height: undefined,
};
const defaultSource = resolveAssetSource(props.defaultSource);
const loadingIndicatorSource = resolveAssetSource(
props.loadingIndicatorSource,
Expand All @@ -147,22 +151,19 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => {
);
}

if (source && !source.uri && !Array.isArray(source)) {
source = null;
}

let style;
let sources;
if (!Array.isArray(source) && source?.uri != null) {
if (Array.isArray(source)) {
style = flattenStyle([styles.base, props.style]) || {};
sources = source;
} else {
const {width = props.width, height = props.height, uri} = source;
style = flattenStyle([{width, height}, styles.base, props.style]);
sources = [{uri: uri, width: width, height: height}];
style = flattenStyle([{width, height}, styles.base, props.style]) || {};
sources = [source];

if (uri === '') {
console.warn('source.uri should not be an empty string');
}
} else {
style = flattenStyle([styles.base, props.style]);
sources = source;
}

const {height, width, ...restProps} = props;
Expand Down

0 comments on commit 884018a

Please sign in to comment.