verdnatura-chat/app/views/LegalView.js

95 lines
2.5 KiB
JavaScript
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import {
Text, ScrollView, View, StyleSheet
} from 'react-native';
2019-03-12 16:23:06 +00:00
import { SafeAreaView } from 'react-navigation';
import { RectButton } from 'react-native-gesture-handler';
import sharedStyles from './Styles';
import scrollPersistTaps from '../utils/scrollPersistTaps';
import LoggedView from './View';
import I18n from '../i18n';
import DisclosureIndicator from '../containers/DisclosureIndicator';
2019-03-12 16:23:06 +00:00
import { CloseModalButton } from '../containers/HeaderButton';
import StatusBar from '../containers/StatusBar';
2019-03-29 19:36:07 +00:00
import { COLOR_SEPARATOR, COLOR_WHITE } from '../constants/colors';
const styles = StyleSheet.create({
container: {
backgroundColor: '#f7f8fa',
flex: 1
},
scroll: {
marginTop: 35,
2019-03-29 19:36:07 +00:00
backgroundColor: COLOR_WHITE,
2019-03-27 20:06:57 +00:00
borderColor: COLOR_SEPARATOR,
borderTopWidth: StyleSheet.hairlineWidth,
borderBottomWidth: StyleSheet.hairlineWidth
},
separator: {
2019-03-27 20:06:57 +00:00
backgroundColor: COLOR_SEPARATOR,
height: StyleSheet.hairlineWidth,
width: '100%',
marginLeft: 20
},
item: {
width: '100%',
height: 48,
2019-03-29 19:36:07 +00:00
backgroundColor: COLOR_WHITE,
paddingLeft: 20,
paddingRight: 10,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between'
},
text: {
...sharedStyles.textMedium,
2019-03-29 19:36:07 +00:00
...sharedStyles.textColorNormal,
fontSize: 18
}
});
const Separator = () => <View style={styles.separator} />;
/** @extends React.Component */
export default class LegalView extends LoggedView {
2019-03-12 16:23:06 +00:00
static navigationOptions = ({ navigation }) => ({
headerLeft: <CloseModalButton testID='legal-view-close' navigation={navigation} />,
title: I18n.t('Legal')
})
static propTypes = {
2019-03-12 16:23:06 +00:00
navigation: PropTypes.object
}
constructor(props) {
super('LegalView', props);
}
onPressItem = ({ route }) => {
2019-03-12 16:23:06 +00:00
const { navigation } = this.props;
navigation.navigate(route);
}
renderItem = ({ text, route, testID }) => (
<RectButton style={styles.item} onPress={() => this.onPressItem({ route })} testID={testID}>
<Text style={styles.text}>{I18n.t(text)}</Text>
<DisclosureIndicator />
</RectButton>
)
render() {
return (
<SafeAreaView style={styles.container} testID='legal-view' forceInset={{ bottom: 'never' }}>
2019-03-12 16:23:06 +00:00
<StatusBar />
<ScrollView {...scrollPersistTaps} contentContainerStyle={styles.scroll}>
{this.renderItem({ text: 'Terms_of_Service', route: 'TermsServiceView', testID: 'legal-terms-button' })}
<Separator />
{this.renderItem({ text: 'Privacy_Policy', route: 'PrivacyPolicyView', testID: 'legal-privacy-button' })}
</ScrollView>
</SafeAreaView>
);
}
}