summaryrefslogtreecommitdiff
path: root/client/src/lib/components/container.js
blob: fe6fd5efe13f8572f7b6efd5e9a62eb666a45b79 (plain)
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
import React, { Component } from 'react';
import {
  StyleSheet,
  View
} from 'react-native';

import Heading from '../components/heading'

export default class Container extends Component {
  constructor() {
    super()
  }
  render() {
    const { heading, style, bodyStyle, headingOnPress, ...props } = this.props
    let headingEl;
    if (heading) {
      headingEl = (
        <Heading style={styles.heading} onPress={headingOnPress}>
          {heading.toUpperCase()}
        </Heading>
      )
    }
    else {
      headingEl = null
    }
    return (
      <View style={[styles.container, style]} {...props}>
        {headingEl}
        <View style={[styles.body, bodyStyle]}>
          {this.props.children}
        </View>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'flex-start',
  },
  heading: {
  },
  body: {
    flex: 1,
    justifyContent: 'flex-start',
    alignItems: 'flex-start',
    paddingLeft: 10,
  }
})