Skip to content

Commit 37c08c9

Browse files
Merge pull request GeekyAnts#2243 from GeekyAnts/revert-2100-deprecate/drawer
Revert "Removed Drawer from NativeBase"
2 parents 6506885 + 94e0786 commit 37c08c9

File tree

5 files changed

+85
-1
lines changed

5 files changed

+85
-1
lines changed

index.d.ts

+44-1
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,46 @@ declare module "native-base" {
685685
color?: string;
686686
inverse?: boolean;
687687
}
688-
688+
/**
689+
* vendor react-native-drawer
690+
*/
691+
interface DrawerStyles {
692+
drawer?: ReactNative.ViewStyle | Array<ReactNative.ViewStyle>;
693+
main?: ReactNative.ViewStyle | Array<ReactNative.ViewStyle>;
694+
drawerOverlay?: ReactNative.ViewStyle | Array<ReactNative.ViewStyle>;
695+
mainOverlay?: ReactNative.ViewStyle | Array<ReactNative.ViewStyle>;
696+
}
697+
interface Drawer {
698+
acceptDoubleTap?: boolean;
699+
acceptPan?: boolean;
700+
acceptTap?: boolean;
701+
captureGestures?: boolean;
702+
children?: any;
703+
open?: boolean;
704+
closedDrawerOffset?: number;
705+
content?: any;
706+
deviceScreen?: ReactNative.ScaledSize;
707+
disabled?: boolean;
708+
initializeOpen?: boolean;
709+
negotiatePan?: boolean;
710+
onClose?: Function;
711+
onCloseStart?: Function;
712+
onOpen?: Function;
713+
onOpenStart?: Function;
714+
openDrawerOffset?: number;
715+
openDrawerThreshold?: number;
716+
panCloseMask?: number;
717+
panOpenMask?: number;
718+
panStartCompensation?: boolean;
719+
relativeDrag?: boolean;
720+
side?: "left" | "right";
721+
styles?: DrawerStyles;
722+
tapToClose?: boolean;
723+
tweenDuration?: number;
724+
tweenEasing?: string;
725+
tweenHandler?: Function;
726+
type?: "overlay" | "static" | "displace";
727+
}
689728
interface ScrollableTab {
690729
goToPage?: Function;
691730
activeTab?: number;
@@ -1049,6 +1088,10 @@ declare module "native-base" {
10491088
*/
10501089
export class ProgressBar extends React.Component<NativeBase.ProgressBar, any> {}
10511090
/**
1091+
* NativeBase.Drawer
1092+
*/
1093+
export class Drawer extends React.Component<NativeBase.Drawer, any> {}
1094+
/**
10521095
* NativeBase.ScrollableTab
10531096
*/
10541097
export class ScrollableTab extends React.Component<NativeBase.ScrollableTab, any> { }

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"native-base-shoutem-theme": "0.2.2",
4040
"print-message": "^2.1.0",
4141
"prop-types": "^15.5.10",
42+
"react-native-drawer": "2.5.0",
4243
"react-native-easy-grid": "0.2.0",
4344
"react-native-keyboard-aware-scroll-view": "0.5.0",
4445
"react-native-vector-icons": "4.6.0",

src/basic/Drawer/index.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React, { Component } from "react";
2+
import RNDrawer from "react-native-drawer";
3+
import PropTypes from "prop-types";
4+
5+
export default class Drawer extends Component {
6+
constructor(props) {
7+
super(props);
8+
}
9+
render() {
10+
return <RNDrawer ref={c => (this._root = c)} {...this.props} />;
11+
}
12+
}
13+
14+
Drawer.defaultProps = {
15+
type: "overlay",
16+
tapToClose: true,
17+
openDrawerOffset: 0.2,
18+
panCloseMask: 0.2,
19+
closedDrawerOffset: 0,
20+
styles: {
21+
drawer: {
22+
shadowColor: "#000000",
23+
shadowOpacity: 0,
24+
shadowRadius: 0,
25+
elevation: 5,
26+
},
27+
mainOverlay: {
28+
opacity: 0,
29+
backgroundColor: "rgba(0, 0, 0, 0.8)",
30+
elevation: 8,
31+
},
32+
},
33+
tweenHandler: ratio => ({
34+
mainOverlay: { opacity: ratio / 2 },
35+
}),
36+
};

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Col, Row, Grid } from "react-native-easy-grid";
55
import setDefaultThemeStyle from "./init";
66
import getTheme from "./theme/components";
77
import variables from "./theme/variables/platform";
8+
import Drawer from "./basic/Drawer";
89
import { SwipeRow } from "./basic/SwipeRow";
910
import { Text } from "./basic/Text";
1011
import { ViewNB as View } from "./basic/View";
@@ -66,6 +67,7 @@ export {
6667
variables,
6768
StyleProvider,
6869
connectStyle,
70+
Drawer,
6971
Button,
7072
DatePicker,
7173
IconNB,

src/vue-native.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { StyleProvider } from "native-base-shoutem-theme";
22
// import { Gravatar } from "./basic/Gravatar";
33
import { Col, Row, Grid } from "react-native-easy-grid";
4+
import Drawer from "./basic/Drawer";
45
import { SwipeRow } from "./basic/SwipeRow";
56
import { Text } from "./basic/Text";
67
import { ViewNB as View } from "./basic/View";
@@ -57,6 +58,7 @@ const VueNativeBasePlugin = {
5758
// The install method is all that needs to exist on the plugin object.
5859
// It takes the global Vue object as well as user-defined options.
5960
install(Vue, options) {
61+
Vue.component("nb-drawer", Drawer);
6062
Vue.component("nb-row", Row);
6163
Vue.component("nb-col", Col);
6264
Vue.component("nb-grid", Grid);

0 commit comments

Comments
 (0)