Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: terms and conditions #631

Merged
merged 7 commits into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/components/Nav/App/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ exports[`App should render correctly 1`] = `
},
"QRScanner": null,
"SyncWithExtensionSuccess": null,
"Webview": Object {
"childRouters": Object {
"SimpleWebview": null,
},
"getActionCreators": [Function],
"getActionForPathAndParams": [Function],
"getComponentForRouteName": [Function],
"getComponentForState": [Function],
"getPathAndParamsForState": [Function],
"getScreenOptions": [Function],
"getStateForAction": [Function],
},
},
"getActionCreators": [Function],
"getActionForPathAndParams": [Function],
Expand Down Expand Up @@ -561,6 +573,18 @@ exports[`App should render correctly 1`] = `
},
"QRScanner": null,
"SyncWithExtensionSuccess": null,
"Webview": Object {
"childRouters": Object {
"SimpleWebview": null,
},
"getActionCreators": [Function],
"getActionForPathAndParams": [Function],
"getComponentForRouteName": [Function],
"getComponentForState": [Function],
"getPathAndParamsForState": [Function],
"getScreenOptions": [Function],
"getStateForAction": [Function],
},
},
"getActionCreators": [Function],
"getActionForPathAndParams": [Function],
Expand Down
13 changes: 13 additions & 0 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Entry from '../../Views/Entry';
import LockScreen from '../../Views/LockScreen';
import Main from '../Main';
import DrawerView from '../../UI/DrawerView';
import SimpleWebview from '../../Views/SimpleWebview';

/**
* Stack navigator responsible for the onboarding process
Expand Down Expand Up @@ -58,6 +59,18 @@ const OnboardingRootNav = createStackNavigator(
},
QRScanner: {
screen: QRScanner
},
Webview: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

screen: createStackNavigator(
{
SimpleWebview: {
screen: SimpleWebview
}
},
{
mode: 'modal'
}
)
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,24 @@ exports[`ImportFromSeed should render correctly 1`] = `
IMPORT
</StyledButton>
</View>
<View
style={
Object {
"paddingTop": 30,
}
}
>
<TermsAndConditions
action="IMPORT"
navigation={
Object {
"state": Object {
"params": Object {},
},
}
}
/>
</View>
</View>
</KeyboardAwareScrollViewMock>
</SafeAreaView>
Expand Down
10 changes: 10 additions & 0 deletions app/components/Views/ImportFromSeed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import SecureKeychain from '../../../core/SecureKeychain';
import AppConstants from '../../../core/AppConstants';
import setOnboardingWizardStep from '../../../actions/wizard';
import { NavigationActions } from 'react-navigation';
import TermsAndConditions from '../TermsAndConditions';

const styles = StyleSheet.create({
mainWrapper: {
Expand Down Expand Up @@ -97,6 +98,9 @@ const styles = StyleSheet.create({
},
biometrySwitch: {
flex: 0
},
termsAndConditions: {
paddingTop: 30
}
});

Expand Down Expand Up @@ -383,6 +387,12 @@ class ImportFromSeed extends Component {
)}
</StyledButton>
</View>
<View style={styles.termsAndConditions}>
<TermsAndConditions
navigation={this.props.navigation}
action={strings('import_from_seed.import_button')}
/>
</View>
</View>
</KeyboardAwareScrollView>
</SafeAreaView>
Expand Down
12 changes: 11 additions & 1 deletion app/components/Views/Onboarding/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { connect } from 'react-redux';
import SecureKeychain from '../../../core/SecureKeychain';
import Engine from '../../../core/Engine';
import FadeOutOverlay from '../../UI/FadeOutOverlay';
import TermsAndConditions from '../TermsAndConditions';

const styles = StyleSheet.create({
flex: {
Expand All @@ -29,9 +30,12 @@ const styles = StyleSheet.create({
},
ctas: {
justifyContent: 'flex-end',
height: 190,
height: 250,
paddingBottom: 40
},
termsAndConditions: {
paddingTop: 30
},
foxWrapper: {
width: Platform.OS === 'ios' ? 100 : 66,
height: Platform.OS === 'ios' ? 100 : 66,
Expand Down Expand Up @@ -195,6 +199,12 @@ class Onboarding extends Component {
{strings('onboarding.import_wallet_button')}
</StyledButton>
</View>
<View style={[styles.ctaWrapper, styles.termsAndConditions]}>
<TermsAndConditions
navigation={this.props.navigation}
action={strings('onboarding.start_exploring_now')}
/>
</View>
</View>
{this.state.existingUser && (
<View style={styles.footer}>
Expand Down
10 changes: 10 additions & 0 deletions app/components/Views/SyncWithExtensionSuccess/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import AsyncStorage from '@react-native-community/async-storage';
import setOnboardingWizardStep from '../../../actions/wizard';
import { NavigationActions } from 'react-navigation';
import { connect } from 'react-redux';
import TermsAndConditions from '../TermsAndConditions';

const styles = StyleSheet.create({
mainWrapper: {
Expand Down Expand Up @@ -43,6 +44,9 @@ const styles = StyleSheet.create({
icon: {
color: colors.green500,
marginBottom: 30
},
termsAndConditions: {
padding: 30
}
});

Expand Down Expand Up @@ -113,6 +117,12 @@ class SyncWithExtensionSuccess extends Component {
{strings('sync_with_extension_success.button_continue')}
</StyledButton>
</View>
<View style={styles.termsAndConditions}>
<TermsAndConditions
navigation={this.props.navigation}
action={strings('sync_with_extension_success.button_continue')}
/>
</View>
</View>
</SafeAreaView>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TermsAndConditions should render correctly 1`] = `
<TermsAndConditions
action="import"
/>
`;
65 changes: 65 additions & 0 deletions app/components/Views/TermsAndConditions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native';
import PropTypes from 'prop-types';
import { colors, fontStyles } from '../../../styles/common';
import { TouchableOpacity } from 'react-native-gesture-handler';
import { strings } from '../../../../locales/i18n';

const TERMS_AND_CONDITIONS = 'https://metamask.io/terms.html';

const styles = StyleSheet.create({
mainWrapper: {
backgroundColor: colors.transparent,
flex: 1,
width: '80%',
alignSelf: 'center'
},
text: {
...fontStyles.normal,
color: colors.grey500,
textAlign: 'center'
},
link: {
textDecorationLine: 'underline'
}
});

/**
* View that is displayed in the flow to agree terms and conditions
*/
export default class TermsAndConditions extends Component {
static propTypes = {
/**
/* navigation object required to push and pop other views
*/
navigation: PropTypes.object,
/**
* Action string to be clicked to agree terms and conditions
*/
action: PropTypes.string
};

press = () => {
const { navigation } = this.props;
navigation.navigate('Webview', {
url: TERMS_AND_CONDITIONS,
title: strings('terms_and_conditions.title')
});
};

render() {
const { action } = this.props;
return (
<View style={styles.mainWrapper}>
<TouchableOpacity onPress={this.press}>
<Text style={styles.text}>
{strings('terms_and_conditions.description', {
action
})}
<Text style={styles.link}>{strings('terms_and_conditions.terms')}</Text>.
</Text>
</TouchableOpacity>
</View>
);
}
}
19 changes: 19 additions & 0 deletions app/components/Views/TermsAndConditions/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { shallow } from 'enzyme';
import TermsAndConditions from './';
import { Provider } from 'react-redux';
import configureMockStore from 'redux-mock-store';

const mockStore = configureMockStore();
const store = mockStore({});

describe('TermsAndConditions', () => {
it('should render correctly', () => {
const wrapper = shallow(
<Provider store={store}>
<TermsAndConditions action="import" />
</Provider>
);
expect(wrapper).toMatchSnapshot();
});
});
5 changes: 5 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@
"add_collectible": "ADD"
}
},
"terms_and_conditions": {
"title": "Terms and Conditions",
"description": "By clicking \"{{action}}\" you agree to these ",
"terms": "Terms and Conditions"
},
"token": {
"token_symbol": "Token Symbol",
"token_address": "Token Address",
Expand Down
5 changes: 5 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@
"add_collectible": "AGREGAR COLECCIONABLE"
}
},
"terms_and_conditions": {
"title": "Términos y Condiciones",
"description": "Haciendo click en \"{{action}}\" estas de acuerdo con estos ",
"terms": "Términos y Condiciones"
},
"token": {
"token_symbol": "Símbolo del Token",
"token_address": "Dirección del Token",
Expand Down