UNPKG

827 BJavaScriptView Raw
1import React from 'react'
2import { observer, useBackPress } from 'startupjs'
3import { SafeAreaView, StatusBar } from 'react-native'
4import propTypes from 'prop-types'
5import { useHistory } from 'react-router-native'
6import config from './../../config/rootConfig'
7import './index.styl'
8
9function Layout ({ style, children }) {
10 const history = useHistory()
11
12 useBackPress((backHandler) => {
13 if (!history.index) return // if first page then exit app
14 history.goBack()
15 return true
16 })
17
18 return pug`
19 SafeAreaView.root(style=style)
20 StatusBar(
21 backgroundColor=config.colors.darkLighter
22 barStyle='dark-content'
23 )
24 = children
25 `
26}
27
28Layout.propTypes = {
29 style: propTypes.oneOfType([propTypes.object, propTypes.array]),
30 children: propTypes.node
31}
32
33export default observer(Layout)