11import PropTypes from 'prop-types' ;
22import React , { PureComponent } from 'react' ;
3- import { View as RNView , ViewPropTypes , SafeAreaView } from 'react-native' ;
3+ import { View as RNView , ViewPropTypes , SafeAreaView , Animated } from 'react-native' ;
44import { BaseComponent , asBaseComponent , forwardRef } from '../../commons' ;
55import * as Constants from '../../helpers/Constants' ;
66
@@ -20,8 +20,21 @@ class View extends PureComponent {
2020 * If true, will render as SafeAreaView
2121 */
2222 useSafeArea : PropTypes . bool ,
23+ /**
24+ * Use Animate.View as a container
25+ */
26+ animated : PropTypes . bool
2327 } ;
2428
29+ constructor ( props ) {
30+ super ( props ) ;
31+
32+ this . Container = props . useSafeArea && Constants . isIOS ? SafeAreaView : RNView ;
33+ if ( props . animated ) {
34+ this . Container = Animated . createAnimatedComponent ( this . Container ) ;
35+ }
36+ }
37+
2538 // TODO: do we need this?
2639 setNativeProps ( nativeProps ) {
2740 this . _root . setNativeProps ( nativeProps ) ; // eslint-disable-line
@@ -41,7 +54,7 @@ class View extends PureComponent {
4154 ...others
4255 } = this . props ;
4356 const { backgroundColor, borderRadius, paddings, margins, alignments, flexStyle} = modifiers ;
44- const Element = useSafeArea && Constants . isIOS ? SafeAreaView : RNView ;
57+ const Element = this . Container ;
4558
4659 return (
4760 < Element
0 commit comments