react-native-elements#Image TypeScript Examples
The following examples show how to use
react-native-elements#Image.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProductListItem.tsx From magento_react_native_graphql with MIT License | 6 votes |
ProductListItem = ({
item,
index,
horizontalMode = false,
onPress,
}: Props): React.ReactElement => {
const { theme } = useContext(ThemeContext);
const renderImage = () => {
const uri = `${item.smallImage.url}?width=${COLUMN_WIDTH}`;
return <Image source={{ uri }} style={styles.image} />;
};
return (
<TouchableOpacity onPress={() => onPress(index)}>
<View
style={[
styles.container,
{
borderColor: theme.colors?.divider,
backgroundColor: theme.colors?.white,
},
horizontalMode && styles.topBorder,
(horizontalMode || index % 2 !== 0) && styles.leftBorder,
]}
>
{renderImage()}
<Text style={styles.name}>{item.name}</Text>
<Text style={styles.price}>
{formatPrice(item.priceRange.maximumPrice.finalPrice)}
</Text>
</View>
</TouchableOpacity>
);
}
Example #2
Source File: CartListItem.tsx From magento_react_native_graphql with MIT License | 6 votes |
CartListItem = ({
item,
index,
onPress,
onRemovePress,
}: Props): React.ReactElement => {
const renderImage = () => {
const uri = `${item.product.small_image.url}?width=${DIMENS.cartScreen.imageSize}`;
return <Image source={{ uri }} style={styles.image} />;
};
return (
<ListItem onPress={() => onPress(index)} bottomDivider>
{renderImage()}
<ListItem.Content>
<ListItem.Title>{item.product.name}</ListItem.Title>
<ListItem.Subtitle>{`${translate('common.quantity')} : ${
item.quantity
}`}</ListItem.Subtitle>
<ListItem.Subtitle>{`${translate('common.price')} : ${formatPrice(
item.prices.rowTotal,
)}`}</ListItem.Subtitle>
</ListItem.Content>
<ListItem.Chevron name="delete" onPress={() => onRemovePress(index)} />
</ListItem>
);
}
Example #3
Source File: CategoryListItem.tsx From magento_react_native_graphql with MIT License | 5 votes |
CategoryListItem = ({ item, navigation }: Props): React.ReactElement => {
const [disabled] = useState<boolean>(
+item.childrenCount < 1 && item.productCount < 1,
);
const onCategoryPress = () => {
if (+item.childrenCount > 0) {
navigation.navigate(Routes.NAVIGATION_TO_CATEGORIES_SCREEN, {
categoryId: item.id,
name: item.name,
});
return;
}
navigation.navigate(Routes.NAVIGATION_TO_PRODUCT_LIST_SCREEN, {
categoryId: item.id,
name: item.name,
});
};
const renderImage = () => {
const rawUri =
item.image ?? item.productPreviewImage?.items?.[0]?.smallImage?.url;
if (!rawUri) {
return null;
}
const uri = `${rawUri ?? ''}?width=100`;
return <Image source={{ uri }} resizeMode="cover" style={styles.image} />;
};
const renderContent = () => {
return (
<>
<ListItem.Content>
<ListItem.Title>{item.name}</ListItem.Title>
</ListItem.Content>
</>
);
};
return (
<ListItem
containerStyle={styles.conatiner}
disabled={disabled}
onPress={onCategoryPress}
bottomDivider
>
{renderImage()}
{renderContent()}
</ListItem>
);
}