mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add "Refresh Image" to RNTester Image.fadeDuration example (#44414)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44414 # Changelog: [Internal] - I noticed that "Image/Fade Duration" test in RNTester is practically useless, as at the moment one scrolls to the test, the fading is most probably had already ended. This adds a "button" to refresh the image and be able to see the fading in again and again, if desired. Reviewed By: christophpurrer Differential Revision: D56978930 fbshipit-source-id: 02873b45600ad319b0b1077467f599dc1a54bee3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7558d5f6f5
commit
9d2cf42f95
@@ -429,6 +429,45 @@ class LoadingIndicatorSourceExample extends React.Component<
|
||||
}
|
||||
}
|
||||
|
||||
type FadeDurationExampleState = {|
|
||||
imageHash: number,
|
||||
|};
|
||||
|
||||
type FadeDurationExampleProps = $ReadOnly<{||}>;
|
||||
|
||||
class FadeDurationExample extends React.Component<
|
||||
FadeDurationExampleProps,
|
||||
FadeDurationExampleState,
|
||||
> {
|
||||
state: FadeDurationExampleState = {
|
||||
imageHash: Date.now(),
|
||||
};
|
||||
|
||||
reloadImage = () => {
|
||||
this.setState({
|
||||
imageHash: Date.now(),
|
||||
});
|
||||
};
|
||||
|
||||
render(): React.Node {
|
||||
const loadingImage = {
|
||||
uri: `https://www.facebook.com/ads/pics/successstories.png?hash=${this.state.imageHash}`,
|
||||
};
|
||||
|
||||
return (
|
||||
<View>
|
||||
<View style={styles.spaceBetweenView}>
|
||||
<Text style={styles.touchableText} onPress={this.reloadImage}>
|
||||
Refresh Image
|
||||
</Text>
|
||||
</View>
|
||||
<Image fadeDuration={1500} source={loadingImage} style={styles.base} />
|
||||
<Text>This image will fade in over the time of 1.5s.</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
type OnLayoutExampleState = {|
|
||||
width: number,
|
||||
height: number,
|
||||
@@ -1448,12 +1487,7 @@ exports.examples = [
|
||||
description:
|
||||
('The time (in miliseconds) that an image will fade in for when it appears (default = 300).': string),
|
||||
render: function (): React.Node {
|
||||
return (
|
||||
<>
|
||||
<Image fadeDuration={1500} source={fullImage} style={styles.base} />
|
||||
<Text>This image will fade in over the time of 1.5s.</Text>
|
||||
</>
|
||||
);
|
||||
return <FadeDurationExample />;
|
||||
},
|
||||
platform: 'android',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user