aretherecookies-mobile/js/modals/FullScreenModal.js

59 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2019-06-22 15:48:52 +00:00
// @flow
import React from 'react';
2019-06-22 12:10:34 -05:00
import { View, SafeAreaView } from 'react-native';
2019-06-22 15:48:52 +00:00
import { Toolbar } from 'react-native-material-ui';
import { compose, renderComponent, mapProps, pure } from 'recompose';
import TopSaveButton from '../components/TopSaveButton';
2019-06-22 12:10:34 -05:00
import { palette } from '../ui-theme';
2019-06-22 15:48:52 +00:00
type Props = {
onClose: () => void,
title: String,
children: React.children,
onSave?: Function,
};
const FullScreenModal = ({ onSave, onClose, title, children }: Props) => (
2019-06-22 12:10:34 -05:00
<View
2019-06-22 15:48:52 +00:00
style={{
2019-06-22 12:10:34 -05:00
backgroundColor: 'white',
2019-06-22 15:48:52 +00:00
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
}}>
2019-06-22 12:10:34 -05:00
<View style={{ backgroundColor: palette.primaryColor }}>
<SafeAreaView>
<Toolbar
leftElement="close"
onLeftElementPress={onClose}
centerElement={title}
rightElement={onSave && <TopSaveButton onSave={onSave} />}
style={{
container: {
elevation: 3,
},
}}
/>
</SafeAreaView>
</View>
2019-06-22 15:48:52 +00:00
{children}
2019-06-22 12:10:34 -05:00
</View>
2019-06-22 15:48:52 +00:00
);
export default FullScreenModal;
export const wrapModalComponent = ({ component, onCloseProp, onUpdateProp }) =>
compose(
renderComponent,
pure,
mapProps((props: Props) => {
return {
2020-04-17 22:50:23 -05:00
product: props.product,
2019-06-22 15:48:52 +00:00
onClose: props[onCloseProp],
onUpdate: props[onUpdateProp],
};
})
)(component);