|
@@ -1,5 +1,6 @@
|
1
|
1
|
import React from 'react';
|
2
|
2
|
import {
|
|
3
|
+ Dimensions,
|
3
|
4
|
TouchableHighlight,
|
4
|
5
|
TouchableWithoutFeedback,
|
5
|
6
|
View
|
|
@@ -28,26 +29,54 @@ export default class Container extends AbstractContainer {
|
28
|
29
|
*/
|
29
|
30
|
render() {
|
30
|
31
|
// eslint-disable-next-line prefer-const
|
31
|
|
- let { onClick, style, touchFeedback, ...props } = this.props;
|
|
32
|
+ let { onClick, style, touchFeedback, visible, ...props } = this.props;
|
|
33
|
+
|
|
34
|
+ // visible
|
|
35
|
+
|
|
36
|
+ // The following property is responsible to hide/show this Container by
|
|
37
|
+ // moving it out of site of the screen boundaries. An attempt to use the
|
|
38
|
+ // opacity property was made in order to eventually implement a
|
|
39
|
+ // fadeIn/fadeOut animation, however a known React Native problem was
|
|
40
|
+ // discovered, which allows the view to still capture touch events even
|
|
41
|
+ // if hidden.
|
|
42
|
+ let visibilityStyle;
|
|
43
|
+
|
|
44
|
+ if (typeof visible !== 'undefined' && !visible) {
|
|
45
|
+ const windowDimensions = Dimensions.get('window');
|
|
46
|
+
|
|
47
|
+ visibilityStyle = {
|
|
48
|
+ bottom: -windowDimensions.height,
|
|
49
|
+ right: -windowDimensions.width
|
|
50
|
+ };
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ // onClick & touchFeedback
|
|
54
|
+ (typeof touchFeedback === 'undefined') && (touchFeedback = onClick);
|
|
55
|
+
|
|
56
|
+ const renderParent = touchFeedback || onClick;
|
|
57
|
+
|
|
58
|
+ if (!renderParent && visibilityStyle) {
|
|
59
|
+ style = {
|
|
60
|
+ ...style,
|
|
61
|
+ ...visibilityStyle
|
|
62
|
+ };
|
|
63
|
+ }
|
32
|
64
|
|
33
|
65
|
// eslint-disable-next-line object-property-newline
|
34
|
66
|
let component = this._render(View, { ...props, style });
|
35
|
67
|
|
36
|
|
- if (component) {
|
37
|
|
- // onClick & touchFeedback
|
38
|
|
- (typeof touchFeedback === 'undefined') && (touchFeedback = onClick);
|
39
|
|
- if (touchFeedback || onClick) {
|
40
|
|
- const parentType
|
41
|
|
- = touchFeedback
|
42
|
|
- ? TouchableHighlight
|
43
|
|
- : TouchableWithoutFeedback;
|
44
|
|
- const parentProps = {};
|
45
|
|
-
|
46
|
|
- onClick && (parentProps.onPress = onClick);
|
47
|
|
-
|
48
|
|
- component
|
49
|
|
- = React.createElement(parentType, parentProps, component);
|
50
|
|
- }
|
|
68
|
+ if (renderParent) {
|
|
69
|
+ const parentType
|
|
70
|
+ = touchFeedback
|
|
71
|
+ ? TouchableHighlight
|
|
72
|
+ : TouchableWithoutFeedback;
|
|
73
|
+ const parentProps = {};
|
|
74
|
+
|
|
75
|
+ onClick && (parentProps.onPress = onClick);
|
|
76
|
+ visibilityStyle && (parentProps.style = visibilityStyle);
|
|
77
|
+
|
|
78
|
+ component
|
|
79
|
+ = React.createElement(parentType, parentProps, component);
|
51
|
80
|
}
|
52
|
81
|
|
53
|
82
|
return component;
|