Changeset View
Changeset View
Standalone View
Standalone View
native/media/multimedia.react.js
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | componentDidUpdate(prevProps: Props, prevState: State) { | ||||
} | } | ||||
} | } | ||||
render() { | render() { | ||||
const images = []; | const images = []; | ||||
const { currentSource, departingSource } = this.state; | const { currentSource, departingSource } = this.state; | ||||
if (departingSource) { | if (departingSource) { | ||||
images.push(this.renderSource(currentSource, true)); | images.push(this.renderSource(currentSource, true)); | ||||
images.push(this.renderSource(departingSource, true)); | images.push(this.renderSource(departingSource, false, false)); | ||||
} else { | } else { | ||||
images.push(this.renderSource(currentSource)); | images.push(this.renderSource(currentSource)); | ||||
} | } | ||||
return <View style={styles.container}>{images}</View>; | return <View style={styles.container}>{images}</View>; | ||||
} | } | ||||
renderSource(source: Source, invisibleLoad?: boolean = false) { | renderSource( | ||||
source: Source, | |||||
invisibleLoad?: boolean = false, | |||||
triggerOnLoad?: boolean = true, | |||||
) { | |||||
const onLoadProp = triggerOnLoad ? this.onLoad : undefined; | |||||
if (source.kind === 'encrypted') { | if (source.kind === 'encrypted') { | ||||
return ( | return ( | ||||
<EncryptedImage | <EncryptedImage | ||||
thumbHash={source.thumbHash} | thumbHash={source.thumbHash} | ||||
holder={source.holder} | holder={source.holder} | ||||
encryptionKey={source.encryptionKey} | encryptionKey={source.encryptionKey} | ||||
onLoad={this.onLoad} | onLoad={onLoadProp} | ||||
spinnerColor={this.props.spinnerColor} | spinnerColor={this.props.spinnerColor} | ||||
style={styles.image} | style={styles.image} | ||||
invisibleLoad={invisibleLoad} | invisibleLoad={invisibleLoad} | ||||
key={source.holder} | key={source.holder} | ||||
/> | /> | ||||
); | ); | ||||
} | } | ||||
const { uri, thumbHash } = source; | const { uri, thumbHash } = source; | ||||
const placeholder = thumbHash ? { thumbhash: thumbHash } : null; | const placeholder = thumbHash ? { thumbhash: thumbHash } : null; | ||||
if (uri.startsWith('http')) { | if (uri.startsWith('http')) { | ||||
return ( | return ( | ||||
<RemoteImage | <RemoteImage | ||||
uri={uri} | uri={uri} | ||||
onLoad={this.onLoad} | onLoad={onLoadProp} | ||||
placeholder={placeholder} | placeholder={placeholder} | ||||
spinnerColor={this.props.spinnerColor} | spinnerColor={this.props.spinnerColor} | ||||
style={styles.image} | style={styles.image} | ||||
invisibleLoad={invisibleLoad} | invisibleLoad={invisibleLoad} | ||||
key={uri} | key={uri} | ||||
/> | /> | ||||
); | ); | ||||
} else { | } else { | ||||
return ( | return ( | ||||
<Image | <Image | ||||
source={{ uri }} | source={{ uri }} | ||||
onLoad={this.onLoad} | onLoad={onLoadProp} | ||||
placeholder={placeholder} | placeholder={placeholder} | ||||
style={styles.image} | style={styles.image} | ||||
key={uri} | key={uri} | ||||
/> | /> | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |