[IMPROVEMENT] Tap app and server version to copy to clipboard (#1425)

This commit is contained in:
Prateek Jain 2019-12-17 19:42:55 +05:30 committed by Diego Mello
parent f1fcdf7379
commit 9084f22ab1
1 changed files with 27 additions and 3 deletions

View File

@ -1,6 +1,6 @@
import React from 'react';
import {
View, Linking, ScrollView, AsyncStorage, SafeAreaView, Switch, Text, Share
View, Linking, ScrollView, AsyncStorage, SafeAreaView, Switch, Text, Share, Clipboard
} from 'react-native';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
@ -31,6 +31,8 @@ import { themedHeader } from '../../utils/navigation';
import SidebarView from '../SidebarView';
import { withSplit } from '../../split';
import Navigation from '../../lib/Navigation';
import { LISTENER } from '../../containers/Toast';
import EventEmitter from '../../utils/events';
const SectionSeparator = React.memo(({ theme }) => (
<View
@ -131,6 +133,20 @@ class SettingsView extends React.Component {
Share.share({ message: isAndroid ? PLAY_MARKET_LINK : APP_STORE_LINK });
}
copyServerVersion = () => {
const { server } = this.props;
this.saveToClipboard(server.version);
}
copyAppVersion = () => {
this.saveToClipboard(getReadableVersion);
}
saveToClipboard = async(content) => {
await Clipboard.setString(content);
EventEmitter.emit(LISTENER, { message: I18n.t('Copied_to_clipboard') });
}
changeTheme = () => {
const { navigation } = this.props;
navigation.navigate('ThemeView');
@ -267,11 +283,19 @@ class SettingsView extends React.Component {
right={this.renderDisclosure}
theme={theme}
/>
<Separator theme={theme} />
<ListItem title={I18n.t('Version_no', { version: getReadableVersion })} testID='settings-view-version' theme={theme} />
<Separator theme={theme} />
<ListItem
title={I18n.t('Version_no', { version: getReadableVersion })}
onPress={this.copyAppVersion}
testID='settings-view-version'
theme={theme}
/>
<Separator theme={theme} />
<ListItem
title={I18n.t('Server_version', { version: server.version })}
onPress={this.copyServerVersion}
subtitle={`${ server.server.split('//')[1] }`}
testID='settings-view-server-version'
theme={theme}