-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cross-platform tint color support (#226)
* tint color support (#2) * add image color support * added tintcolor support for android * changed prop to be named tintColor for consistency * fixed bug where tint color would not work on ios 10 * removed file accidentally added back in by merging master * updated readme, fixed prop warning * re-formatted with new rules
- Loading branch information
1 parent
161ba99
commit ad97e47
Showing
8 changed files
with
118 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react' | ||
import { PixelRatio, StyleSheet, View } from 'react-native' | ||
import withCacheBust from './withCacheBust' | ||
import FastImage from 'react-native-fast-image' | ||
import Section from './Section' | ||
import SectionFlex from './SectionFlex' | ||
import FeatureText from './FeatureText' | ||
|
||
const getImageUrl = (id, width, height) => | ||
`https://source.unsplash.com/${id}/${width}x${height}` | ||
const IMAGE_SIZE = 1024 | ||
const IMAGE_SIZE_PX = PixelRatio.getPixelSizeForLayoutSize(IMAGE_SIZE) | ||
const IMAGE_URLS = [ | ||
getImageUrl('x58soEovG_M', IMAGE_SIZE_PX, IMAGE_SIZE_PX), | ||
getImageUrl('yPI7myL5eWY', IMAGE_SIZE_PX, IMAGE_SIZE_PX), | ||
getImageUrl('S7VCcp6KCKE', IMAGE_SIZE, IMAGE_SIZE), | ||
] | ||
|
||
const TintColorExample = ({ onPressReload, bust }) => ( | ||
<View> | ||
<Section> | ||
<FeatureText text="Images with tint color" /> | ||
</Section> | ||
<SectionFlex onPress={onPressReload}> | ||
<FastImage | ||
style={styles.image} | ||
tintColor={'green'} | ||
source={{ | ||
uri: IMAGE_URLS[0] + bust, | ||
priority: FastImage.priority.low, | ||
}} | ||
/> | ||
<FastImage | ||
style={styles.image} | ||
tintColor={'#9324c3'} | ||
source={{ | ||
uri: IMAGE_URLS[1], | ||
priority: FastImage.priority.normal, | ||
}} | ||
/> | ||
<FastImage | ||
style={styles.image} | ||
tintColor={'rgba(0,0,0,0.5)'} | ||
source={{ | ||
uri: IMAGE_URLS[2] + bust, | ||
priority: FastImage.priority.high, | ||
}} | ||
/> | ||
</SectionFlex> | ||
</View> | ||
) | ||
|
||
const styles = StyleSheet.create({ | ||
image: { | ||
flex: 1, | ||
height: 100, | ||
backgroundColor: '#ddd', | ||
margin: 10, | ||
}, | ||
}) | ||
|
||
export default withCacheBust(TintColorExample) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters