@@ -44,7 +44,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
44
44
var React = require ( "react" ) ;
45
45
var react_native_1 = require ( "react-native" ) ;
46
46
/* Utils - Project Utilities */
47
+ var RNNDrawer_1 = require ( "./RNNDrawer" ) ;
47
48
var events_1 = require ( "./events" ) ;
49
+ var RNNDrawer_2 = require ( "./RNNDrawer" ) ;
48
50
var screenHeight = react_native_1 . Dimensions . get ( 'screen' ) . height ;
49
51
var SideMenuView = /** @class */ ( function ( _super ) {
50
52
__extends ( SideMenuView , _super ) ;
@@ -58,7 +60,8 @@ var SideMenuView = /** @class */ (function (_super) {
58
60
function SideMenuView ( props ) {
59
61
var _this = _super . call ( this , props ) || this ;
60
62
_this . isOpened = false ;
61
- var swipeSensitivity = props . swipeSensitivity , left = props . left , right = props . right ;
63
+ var swipeSensitivity = props . swipeSensitivity , drawerName = props . drawerName , direction = props . direction , passProps = props . passProps , options = props . options ;
64
+ var directionIsLeft = direction ? direction == 'left' : true ;
62
65
_this . _panResponderMethods = {
63
66
// Ask to be the responder:
64
67
onStartShouldSetPanResponder : function ( _evt , _gestureState ) { return true ; } ,
@@ -83,9 +86,15 @@ var SideMenuView = /** @class */ (function (_super) {
83
86
events_1 . dispatch ( 'SWIPE_MOVE' , { value : moveX , direction : 'left' } ) ;
84
87
// Left Swipe
85
88
if ( typeof swipeSensitivity !== 'undefined' ) {
86
- if ( vx > swipeSensitivity && ! _this . isOpened && left ) {
89
+ if ( vx > swipeSensitivity && ! _this . isOpened && directionIsLeft ) {
87
90
_this . isOpened = true ;
88
- left ( ) ;
91
+ RNNDrawer_1 . default . showDrawer ( {
92
+ component : {
93
+ name : drawerName ,
94
+ passProps : __assign ( { direction : RNNDrawer_2 . DirectionType . left , parentComponentId : passProps === null || passProps === void 0 ? void 0 : passProps . parentComponentId } , passProps ) ,
95
+ options : __assign ( { } , options ) ,
96
+ } ,
97
+ } ) ;
89
98
}
90
99
}
91
100
} } ) ) ;
@@ -96,9 +105,15 @@ var SideMenuView = /** @class */ (function (_super) {
96
105
events_1 . dispatch ( 'SWIPE_MOVE' , { value : moveX , direction : 'right' } ) ;
97
106
// Right Swipe
98
107
if ( typeof swipeSensitivity !== 'undefined' ) {
99
- if ( vx > - swipeSensitivity && ! _this . isOpened && right ) {
108
+ if ( vx > - swipeSensitivity && ! _this . isOpened && ! directionIsLeft ) {
100
109
_this . isOpened = true ;
101
- right ( ) ;
110
+ RNNDrawer_1 . default . showDrawer ( {
111
+ component : {
112
+ name : drawerName ,
113
+ passProps : __assign ( { direction : RNNDrawer_2 . DirectionType . right , parentComponentId : passProps === null || passProps === void 0 ? void 0 : passProps . parentComponentId } , passProps ) ,
114
+ options : __assign ( { } , options ) ,
115
+ } ,
116
+ } ) ;
102
117
}
103
118
}
104
119
} } ) ) ;
@@ -137,27 +152,28 @@ var SideMenuView = /** @class */ (function (_super) {
137
152
*/
138
153
SideMenuView . prototype . render = function ( ) {
139
154
/** Props */
140
- var _a = this . props , children = _a . children , left = _a . left , right = _a . right , sideMargin = _a . sideMargin , sideMarginLeft = _a . sideMarginLeft , sideMarginRight = _a . sideMarginRight , props = __rest ( _a , [ "children" , "left" , "right" , "sideMargin" , "sideMarginLeft" , "sideMarginRight" ] ) ;
155
+ var _a = this . props , children = _a . children , direction = _a . direction , sideMargin = _a . sideMargin , sideMarginLeft = _a . sideMarginLeft , sideMarginRight = _a . sideMarginRight , props = __rest ( _a , [ "children" , "direction" , "sideMargin" , "sideMarginLeft" , "sideMarginRight" ] ) ;
156
+ var directionIsLeft = direction ? direction == 'left' : true ;
141
157
return ( React . createElement ( react_native_1 . View , __assign ( { } , props ) ,
142
158
children ,
143
- left ? ( React . createElement ( react_native_1 . View , __assign ( { style : {
159
+ directionIsLeft ? ( React . createElement ( react_native_1 . View , __assign ( { style : {
144
160
left : 0 ,
145
161
position : 'absolute' ,
146
162
width : sideMargin || sideMarginLeft ,
147
163
height : screenHeight ,
148
164
zIndex : 9999 ,
149
- } } , this . _leftPanResponder . panHandlers ) ) ) : null ,
150
- right ? ( React . createElement ( react_native_1 . View , __assign ( { style : {
165
+ } } , this . _leftPanResponder . panHandlers ) ) ) : ( React . createElement ( react_native_1 . View , __assign ( { style : {
151
166
position : 'absolute' ,
152
167
right : 0 ,
153
168
width : sideMargin || sideMarginRight ,
154
169
height : screenHeight ,
155
170
zIndex : 9999 ,
156
- } } , this . _rightPanResponder . panHandlers ) ) ) : null ) ) ;
171
+ } } , this . _rightPanResponder . panHandlers ) ) ) ) ) ;
157
172
} ;
158
173
SideMenuView . defaultProps = {
159
174
sideMargin : 15 ,
160
175
swipeSensitivity : 0.2 ,
176
+ direction : 'left' ,
161
177
} ;
162
178
return SideMenuView ;
163
179
} ( React . Component ) ) ;
0 commit comments