import React from 'react'; import { View, Linking, ScrollView, AsyncStorage, SafeAreaView, Switch } from 'react-native'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { toggleMarkdown as toggleMarkdownAction } from '../../actions/markdown'; import { SWITCH_TRACK_COLOR } from '../../constants/colors'; import { DrawerButton } from '../../containers/HeaderButton'; import StatusBar from '../../containers/StatusBar'; import ListItem from '../../containers/ListItem'; import { DisclosureImage } from '../../containers/DisclosureIndicator'; import Separator from '../../containers/Separator'; import I18n from '../../i18n'; import { MARKDOWN_KEY } from '../../lib/rocketchat'; import { getReadableVersion, getDeviceModel } from '../../utils/deviceInfo'; import openLink from '../../utils/openLink'; import scrollPersistTaps from '../../utils/scrollPersistTaps'; import { showErrorAlert } from '../../utils/info'; import styles from './styles'; import sharedStyles from '../Styles'; const LICENSE_LINK = 'https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/develop/LICENSE'; const SectionSeparator = React.memo(() => ); class SettingsView extends React.Component { static navigationOptions = ({ navigation }) => ({ headerLeft: , title: I18n.t('Settings') }); static propTypes = { navigation: PropTypes.object, server: PropTypes.object, useMarkdown: PropTypes.bool, toggleMarkdown: PropTypes.func } toggleMarkdown = (value) => { AsyncStorage.setItem(MARKDOWN_KEY, JSON.stringify(value)); const { toggleMarkdown } = this.props; toggleMarkdown(value); } navigateToRoom = (room) => { const { navigation } = this.props; navigation.navigate(room); } sendEmail = async() => { const subject = encodeURI('React Native App Support'); const email = encodeURI('support@rocket.chat'); const description = encodeURI(` version: ${ getReadableVersion } device: ${ getDeviceModel } `); try { await Linking.openURL(`mailto:${ email }?subject=${ subject }&body=${ description }`); } catch (e) { showErrorAlert(I18n.t('error-email-send-failed', { message: 'support@rocket.chat' })); } } onPressLicense = () => openLink(LICENSE_LINK) renderDisclosure = () => renderMarkdownSwitch = () => { const { useMarkdown } = this.props; return ( ); } render() { const { server } = this.props; return ( this.navigateToRoom('LanguageView')} showActionIndicator testID='settings-view-language' right={this.renderDisclosure} /> this.renderMarkdownSwitch()} /> ); } } const mapStateToProps = state => ({ server: state.server, useMarkdown: state.markdown.useMarkdown }); const mapDispatchToProps = dispatch => ({ toggleMarkdown: params => dispatch(toggleMarkdownAction(params)) }); export default connect(mapStateToProps, mapDispatchToProps)(SettingsView);