REF: ScanQRCode moved to its own stack nav

This commit is contained in:
marcosrdz 2020-05-24 21:04:04 -04:00
parent f7af083254
commit fd3d54d044
2 changed files with 57 additions and 46 deletions

View file

@ -58,6 +58,12 @@ const ReorderWalletsStackNavigator = createStackNavigator({
}, },
}); });
const ScanQRCodeStackNavigator = createStackNavigator({
ScanQRCode: {
screen: ScanQRCode,
},
});
const WalletsStackNavigator = createStackNavigator( const WalletsStackNavigator = createStackNavigator(
{ {
Wallets: { Wallets: {
@ -283,7 +289,10 @@ const HandleOffchainAndOnChainStackNavigator = createStackNavigator(
}, },
}, },
ScanQRCode: { ScanQRCode: {
screen: ScanQRCode, screen: ScanQRCodeStackNavigator,
navigationOptions: {
header: null,
},
}, },
SendDetails: { SendDetails: {
screen: CreateTransactionStackNavigator, screen: CreateTransactionStackNavigator,
@ -352,7 +361,10 @@ const MainBottomTabs = createStackNavigator(
}, },
}, },
ScanQRCode: { ScanQRCode: {
screen: ScanQRCode, screen: ScanQRCodeStackNavigator,
navigationOptions: {
header: null,
},
}, },
LappBrowser: { LappBrowser: {
screen: LappBrowser, screen: LappBrowser,

View file

@ -11,7 +11,6 @@ const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
const createHash = require('create-hash'); const createHash = require('create-hash');
const ScanQRCode = () => { const ScanQRCode = () => {
const showCloseButton = useNavigationParam('showCloseButton') || true;
const showFileImportButton = useNavigationParam('showFileImportButton') || false; const showFileImportButton = useNavigationParam('showFileImportButton') || false;
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const { navigate } = useNavigation(); const { navigate } = useNavigation();
@ -38,7 +37,7 @@ const ScanQRCode = () => {
if (!isLoading) { if (!isLoading) {
setIsLoading(true); setIsLoading(true);
try { try {
if (showCloseButton && launchedBy) { if (launchedBy) {
navigate(launchedBy); navigate(launchedBy);
} }
if (ret.additionalProperties) { if (ret.additionalProperties) {
@ -77,55 +76,7 @@ const ScanQRCode = () => {
setIsLoading(false); setIsLoading(false);
}; };
const dismiss = () => { const showImagePicker = () => {
navigate(launchedBy);
};
return (
<View style={{ flex: 1, backgroundColor: '#000000' }}>
{!isLoading && isFocused && (
<RNCamera
captureAudio={false}
androidCameraPermissionOptions={{
title: 'Permission to use camera',
message: 'We need your permission to use your camera',
buttonPositive: 'OK',
buttonNegative: 'Cancel',
}}
style={{ flex: 1 }}
onBarCodeRead={onBarCodeRead}
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
/>
)}
{showCloseButton && (
<TouchableOpacity
style={{
width: 40,
height: 40,
backgroundColor: 'rgba(0,0,0,0.4)',
justifyContent: 'center',
borderRadius: 20,
position: 'absolute',
right: 16,
top: 44,
}}
onPress={dismiss}
>
<Image style={{ alignSelf: 'center' }} source={require('../../img/close-white.png')} />
</TouchableOpacity>
)}
<TouchableOpacity
style={{
width: 40,
height: 40,
backgroundColor: 'rgba(0,0,0,0.4)',
justifyContent: 'center',
borderRadius: 20,
position: 'absolute',
left: 24,
bottom: 48,
}}
onPress={() => {
if (!isLoading) { if (!isLoading) {
setIsLoading(true); setIsLoading(true);
ImagePicker.launchImageLibrary( ImagePicker.launchImageLibrary(
@ -149,7 +100,55 @@ const ScanQRCode = () => {
}, },
); );
} }
};
const dismiss = () => {
navigate(launchedBy);
};
return (
<View style={{ flex: 1, backgroundColor: '#000000' }}>
{!isLoading && isFocused && (
<RNCamera
captureAudio={false}
androidCameraPermissionOptions={{
title: 'Permission to use camera',
message: 'We need your permission to use your camera',
buttonPositive: 'OK',
buttonNegative: 'Cancel',
}} }}
style={{ flex: 1 }}
onBarCodeRead={onBarCodeRead}
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
/>
)}
<TouchableOpacity
style={{
width: 40,
height: 40,
backgroundColor: 'rgba(0,0,0,0.4)',
justifyContent: 'center',
borderRadius: 20,
position: 'absolute',
right: 16,
top: 44,
}}
onPress={dismiss}
>
<Image style={{ alignSelf: 'center' }} source={require('../../img/close-white.png')} />
</TouchableOpacity>
<TouchableOpacity
style={{
width: 40,
height: 40,
backgroundColor: 'rgba(0,0,0,0.4)',
justifyContent: 'center',
borderRadius: 20,
position: 'absolute',
left: 24,
bottom: 48,
}}
onPress={showImagePicker}
> >
<Icon name="image" type="font-awesome" color="#ffffff" /> <Icon name="image" type="font-awesome" color="#ffffff" />
</TouchableOpacity> </TouchableOpacity>