-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLayout.js
61 lines (52 loc) · 1.36 KB
/
Layout.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} from 'react'
import PropTypes from 'prop-types'
import {Prism, StyleRegistry} from 'react-native-prism'
import {View} from 'react-native-prism-primitives'
import namespace from './namespace'
import theme from './theme'
// Configure the library style registry
const registry = new StyleRegistry({theme, bundle: true})
class Layout extends Component {
static styleName = 'Layout'
static styleOptions = () => {
return {
registry: registry,
supportsDimension: true,
mapPropsToStyle: {
center: ({prop}) => {
if (prop) {
return {alignItems: 'center'}
}
},
start: ({prop}) => {
if (prop) {
return {alignItems: 'flex-start'}
}
},
end: ({prop}) => {
if (prop) {
return {alignItems: 'flex-end'}
}
}
}
}
}
static propTypes = {
center: PropTypes.bool,
start: PropTypes.bool,
end: PropTypes.bool
}
render() {
const {style} = this.props
return (
<View style={style}>{this.props.children}</View>
)
}
}
const requirements = ({config}) => {
if (config.extendedProperties !== true) {
return `extendedProperties must be set in config ` +
`to use the ${namespace} component library`
}
}
export default Prism(Layout, {namespace, requirements})