1
1
import _ from 'lodash' ;
2
2
import React , { PureComponent } from 'react' ;
3
3
import { StyleSheet , ViewStyle , ImageStyle , ImageSourcePropType , StyleProp } from 'react-native' ;
4
- import { LogService } from '../../services' ;
5
4
import { asBaseComponent } from '../../commons/new' ;
6
5
import View , { ViewProps } from '../view' ;
7
6
import Text , { TextProps } from '../text' ;
8
7
import Image , { ImageProps } from '../image' ;
9
8
import asCardChild , { asCardChildProps } from './asCardChild' ;
10
9
10
+
11
11
type ContentType = TextProps & { text ?: string } ;
12
12
13
13
export type CardSectionProps = ViewProps & {
@@ -36,7 +36,6 @@ export type CardSectionProps = ViewProps & {
36
36
* Will be used for the background when provided
37
37
*/
38
38
imageSource ?: ImageSourcePropType ;
39
- source ?: ImageSourcePropType ; // TODO: remove after deprecation
40
39
/**
41
40
* The style for the background image
42
41
*/
@@ -56,14 +55,6 @@ type Props = CardSectionProps & asCardChildProps;
56
55
class CardSection extends PureComponent < Props > {
57
56
static displayName = 'Card.Section' ;
58
57
59
- constructor ( props : Props ) {
60
- super ( props ) ;
61
-
62
- if ( props . source ) {
63
- LogService . deprecationWarn ( { component : 'CardSection' , oldProp : 'source' , newProp : 'imageSource' } ) ;
64
- }
65
- }
66
-
67
58
renderContent = ( ) => {
68
59
const { content, leadingIcon, trailingIcon, contentStyle, testID} = this . props ;
69
60
if ( ! leadingIcon && ! trailingIcon && _ . isEmpty ( content ) ) {
@@ -92,15 +83,14 @@ class CardSection extends PureComponent<Props> {
92
83
} ;
93
84
94
85
renderImage = ( ) => {
95
- const { source, imageSource, imageStyle, imageProps, testID} = this . props ;
96
- const finalSource = imageSource || source ;
86
+ const { imageSource, imageStyle, imageProps, testID} = this . props ;
97
87
98
88
// not actually needed, instead of adding ts-ignore
99
- if ( finalSource ) {
89
+ if ( imageSource ) {
100
90
return (
101
91
< Image
102
92
testID = { `${ testID } .image` }
103
- source = { finalSource }
93
+ source = { imageSource }
104
94
style = { imageStyle }
105
95
customOverlayContent = { this . renderContent ( ) }
106
96
{ ...imageProps }
@@ -111,18 +101,16 @@ class CardSection extends PureComponent<Props> {
111
101
112
102
render ( ) {
113
103
const {
114
- source,
115
104
imageSource,
116
105
context : { borderStyle} ,
117
106
style,
118
107
...others
119
108
} = this . props ;
120
- const finalSource = imageSource || source ;
121
109
122
110
return (
123
111
< View style = { [ styles . container , borderStyle , style ] } { ...others } >
124
- { finalSource && this . renderImage ( ) }
125
- { ! finalSource && this . renderContent ( ) }
112
+ { imageSource && this . renderImage ( ) }
113
+ { ! imageSource && this . renderContent ( ) }
126
114
</ View >
127
115
) ;
128
116
}
0 commit comments