diff --git a/app/components/UI/Navbar/index.js b/app/components/UI/Navbar/index.js index a8fc2a43a94..b75fae769d0 100644 --- a/app/components/UI/Navbar/index.js +++ b/app/components/UI/Navbar/index.js @@ -8,6 +8,8 @@ import { Text, Platform, TouchableOpacity, View, StyleSheet, Image, Keyboard } f import { fontStyles, colors } from '../../../styles/common'; import IonicIcon from 'react-native-vector-icons/Ionicons'; import AntIcon from 'react-native-vector-icons/AntDesign'; +import EvilIcons from 'react-native-vector-icons/EvilIcons'; +import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'; import URL from 'url-parse'; import { strings } from '../../../../locales/i18n'; import AppConstants from '../../../core/AppConstants'; @@ -33,6 +35,12 @@ const styles = StyleSheet.create({ backIcon: { color: colors.primary }, + backIconIOS: { + marginHorizontal: 5 + }, + shareIconIOS: { + marginHorizontal: -5 + }, backButton: { paddingLeft: Platform.OS === 'android' ? 22 : 18, paddingRight: Platform.OS === 'android' ? 22 : 18, @@ -375,6 +383,9 @@ export function getNetworkNavbarOptions(title, translate, navigation) { */ export function getWebviewNavbar(navigation) { const title = navigation.getParam('title', ''); + const share = navigation.getParam('dispatch', () => { + ''; + }); return { title, headerTitleStyle: { @@ -389,16 +400,22 @@ export function getWebviewNavbar(navigation) { ) : ( - + // eslint-disable-next-line react/jsx-no-bind + navigation.pop()} style={styles.backButton}> + + ), headerRight: - Platform.OS === 'ios' ? ( + Platform.OS === 'android' ? ( // eslint-disable-next-line react/jsx-no-bind - navigation.pop()} style={styles.backButton}> - + share()} style={styles.backButton}> + ) : ( - + // eslint-disable-next-line react/jsx-no-bind + share()} style={styles.backButton}> + + ) }; } diff --git a/app/components/Views/SimpleWebview/index.js b/app/components/Views/SimpleWebview/index.js index 47f4a10d0ef..daf0140fa31 100644 --- a/app/components/Views/SimpleWebview/index.js +++ b/app/components/Views/SimpleWebview/index.js @@ -2,6 +2,8 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Web3Webview from 'react-native-web3-webview'; import { getWebviewNavbar } from '../../UI/Navbar'; +import Share from 'react-native-share'; // eslint-disable-line import/default +import Logger from '../../../util/Logger'; export default class SimpleWebview extends Component { static navigationOptions = ({ navigation }) => getWebviewNavbar(navigation); @@ -13,6 +15,21 @@ export default class SimpleWebview extends Component { navigation: PropTypes.object }; + componentDidMount = () => { + const { navigation } = this.props; + navigation && navigation.setParams({ dispatch: this.share }); + }; + + share = () => { + const { navigation } = this.props; + const uri = navigation && navigation.getParam('url', 'about:blank'); + Share.open({ + url: uri + }).catch(err => { + Logger.log('Error while trying to share simple web view', err); + }); + }; + render() { const uri = this.props.navigation.getParam('url', 'about:blank'); return ; diff --git a/app/components/Views/SimpleWebview/index.test.js b/app/components/Views/SimpleWebview/index.test.js index 8cf47564aee..b4bd3ea0134 100644 --- a/app/components/Views/SimpleWebview/index.test.js +++ b/app/components/Views/SimpleWebview/index.test.js @@ -5,7 +5,14 @@ import SimpleWebview from './'; describe('SimpleWebview', () => { it('should render correctly', () => { const wrapper = shallow( - ({ url: 'https://etherscan.io', title: 'etherscan' }) }} /> + ({ url: 'https://etherscan.io', title: 'etherscan' }), + setParams: () => { + ''; + } + }} + /> ); expect(wrapper).toMatchSnapshot(); });