Skip to content

CardImage - remove deprecated props #1541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions generatedTypes/src/components/card/CardImage.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import React from 'react';
import { ImageSourcePropType } from 'react-native';
import { ImageProps } from '../image';
export declare type CardImageProps = Omit<ImageProps, 'source'> & {
/**
* Image source, either remote source or local. Note: for remote pass object {uri: <remote_uri_string>}
*/
imageSource?: ImageSourcePropType;
source?: ImageSourcePropType;
export declare type CardImageProps = ImageProps & {
/**
* Image width
*/
Expand All @@ -21,10 +15,6 @@ export declare type CardImageProps = Omit<ImageProps, 'source'> & {
* Card component
*/
position?: string[];
/**
* border radius, basically for Android since overflow doesn't work well (deprecated)
*/
borderRadius?: number;
};
declare const _default: React.ComponentType<CardImageProps>;
export default _default;
28 changes: 4 additions & 24 deletions src/components/card/CardImage.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import React, {PureComponent} from 'react';
import {View, StyleSheet, ImageSourcePropType} from 'react-native';
import {LogService} from '../../services';
import {View, StyleSheet} from 'react-native';
// import {BaseComponent} from '../../commons';
import Image, {ImageProps} from '../image';
import * as CardPresenter from './CardPresenter';
import asCardChild, {asCardChildProps} from './asCardChild';


// TODO: Remove omitting source after imageSource deprecation (since it's required for Image)
export type CardImageProps = Omit<ImageProps, 'source'> & {
/**
* Image source, either remote source or local. Note: for remote pass object {uri: <remote_uri_string>}
*/
imageSource?: ImageSourcePropType;
source?: ImageSourcePropType; //TODO: Remove after imageSource deprecation - should take it from ImageProps
export type CardImageProps = ImageProps & {
/**
* Image width
*/
Expand All @@ -28,10 +21,6 @@ export type CardImageProps = Omit<ImageProps, 'source'> & {
* Card component
*/
position?: string[];
/**
* border radius, basically for Android since overflow doesn't work well (deprecated)
*/
borderRadius?: number;
};

type Props = CardImageProps & asCardChildProps;
Expand All @@ -49,32 +38,23 @@ class CardImage extends PureComponent<Props> {
super(props);

this.styles = createStyles(props);

if (props.imageSource) {
LogService.deprecationWarn({component: 'CardImage', oldProp: 'imageSource', newProp: 'source'});
}
if (props.borderRadius) {
LogService.deprecationWarn({component: 'CardImage', oldProp: 'borderRadius'});
}
}

render() {
const {
imageSource,
source,
style,
testID,
overlayType,
context: {borderStyle}
} = this.props;
const finalSource = source || imageSource;

if (finalSource) {
if (source) {
return (
<View style={[this.styles.container, borderStyle, style]}>
<Image
testID={testID}
source={finalSource}
source={source}
style={[this.styles.image]}
overlayType={overlayType}
/>
Expand Down