forked from GeekyAnts/NativeBase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeBaseComponent.js
More file actions
37 lines (30 loc) · 872 Bytes
/
NativeBaseComponent.js
File metadata and controls
37 lines (30 loc) · 872 Bytes
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
/* @flow */
'use strict';
import React, {Component} from 'react';
import lightTheme from '../Themes/light';
export default class NativeBaseComponent extends Component {
static contextTypes = {
theme: React.PropTypes.object,
foregroundColor: React.PropTypes.string
}
static propTypes = {
theme: React.PropTypes.object,
foregroundColor: React.PropTypes.string
}
static childContextTypes = {
theme: React.PropTypes.object,
foregroundColor: React.PropTypes.string
}
getChildContext() {
return {
theme: this.props.theme ? this.props.theme : this.getTheme(),
foregroundColor: this.props.foregroundColor ? this.props.foregroundColor : this.getTheme().textColor
};
}
getContextForegroundColor() {
return this.context.foregroundColor
}
getTheme() {
return this.props.theme ? this.props.theme : this.context.theme || lightTheme
}
}