|
1 |
| -/* @flow */ |
2 |
| -'use strict'; |
3 |
| - |
4 |
| -import React from 'react'; |
5 |
| -import {View} from 'react-native'; |
6 |
| -import NativeBaseComponent from '../Base/NativeBaseComponent'; |
7 |
| -import computeProps from '../../Utils/computeProps'; |
8 |
| -import Text from './Text'; |
9 |
| - |
10 |
| - |
11 |
| -export default class BadgeNB extends NativeBaseComponent { |
12 |
| - |
13 |
| - propTypes: { |
14 |
| - style : React.PropTypes.object |
15 |
| - } |
16 |
| - |
17 |
| - prepareRootProps() { |
18 |
| - |
19 |
| - var type = { |
20 |
| - |
21 |
| - backgroundColor:this.props.primary ? |
22 |
| - this.getTheme().brandPrimary : |
23 |
| - this.props.success ? |
24 |
| - this.getTheme().brandSuccess : |
25 |
| - this.props.info ? |
26 |
| - this.getTheme().brandInfo : |
27 |
| - this.props.warning ? |
28 |
| - this.getTheme().brandWarning : |
29 |
| - this.props.danger ? |
30 |
| - this.getTheme().brandDanger : |
31 |
| - this.getTheme().badgeBg, |
32 |
| - padding: 3, |
33 |
| - paddingHorizontal: 10, |
34 |
| - alignSelf: 'flex-start', |
35 |
| - borderRadius: 13.5, |
36 |
| - height: 27 |
37 |
| - |
38 |
| - } |
39 |
| - |
40 |
| - var defaultProps = { |
41 |
| - style: type |
42 |
| - } |
43 |
| - |
44 |
| - return computeProps(this.props, defaultProps); |
45 |
| - |
46 |
| - } |
47 |
| - render() { |
48 |
| - return( |
49 |
| - <View {...this.prepareRootProps()}> |
50 |
| - <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, |
51 |
| - fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, |
52 |
| - lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, |
53 |
| - textAlign: 'center'}}>{this.props.children} |
54 |
| - </Text> |
55 |
| - </View> |
56 |
| - ); |
57 |
| - } |
58 |
| - |
59 |
| -} |
| 1 | +/* @flow */ |
| 2 | +'use strict'; |
| 3 | + |
| 4 | +import React from 'react'; |
| 5 | +import {View} from 'react-native'; |
| 6 | +import NativeBaseComponent from '../Base/NativeBaseComponent'; |
| 7 | +import computeProps from '../../Utils/computeProps'; |
| 8 | +import Text from './Text'; |
| 9 | + |
| 10 | + |
| 11 | +export default class BadgeNB extends NativeBaseComponent { |
| 12 | + |
| 13 | + propTypes: { |
| 14 | + style : React.PropTypes.object |
| 15 | + } |
| 16 | + |
| 17 | + prepareRootProps() { |
| 18 | + |
| 19 | + var type = { |
| 20 | + |
| 21 | + backgroundColor:this.props.primary ? |
| 22 | + this.getTheme().brandPrimary : |
| 23 | + this.props.success ? |
| 24 | + this.getTheme().brandSuccess : |
| 25 | + this.props.info ? |
| 26 | + this.getTheme().brandInfo : |
| 27 | + this.props.warning ? |
| 28 | + this.getTheme().brandWarning : |
| 29 | + this.props.danger ? |
| 30 | + this.getTheme().brandDanger : |
| 31 | + this.getTheme().badgeBg, |
| 32 | + padding: 3, |
| 33 | + paddingHorizontal: 10, |
| 34 | + alignSelf: 'flex-start', |
| 35 | + borderRadius: 13.5, |
| 36 | + height: 27 |
| 37 | + |
| 38 | + } |
| 39 | + |
| 40 | + var defaultProps = { |
| 41 | + style: type |
| 42 | + } |
| 43 | + |
| 44 | + return computeProps(this.props, defaultProps); |
| 45 | + |
| 46 | + } |
| 47 | + render() { |
| 48 | + return( |
| 49 | + <View {...this.prepareRootProps()}> |
| 50 | + <Text style={{ color: (this.props.textStyle && this.props.textStyle.color) ? this.props.textStyle.color : this.getTheme().badgeColor, |
| 51 | + fontSize: (this.props.textStyle && this.props.textStyle.fontSize) ? this.props.textStyle.fontSize : this.getTheme().fontSizeBase, |
| 52 | + lineHeight: (this.props.textStyle && this.props.textStyle.lineHeight) ? this.props.textStyle.lineHeight : this.getTheme().lineHeight-1, |
| 53 | + textAlign: 'center'}}>{this.props.children} |
| 54 | + </Text> |
| 55 | + </View> |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | +} |
0 commit comments