diff --git a/babel.config.js b/babel.config.js index 02b2b63050..65d52ab4f1 100755 --- a/babel.config.js +++ b/babel.config.js @@ -11,7 +11,8 @@ module.exports = function(api) { plugins: [ ["module-resolver", { "alias": { - "^react-native$": "react-native-web" + "^react-native$": "react-native-web", + "WebView": "react-native-web-webview" } }] ], diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index 1f9a93f0fe..5402db4d62 100755 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -143,7 +143,8 @@ module.exports = { alias: { // Support React Native Web // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/ - 'react-native': 'react-native-web' + 'react-native': 'react-native-web', + 'WebView': 'react-native-web-webview', }, plugins: [ // Adds support for installing with Plug'n'Play, leading to faster installs and adding @@ -186,6 +187,15 @@ module.exports = { ], include: paths.appSrc }, + { + test: /postMock.html$/, + use: { + loader: 'file-loader', + options: { + name: '[name].[ext]', + }, + }, + }, { // "oneOf" will traverse all following loaders until one will // match the requirements. When no loader matches it will fall diff --git a/package-lock.json b/package-lock.json index deef284ec8..936babe57a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29214,6 +29214,14 @@ } } }, + "react-native-web-webview": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/react-native-web-webview/-/react-native-web-webview-0.2.8.tgz", + "integrity": "sha512-4MH32EJj5XMNEBJ0urxxSqAc8JnLQ4Z1djjWQX7S4H6X+Ta5NLmuCnMu99lDcSfPiVTGIr1bN6bhqNdbldc21w==", + "requires": { + "qs": "^6.5.1" + } + }, "react-navigation-stack": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/react-navigation-stack/-/react-navigation-stack-1.0.10.tgz", diff --git a/package.json b/package.json index 46c20c6b6e..1dfc6083a0 100755 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "react-native-recaptcha-v3": "0.0.16", "react-native-vector-icons": "^6.2.0", "react-native-web": "^0.11.x", + "react-native-web-webview": "^0.2.8", "react-navigation-stack": "^1.0.9", "react-navigation-tabs": "^1.0.2", "react-otp-input": "^0.2.2", diff --git a/src/components/auth/Auth.js b/src/components/auth/Auth.js index 0720155eba..9a0aaeb9f1 100644 --- a/src/components/auth/Auth.js +++ b/src/components/auth/Auth.js @@ -1,19 +1,31 @@ // @flow import React from 'react' +import { createStackNavigator } from '../appNavigation/stackNavigation' import { StyleSheet, View } from 'react-native' -import { Button, Headline, Paragraph, Text } from 'react-native-paper' +import { Text } from 'react-native-paper' import { normalize } from 'react-native-elements' import goodWallet from '../../lib/wallet/GoodWallet' import logger from '../../lib/logger/pino-logger' +import { CustomButton } from '../common' +import { Description, LinkButton } from '../signup/components' +import { fontStyle } from '../common/styles' +import { TermsOfUse, PrivacyPolicy } from '../webView/webViewInstances' type Props = { // callback to report to parent component - navigation: any + navigation: any, + screenProps: { + push: Function + } } const log = logger.child({ from: 'Auth' }) class Auth extends React.Component { + static navigationOptions = { + navigationBarHidden: true + } + componentDidMount() { log.info(goodWallet) } @@ -31,30 +43,35 @@ class Auth extends React.Component { this.props.navigation.navigate('SignIn') } + handleNavigateTermsOfUse = () => this.props.screenProps.push('TermsOfUse') + handleNavigatePrivacyPolicy = () => this.props.screenProps.push('PrivacyPolicy') + render() { return ( - - - CREATE YOUR WALLET - - START EARNING MONEY & USE IT FOR PAYMENTS! - - - - - - - + + + { + "Early Access Alpha's tokens will be revoked at the end of the test and they have no value until public release" + } + - + + {`By clicking the 'Create a wallet' button, you are accepting our `} + + Terms of Service + + {` and `} + + Privacy Policy + + + + Create a wallet + - Sign In (Recovery In your Wallet) + Already have a wallet? @@ -70,7 +87,7 @@ const styles = StyleSheet.create({ justifyContent: 'space-between', display: 'flex', flex: 1, - alignItems: 'center' + alignItems: 'stretch' }, topContainer: { flexGrow: 1, @@ -78,49 +95,45 @@ const styles = StyleSheet.create({ justifyContent: 'space-evenly' }, bottomContainer: { - marginBottom: 50, + marginBottom: 30, paddingTop: 30 }, - textContainer: { - paddingTop: '50%', - marginTop: -30 - }, - buttonsContainer: { - marginTop: 30 - }, - fontBase: { - fontFamily: 'Helvetica, "sans-serif"', - color: '#555555', - textAlign: 'center' - }, - headline: { - fontWeight: 'bold', - fontSize: normalize(24) - }, paragraph: { - fontSize: normalize(18), + ...fontStyle, + marginLeft: normalize(20), + marginRight: normalize(20), + fontSize: normalize(20), lineHeight: '1.2em' }, buttonLayout: { - marginTop: 30, - padding: 10 - }, - buttonText: { - fontFamily: 'Helvetica, "sans-serif"', - fontSize: normalize(16), - color: 'white', - fontWeight: 'bold' - }, - signUpButton: { - backgroundColor: '#555555' + padding: normalize(5), + marginTop: normalize(20), + marginBottom: normalize(20), + fontSize: normalize(18) }, signInLink: { - color: '#555555', - fontFamily: 'Helvetica, "sans-serif"', - fontSize: normalize(18), + ...fontStyle, textDecorationLine: 'underline', - textAlign: 'center' + fontSize: normalize(16) + }, + acceptTermsText: { + ...fontStyle, + fontSize: normalize(14) + }, + acceptTermsLink: { + ...fontStyle, + fontSize: normalize(14), + fontWeight: 'bold' } }) -export default Auth +export default createStackNavigator( + { + Auth, + TermsOfUse, + PrivacyPolicy + }, + { + backRouteName: 'Auth' + } +) diff --git a/src/components/common/styles.js b/src/components/common/styles.js index 0efd55f5b1..4cfc7054bf 100644 --- a/src/components/common/styles.js +++ b/src/components/common/styles.js @@ -1,7 +1,6 @@ import { normalize } from 'react-native-elements' export const fontStyle = { - fontFamily: 'Helvetica, "sans-serif"', color: '#555', fontSize: normalize(18), textAlign: 'center' diff --git a/src/components/dashboard/__tests__/__util__/index.js b/src/components/dashboard/__tests__/__util__/index.js index b1c0e824c4..0df9582708 100644 --- a/src/components/dashboard/__tests__/__util__/index.js +++ b/src/components/dashboard/__tests__/__util__/index.js @@ -22,13 +22,7 @@ const withContainer = Component => props => ( ) -export const getWebRouterComponentWithMocks = componentPath => { - const Component = getComponentWithMocks(componentPath) - - const routes = { - Component - } - +export const getWebRouterComponentWithRoutes = routes => { const AppNavigator = createSwitchNavigator(routes) class AppNavigation extends React.Component { static router = AppNavigator.router @@ -40,6 +34,16 @@ export const getWebRouterComponentWithMocks = componentPath => { return withContainer(createBrowserApp(createSwitchNavigator({ AppNavigation }))) } +export const getWebRouterComponentWithMocks = componentPath => { + const Component = getComponentWithMocks(componentPath) + + const routes = { + Component + } + + return getWebRouterComponentWithRoutes(routes) +} + export const convertDateToUTC = unixDate => { let date = new Date(unixDate) return date.getTime() + date.getTimezoneOffset() * 60000 diff --git a/src/components/signup/SignupCompleted.js b/src/components/signup/SignupCompleted.js index a44166f5d4..ac5b2e6d85 100644 --- a/src/components/signup/SignupCompleted.js +++ b/src/components/signup/SignupCompleted.js @@ -16,7 +16,6 @@ export default class SignupCompleted extends React.Component { valid={true} handleSubmit={this.handleSubmit} submitText="Let's start!" - showPrivacyPolicy={false} loading={this.props.screenProps.data.loading} > {`That's great,\nThanks ${this.props.screenProps.data.fullName}!`} diff --git a/src/components/signup/components.js b/src/components/signup/components.js index 7318e6077d..0e34ff1f28 100644 --- a/src/components/signup/components.js +++ b/src/components/signup/components.js @@ -3,6 +3,7 @@ import React from 'react' import { View, StyleSheet } from 'react-native' import { Button, Text } from 'react-native-paper' import { normalize } from 'react-native-elements' +import { PushButton } from '../appNavigation/stackNavigation' export const NextButton = (props: { valid?: boolean, @@ -43,20 +44,12 @@ export const ActionButton = (props: { ) -const Footer = (props: { - valid?: boolean, - showPrivacyPolicy?: string, - submitText?: string, - handleSubmit: () => any, - loading?: boolean -}) => { - const showPrivacyPolicy = props.showPrivacyPolicy === undefined ? true : props.showPrivacyPolicy +const Footer = (props: { valid?: boolean, submitText?: string, handleSubmit: () => any, loading?: boolean }) => { return ( {props.submitText || 'Next'} - {showPrivacyPolicy && console.log('Link button')}>Privacy Policy} ) } @@ -74,7 +67,7 @@ export const Wrapper = (props: any) => { } export const LinkButton = (props: any) => ( - + {props.children} ) @@ -90,7 +83,6 @@ export const Error = (props: any) => ( ) const fontStyle = { - fontFamily: 'Helvetica, "sans-serif"', color: '#555', fontSize: normalize(18), textAlign: 'center' @@ -114,7 +106,6 @@ const styles = StyleSheet.create({ }, linkButton: { color: '#555', - fontFamily: 'Helvetica, "sans-serif"', fontSize: normalize(18), textAlign: 'center', marginTop: normalize(10) diff --git a/src/components/webView/WebViewScreen.js b/src/components/webView/WebViewScreen.js new file mode 100644 index 0000000000..82f7fe100f --- /dev/null +++ b/src/components/webView/WebViewScreen.js @@ -0,0 +1,16 @@ +import React from 'react' +import WebView from 'WebView' + +const WebViewScreen = props => { + return +} + +export default WebViewScreen + +export const createWebViewScreen = (source, title) => { + const CurrentWebView = () => + CurrentWebView.navigationOptions = { + title + } + return CurrentWebView +} diff --git a/src/components/webView/__tests__/WebViewScreen.js b/src/components/webView/__tests__/WebViewScreen.js new file mode 100644 index 0000000000..2cfd70cc23 --- /dev/null +++ b/src/components/webView/__tests__/WebViewScreen.js @@ -0,0 +1,56 @@ +import React from 'react' +import WebViewScreen, { createWebViewScreen } from '../WebViewScreen' +import { TermsOfUse, PrivacyPolicy } from '../webViewInstances' + +// Note: test renderer must be required after react-native. +import renderer from 'react-test-renderer' + +describe('WebViewScreen', () => { + it('renders without errors', () => { + const tree = renderer.create() + expect(tree.toJSON()).toBeTruthy() + }) + + it('matches snapshot', () => { + const component = renderer.create() + const tree = component.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('renders without errors', () => { + const NewWebScreen = createWebViewScreen('https://community.gooddollar.org/terms/', 'Terms of Use') + const tree = renderer.create() + expect(tree.toJSON()).toBeTruthy() + }) + + it('matches snapshot', () => { + const NewWebScreen = createWebViewScreen('https://community.gooddollar.org/terms/', 'Terms of Use') + const component = renderer.create() + const tree = component.toJSON() + expect(tree).toMatchSnapshot() + }) +}) + +describe('WebViewScreen Instances', () => { + it('TermsOfUse renders without errors', () => { + const tree = renderer.create() + expect(tree.toJSON()).toBeTruthy() + }) + + it('TermsOfUse matches snapshot', () => { + const component = renderer.create() + const tree = component.toJSON() + expect(tree).toMatchSnapshot() + }) + + it('PrivacyPolicy renders without errors', () => { + const tree = renderer.create() + expect(tree.toJSON()).toBeTruthy() + }) + + it('PrivacyPolicy matches snapshot', () => { + const component = renderer.create() + const tree = component.toJSON() + expect(tree).toMatchSnapshot() + }) +}) diff --git a/src/components/webView/webViewInstances.js b/src/components/webView/webViewInstances.js new file mode 100644 index 0000000000..53073497c6 --- /dev/null +++ b/src/components/webView/webViewInstances.js @@ -0,0 +1,4 @@ +import { createWebViewScreen } from './WebViewScreen' + +export const TermsOfUse = createWebViewScreen('https://community.gooddollar.org/terms/', 'Terms of Use') +export const PrivacyPolicy = createWebViewScreen('https://community.gooddollar.org/privacy/', 'Privacy Policy')