Skip to content

Commit

Permalink
fix(rn): save qrcode to camera roll
Browse files Browse the repository at this point in the history
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
  • Loading branch information
90dy committed Jun 12, 2019
1 parent 36da6f8 commit 2fa7200
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
12 changes: 3 additions & 9 deletions client/react-native/app/common/helpers/saveViewToCamera.js
@@ -1,8 +1,6 @@
import ViewShot from 'react-native-view-shot'
import React, { Component } from 'react'
import { View, CameraRoll, Platform, PermissionsAndroid } from 'react-native'
import { StackActions } from 'react-navigation'
import NavigationService from './NavigationService'
import { requestAndroidPermission } from './permissions'
import I18n from '../locale'

Expand All @@ -19,11 +17,7 @@ export class ViewExportComponent extends Component {
reject(e)
}

this.props.navigation.dispatch(
StackActions.pop({
n: 1,
})
)
this.props.navigation.goBack(null)
}

render () {
Expand All @@ -37,7 +31,7 @@ export class ViewExportComponent extends Component {
}
}

export default async ({ view }) => {
export default async ({ view, navigation }) => {
if (Platform.OS === 'android') {
const allowed = await requestAndroidPermission({
permission: PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
Expand All @@ -56,7 +50,7 @@ export default async ({ view }) => {

try {
const uri = await new Promise((resolve, reject) => {
NavigationService.navigate('virtual/view-export', {
navigation.navigate('virtual/view-export', {
resolve,
reject,
view,
Expand Down
Expand Up @@ -9,8 +9,9 @@ import saveViewToCamera from '@berty/common/helpers/saveViewToCamera'
import QRCodeExport from '../QRExport'
import ActionList from './ActionList'
import { withNamespaces } from 'react-i18next'
import { withNavigation } from 'react-navigation'

const ActionsShare = ({ data, self, inModal, t }) => {
const ActionsShare = ({ data, self, inModal, t, navigation }) => {
const { id, displayName } = data

const pubKey = id
Expand All @@ -35,6 +36,7 @@ const ActionsShare = ({ data, self, inModal, t }) => {
title={t('contacts.save-qrcode-action')}
action={() =>
saveViewToCamera({
navigation,
view: <QRCodeExport data={{ ...data, id: pubKey }} />,
})
}
Expand All @@ -61,4 +63,4 @@ const ActionsShare = ({ data, self, inModal, t }) => {
)
}

export default withNamespaces()(ActionsShare)
export default withNavigation(withNamespaces()(ActionsShare))

0 comments on commit 2fa7200

Please sign in to comment.