react-native-drawer-layout 4.1.7 → 4.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/views/Drawer.js +37 -52
- package/lib/module/views/Drawer.js.map +1 -1
- package/lib/module/views/Overlay.native.js +2 -1
- package/lib/module/views/Overlay.native.js.map +1 -1
- package/lib/typescript/src/views/Drawer.d.ts.map +1 -1
- package/lib/typescript/src/views/Overlay.native.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/views/Drawer.tsx +59 -72
- package/src/views/Overlay.native.tsx +1 -0
|
@@ -25,9 +25,8 @@ export function Drawer({
|
|
|
25
25
|
style
|
|
26
26
|
}) {
|
|
27
27
|
const windowDimensions = useWindowDimensions();
|
|
28
|
-
const layout = customLayout ?? windowDimensions;
|
|
29
28
|
const drawerWidth = getDrawerWidth({
|
|
30
|
-
layout,
|
|
29
|
+
layout: customLayout ?? windowDimensions,
|
|
31
30
|
drawerStyle
|
|
32
31
|
});
|
|
33
32
|
const progress = useFakeSharedValue(open ? 1 : 0);
|
|
@@ -52,22 +51,9 @@ export function Drawer({
|
|
|
52
51
|
}, [onTransitionEndLatest, onTransitionStartLatest]);
|
|
53
52
|
const isOpen = drawerType === 'permanent' ? true : open;
|
|
54
53
|
const isRight = drawerPosition === 'right';
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
const translateX =
|
|
57
55
|
// The drawer stays in place at open position when `drawerType` is `back`
|
|
58
|
-
|
|
59
|
-
if (direction === 'rtl') {
|
|
60
|
-
translateX = drawerPosition === 'left' ? drawerWidth - layout.width : 0;
|
|
61
|
-
} else {
|
|
62
|
-
translateX = drawerPosition === 'left' ? 0 : layout.width - drawerWidth;
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
if (direction === 'rtl') {
|
|
66
|
-
translateX = drawerPosition === 'left' ? -layout.width : drawerWidth;
|
|
67
|
-
} else {
|
|
68
|
-
translateX = drawerPosition === 'left' ? -drawerWidth : layout.width;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
56
|
+
open || drawerType === 'back' ? 0 : drawerPosition === 'left' ? -drawerWidth : drawerWidth;
|
|
71
57
|
const drawerAnimatedStyle = drawerType !== 'permanent' ? {
|
|
72
58
|
transition: 'transform 0.3s',
|
|
73
59
|
transform: [{
|
|
@@ -82,43 +68,45 @@ export function Drawer({
|
|
|
82
68
|
drawerType === 'front' ? 0 : drawerWidth * (drawerPosition === 'left' ? 1 : -1) : 0
|
|
83
69
|
}]
|
|
84
70
|
} : null;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
71
|
+
const drawerElement = /*#__PURE__*/_jsx(View, {
|
|
72
|
+
ref: drawerRef,
|
|
73
|
+
style: [styles.drawer, {
|
|
74
|
+
width: drawerWidth,
|
|
75
|
+
position: drawerType === 'permanent' ? 'relative' : 'absolute',
|
|
76
|
+
zIndex: drawerType === 'back' ? -1 : 1
|
|
77
|
+
}, drawerPosition === 'right' ? {
|
|
78
|
+
right: 0
|
|
79
|
+
} : {
|
|
80
|
+
left: 0
|
|
81
|
+
}, drawerAnimatedStyle, drawerStyle],
|
|
82
|
+
children: renderDrawerContent()
|
|
83
|
+
}, "drawer");
|
|
84
|
+
const mainContent = /*#__PURE__*/_jsxs(View, {
|
|
85
|
+
style: [styles.content, contentAnimatedStyle],
|
|
86
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
87
|
+
"aria-hidden": isOpen && drawerType !== 'permanent',
|
|
88
|
+
style: styles.content,
|
|
89
|
+
children: children
|
|
90
|
+
}), drawerType !== 'permanent' ? /*#__PURE__*/_jsx(Overlay, {
|
|
91
|
+
open: open,
|
|
92
|
+
progress: progress,
|
|
93
|
+
onPress: () => onClose(),
|
|
94
|
+
style: overlayStyle,
|
|
95
|
+
accessibilityLabel: overlayAccessibilityLabel
|
|
96
|
+
}) : null]
|
|
97
|
+
}, "content");
|
|
98
|
+
return /*#__PURE__*/_jsx(DrawerProgressContext.Provider, {
|
|
99
|
+
value: progress,
|
|
100
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
101
|
+
style: [styles.container, style],
|
|
102
|
+
children: [!isRight && drawerElement, mainContent, isRight && drawerElement]
|
|
116
103
|
})
|
|
117
104
|
});
|
|
118
105
|
}
|
|
119
106
|
const styles = StyleSheet.create({
|
|
120
107
|
container: {
|
|
121
|
-
flex: 1
|
|
108
|
+
flex: 1,
|
|
109
|
+
flexDirection: 'row'
|
|
122
110
|
},
|
|
123
111
|
drawer: {
|
|
124
112
|
top: 0,
|
|
@@ -128,9 +116,6 @@ const styles = StyleSheet.create({
|
|
|
128
116
|
},
|
|
129
117
|
content: {
|
|
130
118
|
flex: 1
|
|
131
|
-
},
|
|
132
|
-
main: {
|
|
133
|
-
flex: 1
|
|
134
119
|
}
|
|
135
120
|
});
|
|
136
121
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","StyleSheet","useWindowDimensions","View","useLatestCallback","DrawerProgressContext","getDrawerWidth","useFakeSharedValue","Overlay","jsx","_jsx","jsxs","_jsxs","Drawer","layout","customLayout","direction","drawerPosition","drawerStyle","drawerType","onClose","onTransitionStart","onTransitionEnd","open","overlayStyle","overlayAccessibilityLabel","renderDrawerContent","children","style","windowDimensions","drawerWidth","progress","useEffect","value","drawerRef","useRef","onTransitionStartLatest","onTransitionEndLatest","element","current","addEventListener","removeEventListener","isOpen","isRight","translateX","
|
|
1
|
+
{"version":3,"names":["React","StyleSheet","useWindowDimensions","View","useLatestCallback","DrawerProgressContext","getDrawerWidth","useFakeSharedValue","Overlay","jsx","_jsx","jsxs","_jsxs","Drawer","layout","customLayout","direction","drawerPosition","drawerStyle","drawerType","onClose","onTransitionStart","onTransitionEnd","open","overlayStyle","overlayAccessibilityLabel","renderDrawerContent","children","style","windowDimensions","drawerWidth","progress","useEffect","value","drawerRef","useRef","onTransitionStartLatest","onTransitionEndLatest","element","current","addEventListener","removeEventListener","isOpen","isRight","translateX","drawerAnimatedStyle","transition","transform","contentAnimatedStyle","drawerElement","ref","styles","drawer","width","position","zIndex","right","left","mainContent","content","onPress","accessibilityLabel","Provider","container","create","flex","flexDirection","top","bottom","maxWidth","backgroundColor"],"sourceRoot":"../../../src","sources":["views/Drawer.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,UAAU,EAAEC,mBAAmB,EAAEC,IAAI,QAAQ,cAAc;AACpE,OAAOC,iBAAiB,MAAM,qBAAqB;AAGnD,SAASC,qBAAqB,QAAQ,mCAAgC;AACtE,SAASC,cAAc,QAAQ,4BAAyB;AACxD,SAASC,kBAAkB,QAAQ,gCAA6B;AAChE,SAASC,OAAO,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEpC,OAAO,SAASC,MAAMA,CAAC;EACrBC,MAAM,EAAEC,YAAY;EACpBC,SAAS,GAAG,KAAK;EACjBC,cAAc,GAAGD,SAAS,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM;EACvDE,WAAW;EACXC,UAAU,GAAG,OAAO;EACpBC,OAAO;EACPC,iBAAiB;EACjBC,eAAe;EACfC,IAAI;EACJC,YAAY;EACZC,yBAAyB;EACzBC,mBAAmB;EACnBC,QAAQ;EACRC;AACW,CAAC,EAAE;EACd,MAAMC,gBAAgB,GAAG3B,mBAAmB,CAAC,CAAC;EAE9C,MAAM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AAK,EAAEuB,MAAM,CAACQ,OAAQ;MAAAhC,QAAA,EAErBA;IAAQ,CACL,CAAC,EACNR,UAAU,KAAK,WAAW,gBACzBT,IAAA,CAACF,OAAO;MACNe,IAAI,EAAEA,IAAK;MACXQ,QAAQ,EAAEA,QAAS;MACnB6B,OAAO,EAAEA,CAAA,KAAMxC,OAAO,CAAC,CAAE;MACzBQ,KAAK,EAAEJ,YAAa;MACpBqC,kBAAkB,EAAEpC;IAA0B,CAC/C,CAAC,GACA,IAAI;EAAA,GAfA,SAgBJ,CACP;EAED,oBACEf,IAAA,CAACL,qBAAqB,CAACyD,QAAQ;IAAC7B,KAAK,EAAEF,QAAS;IAAAJ,QAAA,eAC9Cf,KAAA,CAACT,IAAI;MAACyB,KAAK,EAAE,CAACuB,MAAM,CAACY,SAAS,EAAEnC,KAAK,CAAE;MAAAD,QAAA,GACpC,CAACgB,OAAO,IAAIM,aAAa,EACzBS,WAAW,EACXf,OAAO,IAAIM,aAAa;IAAA,CACrB;EAAC,CACuB,CAAC;AAErC;AAEA,MAAME,MAAM,GAAGlD,UAAU,CAAC+D,MAAM,CAAC;EAC/BD,SAAS,EAAE;IACTE,IAAI,EAAE,CAAC;IACPC,aAAa,EAAE;EACjB,CAAC;EACDd,MAAM,EAAE;IACNe,GAAG,EAAE,CAAC;IACNC,MAAM,EAAE,CAAC;IACTC,QAAQ,EAAE,MAAM;IAChBC,eAAe,EAAE;EACnB,CAAC;EACDX,OAAO,EAAE;IACPM,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Pressable","StyleSheet","Animated","useAnimatedProps","useAnimatedStyle","jsx","_jsx","PROGRESS_EPSILON","Overlay","progress","onPress","style","accessibilityLabel","rest","animatedStyle","opacity","value","animatedProps","active","View","styles","overlay","children","pressable","role","create","absoluteFillObject","backgroundColor","flex","pointerEvents"],"sourceRoot":"../../../src","sources":["views/Overlay.native.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,UAAU,QAAQ,cAAc;AACpD,OAAOC,QAAQ,IACbC,gBAAgB,EAChBC,gBAAgB,QACX,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAIjC,MAAMC,gBAAgB,GAAG,IAAI;AAE7B,OAAO,SAASC,OAAOA,CAAC;EACtBC,QAAQ;EACRC,OAAO;EACPC,KAAK;EACLC,kBAAkB,GAAG,cAAc;EACnC,GAAGC;AACS,CAAC,EAAE;EACf,MAAMC,aAAa,GAAGV,gBAAgB,CAAC,MAAM;IAC3C,OAAO;MACLW,OAAO,EAAEN,QAAQ,CAACO;IACpB,CAAC;EACH,CAAC,EAAE,CAACP,QAAQ,CAAC,CAAC;EAEd,MAAMQ,aAAa,GAAGd,gBAAgB,CAAC,MAAM;IAC3C,MAAMe,MAAM,GAAGT,QAAQ,CAACO,KAAK,GAAGT,gBAAgB;IAEhD,OAAO;MACL,eAAe,EAAEW,MAAM,GAAG,MAAM,GAAG,MAAM;MACzC,aAAa,EAAE,CAACA;IAClB,CAAC;EACH,CAAC,EAAE,CAACT,QAAQ,CAAC,CAAC;EAEd,oBACEH,IAAA,CAACJ,QAAQ,CAACiB,IAAI;IAAA,GACRN,IAAI;IACRF,KAAK,EAAE,CAACS,MAAM,CAACC,OAAO,EAAEP,aAAa,EAAEH,KAAK,CAAE;IAC9CM,aAAa,EAAEA,aAAc;IAAAK,QAAA,eAE7BhB,IAAA,CAACN,SAAS;MACRU,OAAO,EAAEA,OAAQ;MACjBC,KAAK,EAAES,MAAM,CAACG,SAAU;MACxBC,IAAI,EAAC,QAAQ;MACb,cAAYZ;
|
|
1
|
+
{"version":3,"names":["Pressable","StyleSheet","Animated","useAnimatedProps","useAnimatedStyle","jsx","_jsx","PROGRESS_EPSILON","Overlay","progress","onPress","style","accessibilityLabel","rest","animatedStyle","opacity","value","animatedProps","active","View","styles","overlay","children","pressable","role","accessible","create","absoluteFillObject","backgroundColor","flex","pointerEvents"],"sourceR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EAAE;EACnB,CAAC;EACDL,SAAS,EAAE;IACTM,IAAI,EAAE,CAAC;IACPC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../../src/views/Drawer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAM5C,wBAAgB,MAAM,CAAC,EACrB,MAAM,EAAE,YAAY,EACpB,SAAiB,EACjB,cAAuD,EACvD,WAAW,EACX,UAAoB,EACpB,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,IAAI,EACJ,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,EACnB,QAAQ,EACR,KAAK,GACN,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../../src/views/Drawer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAM5C,wBAAgB,MAAM,CAAC,EACrB,MAAM,EAAE,YAAY,EACpB,SAAiB,EACjB,cAAuD,EACvD,WAAW,EACX,UAAoB,EACpB,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,IAAI,EACJ,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,EACnB,QAAQ,EACR,KAAK,GACN,EAAE,WAAW,2CAyHb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Overlay.native.d.ts","sourceRoot":"","sources":["../../../../src/views/Overlay.native.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,wBAAgB,OAAO,CAAC,EACtB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,kBAAmC,EACnC,GAAG,IAAI,EACR,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"Overlay.native.d.ts","sourceRoot":"","sources":["../../../../src/views/Overlay.native.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,wBAAgB,OAAO,CAAC,EACtB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,kBAAmC,EACnC,GAAG,IAAI,EACR,EAAE,YAAY,2CA+Bd"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-drawer-layout",
|
|
3
3
|
"description": "Drawer component for React Native",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.9",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native-component",
|
|
7
7
|
"react-component",
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
"del-cli": "^6.0.0",
|
|
49
49
|
"react": "19.0.0",
|
|
50
50
|
"react-native": "0.79.2",
|
|
51
|
-
"react-native-builder-bob": "^0.40.
|
|
51
|
+
"react-native-builder-bob": "^0.40.9",
|
|
52
52
|
"typescript": "^5.8.3"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"react": ">= 18.2.0",
|
|
56
|
-
"react-native": "
|
|
57
|
-
"react-native-gesture-handler": "
|
|
56
|
+
"react-native": "*",
|
|
57
|
+
"react-native-gesture-handler": ">= 2.0.0",
|
|
58
58
|
"react-native-reanimated": ">= 2.0.0"
|
|
59
59
|
},
|
|
60
60
|
"react-native-builder-bob": {
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
]
|
|
76
76
|
]
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "52e5ec64745b399655adf7bd9773e31372d51e62"
|
|
79
79
|
}
|
package/src/views/Drawer.tsx
CHANGED
|
@@ -26,8 +26,10 @@ export function Drawer({
|
|
|
26
26
|
}: DrawerProps) {
|
|
27
27
|
const windowDimensions = useWindowDimensions();
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const drawerWidth = getDrawerWidth({
|
|
30
|
+
layout: customLayout ?? windowDimensions,
|
|
31
|
+
drawerStyle,
|
|
32
|
+
});
|
|
31
33
|
|
|
32
34
|
const progress = useFakeSharedValue(open ? 1 : 0);
|
|
33
35
|
|
|
@@ -60,22 +62,13 @@ export function Drawer({
|
|
|
60
62
|
const isOpen = drawerType === 'permanent' ? true : open;
|
|
61
63
|
const isRight = drawerPosition === 'right';
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
translateX = drawerPosition === 'left' ? 0 : layout.width - drawerWidth;
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
if (direction === 'rtl') {
|
|
74
|
-
translateX = drawerPosition === 'left' ? -layout.width : drawerWidth;
|
|
75
|
-
} else {
|
|
76
|
-
translateX = drawerPosition === 'left' ? -drawerWidth : layout.width;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
65
|
+
const translateX =
|
|
66
|
+
// The drawer stays in place at open position when `drawerType` is `back`
|
|
67
|
+
open || drawerType === 'back'
|
|
68
|
+
? 0
|
|
69
|
+
: drawerPosition === 'left'
|
|
70
|
+
? -drawerWidth
|
|
71
|
+
: drawerWidth;
|
|
79
72
|
|
|
80
73
|
const drawerAnimatedStyle =
|
|
81
74
|
drawerType !== 'permanent'
|
|
@@ -102,64 +95,61 @@ export function Drawer({
|
|
|
102
95
|
}
|
|
103
96
|
: null;
|
|
104
97
|
|
|
105
|
-
|
|
106
|
-
<View
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
styles.drawer,
|
|
143
|
-
{
|
|
144
|
-
width: drawerWidth,
|
|
145
|
-
position: drawerType === 'permanent' ? 'relative' : 'absolute',
|
|
146
|
-
zIndex: drawerType === 'back' ? -1 : 0,
|
|
147
|
-
},
|
|
148
|
-
drawerAnimatedStyle,
|
|
149
|
-
drawerStyle,
|
|
150
|
-
]}
|
|
151
|
-
>
|
|
152
|
-
{renderDrawerContent()}
|
|
153
|
-
</View>
|
|
154
|
-
</View>
|
|
155
|
-
</DrawerProgressContext.Provider>
|
|
98
|
+
const drawerElement = (
|
|
99
|
+
<View
|
|
100
|
+
key="drawer"
|
|
101
|
+
ref={drawerRef}
|
|
102
|
+
style={[
|
|
103
|
+
styles.drawer,
|
|
104
|
+
{
|
|
105
|
+
width: drawerWidth,
|
|
106
|
+
position: drawerType === 'permanent' ? 'relative' : 'absolute',
|
|
107
|
+
zIndex: drawerType === 'back' ? -1 : 1,
|
|
108
|
+
},
|
|
109
|
+
drawerPosition === 'right' ? { right: 0 } : { left: 0 },
|
|
110
|
+
drawerAnimatedStyle,
|
|
111
|
+
drawerStyle,
|
|
112
|
+
]}
|
|
113
|
+
>
|
|
114
|
+
{renderDrawerContent()}
|
|
115
|
+
</View>
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const mainContent = (
|
|
119
|
+
<View key="content" style={[styles.content, contentAnimatedStyle]}>
|
|
120
|
+
<View
|
|
121
|
+
aria-hidden={isOpen && drawerType !== 'permanent'}
|
|
122
|
+
style={styles.content}
|
|
123
|
+
>
|
|
124
|
+
{children}
|
|
125
|
+
</View>
|
|
126
|
+
{drawerType !== 'permanent' ? (
|
|
127
|
+
<Overlay
|
|
128
|
+
open={open}
|
|
129
|
+
progress={progress}
|
|
130
|
+
onPress={() => onClose()}
|
|
131
|
+
style={overlayStyle}
|
|
132
|
+
accessibilityLabel={overlayAccessibilityLabel}
|
|
133
|
+
/>
|
|
134
|
+
) : null}
|
|
156
135
|
</View>
|
|
157
136
|
);
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<DrawerProgressContext.Provider value={progress}>
|
|
140
|
+
<View style={[styles.container, style]}>
|
|
141
|
+
{!isRight && drawerElement}
|
|
142
|
+
{mainContent}
|
|
143
|
+
{isRight && drawerElement}
|
|
144
|
+
</View>
|
|
145
|
+
</DrawerProgressContext.Provider>
|
|
146
|
+
);
|
|
158
147
|
}
|
|
159
148
|
|
|
160
149
|
const styles = StyleSheet.create({
|
|
161
150
|
container: {
|
|
162
151
|
flex: 1,
|
|
152
|
+
flexDirection: 'row',
|
|
163
153
|
},
|
|
164
154
|
drawer: {
|
|
165
155
|
top: 0,
|
|
@@ -170,7 +160,4 @@ const styles = StyleSheet.create({
|
|
|
170
160
|
content: {
|
|
171
161
|
flex: 1,
|
|
172
162
|
},
|
|
173
|
-
main: {
|
|
174
|
-
flex: 1,
|
|
175
|
-
},
|
|
176
163
|
});
|