2018-11-14 21:42:03 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import {
|
2019-03-01 16:49:11 +00:00
|
|
|
Text, ScrollView, View, StyleSheet
|
2018-11-14 21:42:03 +00:00
|
|
|
} from 'react-native';
|
2019-09-26 16:52:22 +00:00
|
|
|
import SafeAreaView from 'react-native-safe-area-view';
|
2019-01-31 16:08:38 +00:00
|
|
|
import { RectButton } from 'react-native-gesture-handler';
|
2019-04-26 20:51:09 +00:00
|
|
|
import { connect } from 'react-redux';
|
2018-11-14 21:42:03 +00:00
|
|
|
|
|
|
|
import sharedStyles from './Styles';
|
|
|
|
import scrollPersistTaps from '../utils/scrollPersistTaps';
|
|
|
|
import I18n from '../i18n';
|
2019-03-01 16:49:11 +00:00
|
|
|
import DisclosureIndicator from '../containers/DisclosureIndicator';
|
2019-03-12 16:23:06 +00:00
|
|
|
import StatusBar from '../containers/StatusBar';
|
2019-03-29 19:36:07 +00:00
|
|
|
import { COLOR_SEPARATOR, COLOR_WHITE } from '../constants/colors';
|
2019-04-26 20:51:09 +00:00
|
|
|
import openLink from '../utils/openLink';
|
2018-11-14 21:42:03 +00:00
|
|
|
|
|
|
|
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,
|
2018-11-14 21:42:03 +00:00
|
|
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
|
|
borderBottomWidth: StyleSheet.hairlineWidth
|
|
|
|
},
|
|
|
|
separator: {
|
2019-03-27 20:06:57 +00:00
|
|
|
backgroundColor: COLOR_SEPARATOR,
|
2018-11-14 21:42:03 +00:00
|
|
|
height: StyleSheet.hairlineWidth,
|
|
|
|
width: '100%',
|
|
|
|
marginLeft: 20
|
|
|
|
},
|
|
|
|
item: {
|
|
|
|
width: '100%',
|
|
|
|
height: 48,
|
2019-03-29 19:36:07 +00:00
|
|
|
backgroundColor: COLOR_WHITE,
|
2018-11-14 21:42:03 +00:00
|
|
|
paddingLeft: 20,
|
|
|
|
paddingRight: 10,
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'space-between'
|
|
|
|
},
|
|
|
|
text: {
|
|
|
|
...sharedStyles.textMedium,
|
2019-03-29 19:36:07 +00:00
|
|
|
...sharedStyles.textColorNormal,
|
2018-11-14 21:42:03 +00:00
|
|
|
fontSize: 18
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const Separator = () => <View style={styles.separator} />;
|
|
|
|
|
2019-08-07 13:51:34 +00:00
|
|
|
class LegalView extends React.Component {
|
2019-04-26 20:51:09 +00:00
|
|
|
static navigationOptions = () => ({
|
2019-03-12 16:23:06 +00:00
|
|
|
title: I18n.t('Legal')
|
|
|
|
})
|
2018-11-14 21:42:03 +00:00
|
|
|
|
|
|
|
static propTypes = {
|
2019-04-26 20:51:09 +00:00
|
|
|
server: PropTypes.string
|
2018-11-14 21:42:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onPressItem = ({ route }) => {
|
2019-04-26 20:51:09 +00:00
|
|
|
const { server } = this.props;
|
|
|
|
if (!server) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
openLink(`${ server }/${ route }`);
|
2018-11-14 21:42:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderItem = ({ text, route, testID }) => (
|
|
|
|
<RectButton style={styles.item} onPress={() => this.onPressItem({ route })} testID={testID}>
|
|
|
|
<Text style={styles.text}>{I18n.t(text)}</Text>
|
2019-03-01 16:49:11 +00:00
|
|
|
<DisclosureIndicator />
|
2018-11-14 21:42:03 +00:00
|
|
|
</RectButton>
|
|
|
|
)
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2019-08-07 13:51:34 +00:00
|
|
|
<SafeAreaView style={styles.container} testID='legal-view' forceInset={{ vertical: 'never' }}>
|
2019-03-12 16:23:06 +00:00
|
|
|
<StatusBar />
|
2018-11-14 21:42:03 +00:00
|
|
|
<ScrollView {...scrollPersistTaps} contentContainerStyle={styles.scroll}>
|
2019-04-26 20:51:09 +00:00
|
|
|
{this.renderItem({ text: 'Terms_of_Service', route: 'terms-of-service', testID: 'legal-terms-button' })}
|
2018-11-14 21:42:03 +00:00
|
|
|
<Separator />
|
2019-04-26 20:51:09 +00:00
|
|
|
{this.renderItem({ text: 'Privacy_Policy', route: 'privacy-policy', testID: 'legal-privacy-button' })}
|
2018-11-14 21:42:03 +00:00
|
|
|
</ScrollView>
|
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 13:51:34 +00:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
server: state.server.server
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(LegalView);
|