@@ -46,7 +46,7 @@ class Image extends PureBaseComponent {
46
46
*/
47
47
aspectRatio : PropTypes . number ,
48
48
/**
49
- * The type of overly to place on top of the image. Note: the image MUST have proper size, see examples in:
49
+ * The type of overly to place on top of the image. Note: the image MUST have proper size, see examples in:
50
50
* https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/OverlaysScreen.js
51
51
*/
52
52
overlayType : Overlay . propTypes . type
@@ -64,6 +64,20 @@ class Image extends PureBaseComponent {
64
64
this . sourceTransformer = this . getThemeProps ( ) . sourceTransformer ;
65
65
}
66
66
67
+ isGif ( ) {
68
+ if ( Constants . isAndroid ) {
69
+ const { source} = this . props ;
70
+ const url = _ . get ( source , 'uri' ) ;
71
+ const isGif = / ( h t t p ( s ? ) : ) ( [ / | . | \w | \s | - ] ) * \. (?: j p g | g i f | p n g ) / . test ( url ) ;
72
+ return isGif ;
73
+ }
74
+ }
75
+
76
+ shouldUseImageBackground ( ) {
77
+ const { overlayType} = this . props ;
78
+ return ! ! overlayType || this . isGif ( ) ;
79
+ }
80
+
67
81
getImageSource ( ) {
68
82
const { assetName, assetGroup} = this . props ;
69
83
if ( ! _ . isUndefined ( assetName ) ) {
@@ -86,14 +100,15 @@ class Image extends PureBaseComponent {
86
100
const source = this . getImageSource ( ) ;
87
101
const { tintColor, style, supportRTL, cover, aspectRatio, overlayType, ...others } = this . getThemeProps ( ) ;
88
102
const shouldFlipRTL = supportRTL && Constants . isRTL ;
89
- const ImageView = overlayType ? ImageBackground : RNImage ;
103
+ const ImageView = this . shouldUseImageBackground ( ) ? ImageBackground : RNImage ;
90
104
91
105
return (
92
106
< ImageView
93
107
style = { [
94
108
{ tintColor} ,
95
109
shouldFlipRTL && styles . rtlFlipped ,
96
110
cover && styles . coverImage ,
111
+ this . isGif ( ) && styles . gifImage ,
97
112
aspectRatio && { aspectRatio} ,
98
113
style
99
114
] }
@@ -115,6 +130,9 @@ const styles = StyleSheet.create({
115
130
coverImage : {
116
131
width : Constants . screenWidth ,
117
132
aspectRatio : 16 / 8
133
+ } ,
134
+ gifImage : {
135
+ overflow : 'hidden'
118
136
}
119
137
} ) ;
120
138
0 commit comments