This repository has been archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 365
/
index.js
61 lines (49 loc) · 1.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, {Component, PropTypes} from "react";
import {ScrollView} from "react-native";
import { THEME_NAME, PRIMARY_COLORS } from '../config';
import { getColor } from '../helpers';
import Header from './Header';
import Section from './Section';
export default class Drawer extends Component {
static propTypes = {
theme: PropTypes.oneOf(THEME_NAME),
primary: PropTypes.oneOf(PRIMARY_COLORS),
overrides: PropTypes.shape({
backgroundColor: PropTypes.string
}),
children: PropTypes.node.isRequired
};
static defaultProps = {
theme: 'light',
primary: 'paperGrey'
};
static Header = Header;
static Section = Section;
render() {
const { theme, overrides, children } = this.props;
const backgroundColorMap = {
light: '#ffffff',
dark: '#333333'
};
const backgroundColor = (() => {
if (overrides && overrides.backgroundColor) {
return getColor(overrides.backgroundColor);
}
return backgroundColorMap[theme];
})();
return (
<ScrollView style={[styles.container, { backgroundColor: backgroundColor }]}>
{React.Children.map(children, (child) => {
return React.cloneElement(child, {
theme
});
})}
</ScrollView>
);
}
}
const styles = {
container: {
flex: 1
}
};