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-03-12 16:23:06 +00:00
|
|
|
import { SafeAreaView } from 'react-navigation';
|
2019-04-26 20:51:09 +00:00
|
|
|
import { connect } from 'react-redux';
|
2018-11-14 21:42:03 +00:00
|
|
|
|
2019-12-11 23:01:12 +00:00
|
|
|
import Touch from '../utils/touch';
|
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-12-11 23:01:12 +00:00
|
|
|
import { themes } from '../constants/colors';
|
2019-04-26 20:51:09 +00:00
|
|
|
import openLink from '../utils/openLink';
|
2019-12-11 23:01:12 +00:00
|
|
|
import { withTheme } from '../theme';
|
|
|
|
import { themedHeader } from '../utils/navigation';
|
2018-11-14 21:42:03 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
scroll: {
|
|
|
|
marginTop: 35,
|
|
|
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
|
|
borderBottomWidth: StyleSheet.hairlineWidth
|
|
|
|
},
|
|
|
|
separator: {
|
|
|
|
height: StyleSheet.hairlineWidth,
|
|
|
|
width: '100%',
|
|
|
|
marginLeft: 20
|
|
|
|
},
|
|
|
|
item: {
|
|
|
|
width: '100%',
|
|
|
|
height: 48,
|
|
|
|
paddingLeft: 20,
|
|
|
|
paddingRight: 10,
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'space-between'
|
|
|
|
},
|
|
|
|
text: {
|
|
|
|
...sharedStyles.textMedium,
|
|
|
|
fontSize: 18
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-12-11 23:01:12 +00:00
|
|
|
const Separator = ({ theme }) => <View style={[styles.separator, { backgroundColor: themes[theme].separatorColor }]} />;
|
|
|
|
Separator.propTypes = {
|
|
|
|
theme: PropTypes.string
|
|
|
|
};
|
2018-11-14 21:42:03 +00:00
|
|
|
|
2019-08-20 19:24:22 +00:00
|
|
|
class LegalView extends React.Component {
|
2019-12-11 23:01:12 +00:00
|
|
|
static navigationOptions = ({ screenProps }) => ({
|
|
|
|
title: I18n.t('Legal'),
|
|
|
|
...themedHeader(screenProps.theme)
|
2019-03-12 16:23:06 +00:00
|
|
|
})
|
2018-11-14 21:42:03 +00:00
|
|
|
|
|
|
|
static propTypes = {
|
2019-12-11 23:01:12 +00:00
|
|
|
server: PropTypes.string,
|
|
|
|
theme: PropTypes.string
|
2018-11-14 21:42:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onPressItem = ({ route }) => {
|
2019-12-11 23:01:12 +00:00
|
|
|
const { server, theme } = this.props;
|
2019-04-26 20:51:09 +00:00
|
|
|
if (!server) {
|
|
|
|
return;
|
|
|
|
}
|
2019-12-11 23:01:12 +00:00
|
|
|
openLink(`${ server }/${ route }`, theme);
|
2018-11-14 21:42:03 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 23:01:12 +00:00
|
|
|
renderItem = ({ text, route, testID }) => {
|
|
|
|
const { theme } = this.props;
|
|
|
|
return (
|
|
|
|
<Touch
|
|
|
|
style={[styles.item, { backgroundColor: themes[theme].backgroundColor }]}
|
|
|
|
onPress={() => this.onPressItem({ route })}
|
|
|
|
testID={testID}
|
|
|
|
theme={theme}
|
|
|
|
>
|
|
|
|
<Text style={[styles.text, { color: themes[theme].titleText }]}>{I18n.t(text)}</Text>
|
|
|
|
<DisclosureIndicator theme={theme} />
|
|
|
|
</Touch>
|
|
|
|
);
|
|
|
|
}
|
2018-11-14 21:42:03 +00:00
|
|
|
|
|
|
|
render() {
|
2019-12-11 23:01:12 +00:00
|
|
|
const { theme } = this.props;
|
2018-11-14 21:42:03 +00:00
|
|
|
return (
|
2019-12-11 23:01:12 +00:00
|
|
|
<SafeAreaView
|
|
|
|
style={[
|
|
|
|
styles.container,
|
|
|
|
{ backgroundColor: themes[theme].auxiliaryBackground }
|
|
|
|
]}
|
|
|
|
forceInset={{ vertical: 'never' }}
|
|
|
|
testID='legal-view'
|
|
|
|
>
|
|
|
|
<StatusBar theme={theme} />
|
|
|
|
<ScrollView
|
|
|
|
contentContainerStyle={[
|
|
|
|
styles.scroll,
|
|
|
|
{
|
|
|
|
backgroundColor: themes[theme].backgroundColor,
|
|
|
|
borderColor: themes[theme].separatorColor
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
{...scrollPersistTaps}
|
|
|
|
>
|
2019-04-26 20:51:09 +00:00
|
|
|
{this.renderItem({ text: 'Terms_of_Service', route: 'terms-of-service', testID: 'legal-terms-button' })}
|
2019-12-11 23:01:12 +00:00
|
|
|
<Separator theme={theme} />
|
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-20 19:24:22 +00:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
server: state.server.server
|
|
|
|
});
|
|
|
|
|
2019-12-11 23:01:12 +00:00
|
|
|
export default connect(mapStateToProps)(withTheme(LegalView));
|