Merge pull request #6271 from BlueWallet/crash

FIX: Crash due to actionsheet changes
This commit is contained in:
GLaDOS 2024-03-14 01:56:45 +00:00 committed by GitHub
commit b33bc30fd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 118 additions and 164 deletions

43
App.js
View File

@ -254,36 +254,23 @@ const App = () => {
BlueClipboard()
.getClipboardContent()
.then(clipboard => {
if (Platform.OS === 'ios' || Platform.OS === 'macos') {
ActionSheet.showActionSheetWithOptions(
{
options: [loc._.cancel, loc._.continue],
title: loc._.clipboard,
message: contentType === ClipboardContentType.BITCOIN ? loc.wallets.clipboard_bitcoin : loc.wallets.clipboard_lightning,
cancelButtonIndex: 0,
},
buttonIndex => {
if (buttonIndex === 1) {
handleOpenURL({ url: clipboard });
}
},
);
} else {
ActionSheet.showActionSheetWithOptions({
buttons: [
{ text: loc._.cancel, style: 'cancel', onPress: () => {} },
{
text: loc._.continue,
style: 'default',
onPress: () => {
handleOpenURL({ url: clipboard });
},
},
],
ActionSheet.showActionSheetWithOptions(
{
title: loc._.clipboard,
message: contentType === ClipboardContentType.BITCOIN ? loc.wallets.clipboard_bitcoin : loc.wallets.clipboard_lightning,
});
}
options: [loc._.cancel, loc._.continue],
cancelButtonIndex: 0,
},
buttonIndex => {
switch (buttonIndex) {
case 0: // Cancel
break;
case 1:
handleOpenURL({ url: clipboard });
break;
}
},
);
});
};

50
package-lock.json generated
View File

@ -19,9 +19,9 @@
"@react-native-async-storage/async-storage": "1.22.3",
"@react-native-clipboard/clipboard": "1.13.2",
"@react-native-community/push-notification-ios": "1.11.0",
"@react-navigation/drawer": "6.6.12",
"@react-navigation/drawer": "6.6.13",
"@react-navigation/native": "6.1.15",
"@react-navigation/native-stack": "6.9.23",
"@react-navigation/native-stack": "6.9.24",
"@remobile/react-native-qrcode-local-image": "https://github.com/BlueWallet/react-native-qrcode-local-image",
"@spsina/bip47": "github:BlueWallet/bip47#0a2f02c90350802f2ec93afa4e6c8843be2d687c",
"aezeed": "0.0.5",
@ -72,7 +72,7 @@
"react-native-handoff": "https://github.com/BlueWallet/react-native-handoff#31d005f93d31099d0e564590a3bbd052b8a02b39",
"react-native-haptic-feedback": "2.2.0",
"react-native-idle-timer": "https://github.com/BlueWallet/react-native-idle-timer#8587876d68ab5920e79619726aeca9e672beaf2b",
"react-native-image-picker": "7.1.0",
"react-native-image-picker": "7.1.1",
"react-native-ios-context-menu": "github:BlueWallet/react-native-ios-context-menu#v1.15.3",
"react-native-keychain": "8.2.0",
"react-native-linear-gradient": "2.8.3",
@ -6364,11 +6364,11 @@
}
},
"node_modules/@react-navigation/drawer": {
"version": "6.6.12",
"resolved": "https://registry.npmjs.org/@react-navigation/drawer/-/drawer-6.6.12.tgz",
"integrity": "sha512-0V2DzoOCxI2JivejrRxlRUTdlX+JDNymJEsPJLTQ4Aum8LsPC5Ewk+ToO8NQCl4ZyaZC7mANhnN5fYvMq1gtaQ==",
"version": "6.6.13",
"resolved": "https://registry.npmjs.org/@react-navigation/drawer/-/drawer-6.6.13.tgz",
"integrity": "sha512-fMHucgHqY+n8cOR/GgIK6sYs/L1jnaOEiDcH4lmmPJYSDwKy+Srjl32Z5v1/OG2dzgtMyKFxz2/QfMPas8PQaA==",
"dependencies": {
"@react-navigation/elements": "^1.3.27",
"@react-navigation/elements": "^1.3.28",
"color": "^4.2.3",
"warn-once": "^0.1.0"
},
@ -6409,11 +6409,11 @@
}
},
"node_modules/@react-navigation/native-stack": {
"version": "6.9.23",
"resolved": "https://registry.npmjs.org/@react-navigation/native-stack/-/native-stack-6.9.23.tgz",
"integrity": "sha512-8s/DVln/da++1IGjp+3moTKPV0c6nKmCATTflwlknqoM6/yjwy3gLrnV8Tehzib+R3dvTgkqh1bZEn0l9mFQjg==",
"version": "6.9.24",
"resolved": "https://registry.npmjs.org/@react-navigation/native-stack/-/native-stack-6.9.24.tgz",
"integrity": "sha512-+UpruwDcaELmd8cGk8XUDVKFrTMN0x+FbtwNQ7if/hJKbaMg6c43rPtjtiMFX/ycYW7J3owwJ8rcCmU4M7S4Aw==",
"dependencies": {
"@react-navigation/elements": "^1.3.27",
"@react-navigation/elements": "^1.3.28",
"warn-once": "^0.1.0"
},
"peerDependencies": {
@ -19696,9 +19696,9 @@
"license": "MIT"
},
"node_modules/react-native-image-picker": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/react-native-image-picker/-/react-native-image-picker-7.1.0.tgz",
"integrity": "sha512-An0hn2mwqjGAA2mbsXdHRTyoMMklGPT9stIjE2zvkegU7CdoFhowqvVHfnELJNZnfAiSQuIaeY//z0r1R0lsgw==",
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/react-native-image-picker/-/react-native-image-picker-7.1.1.tgz",
"integrity": "sha512-8zQS8RJkGq+jV6bzmIQ560QL2tccXUwouDWktJt7typfNu/QpuDm9pnESeLkdA5MHGTMm8YR09tcV1qtBD+0fg==",
"peerDependencies": {
"react": "*",
"react-native": "*"
@ -27338,11 +27338,11 @@
}
},
"@react-navigation/drawer": {
"version": "6.6.12",
"resolved": "https://registry.npmjs.org/@react-navigation/drawer/-/drawer-6.6.12.tgz",
"integrity": "sha512-0V2DzoOCxI2JivejrRxlRUTdlX+JDNymJEsPJLTQ4Aum8LsPC5Ewk+ToO8NQCl4ZyaZC7mANhnN5fYvMq1gtaQ==",
"version": "6.6.13",
"resolved": "https://registry.npmjs.org/@react-navigation/drawer/-/drawer-6.6.13.tgz",
"integrity": "sha512-fMHucgHqY+n8cOR/GgIK6sYs/L1jnaOEiDcH4lmmPJYSDwKy+Srjl32Z5v1/OG2dzgtMyKFxz2/QfMPas8PQaA==",
"requires": {
"@react-navigation/elements": "^1.3.27",
"@react-navigation/elements": "^1.3.28",
"color": "^4.2.3",
"warn-once": "^0.1.0"
}
@ -27364,11 +27364,11 @@
}
},
"@react-navigation/native-stack": {
"version": "6.9.23",
"resolved": "https://registry.npmjs.org/@react-navigation/native-stack/-/native-stack-6.9.23.tgz",
"integrity": "sha512-8s/DVln/da++1IGjp+3moTKPV0c6nKmCATTflwlknqoM6/yjwy3gLrnV8Tehzib+R3dvTgkqh1bZEn0l9mFQjg==",
"version": "6.9.24",
"resolved": "https://registry.npmjs.org/@react-navigation/native-stack/-/native-stack-6.9.24.tgz",
"integrity": "sha512-+UpruwDcaELmd8cGk8XUDVKFrTMN0x+FbtwNQ7if/hJKbaMg6c43rPtjtiMFX/ycYW7J3owwJ8rcCmU4M7S4Aw==",
"requires": {
"@react-navigation/elements": "^1.3.27",
"@react-navigation/elements": "^1.3.28",
"warn-once": "^0.1.0"
}
},
@ -37481,9 +37481,9 @@
"from": "react-native-idle-timer@https://github.com/BlueWallet/react-native-idle-timer#8587876d68ab5920e79619726aeca9e672beaf2b"
},
"react-native-image-picker": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/react-native-image-picker/-/react-native-image-picker-7.1.0.tgz",
"integrity": "sha512-An0hn2mwqjGAA2mbsXdHRTyoMMklGPT9stIjE2zvkegU7CdoFhowqvVHfnELJNZnfAiSQuIaeY//z0r1R0lsgw=="
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/react-native-image-picker/-/react-native-image-picker-7.1.1.tgz",
"integrity": "sha512-8zQS8RJkGq+jV6bzmIQ560QL2tccXUwouDWktJt7typfNu/QpuDm9pnESeLkdA5MHGTMm8YR09tcV1qtBD+0fg=="
},
"react-native-ios-context-menu": {
"version": "git+ssh://git@github.com/BlueWallet/react-native-ios-context-menu.git#e5c1217cd220bfab6e6d9a7c65838545082e3f8e",

View File

@ -29,6 +29,7 @@ import { TransactionListItem } from '../../components/TransactionListItem';
import { scanQrHelper } from '../../helpers/scan-qr';
import { useTheme } from '../../components/themes';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
import presentAlert from '../../components/Alert';
const A = require('../../blue_modules/analytics');
const fs = require('../../blue_modules/fs');
@ -311,51 +312,43 @@ const WalletsList = () => {
const sendButtonLongPress = async () => {
const isClipboardEmpty = (await BlueClipboard().getClipboardContent()).trim().length === 0;
if (Platform.OS === 'ios') {
const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan];
if (!isClipboardEmpty) {
options.push(loc.wallets.list_long_clipboard);
}
ActionSheet.showActionSheetWithOptions(
{ options, cancelButtonIndex: 0, anchor: findNodeHandle(walletActionButtonsRef.current) },
buttonIndex => {
if (buttonIndex === 1) {
fs.showImagePickerAndReadImage().then(onBarScanned);
} else if (buttonIndex === 2) {
scanQrHelper(navigate, routeName, false).then(onBarScanned);
} else if (buttonIndex === 3) {
copyFromClipboard();
}
},
);
} else if (Platform.OS === 'android') {
const buttons = [
{
text: loc._.cancel,
onPress: () => {},
style: 'cancel',
},
{
text: loc.wallets.list_long_choose,
onPress: () => fs.showImagePickerAndReadImage().then(onBarScanned),
},
{
text: loc.wallets.list_long_scan,
onPress: () => scanQrHelper(navigate, routeName, false).then(onBarScanned),
},
];
if (!isClipboardEmpty) {
buttons.push({
text: loc.wallets.list_long_clipboard,
onPress: copyFromClipboard,
});
}
ActionSheet.showActionSheetWithOptions({
title: '',
message: '',
buttons,
});
const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan];
if (!isClipboardEmpty) {
options.push(loc.wallets.list_long_clipboard);
}
ActionSheet.showActionSheetWithOptions(
{
title: loc.send.header,
options,
cancelButtonIndex: 0,
anchor: findNodeHandle(walletActionButtonsRef.current),
},
buttonIndex => {
switch (buttonIndex) {
case 0:
break;
case 1:
fs.showImagePickerAndReadImage()
.then(onBarScanned)
.catch(error => {
console.log(error);
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
presentAlert({ title: loc.errors.error, message: error.message });
});
break;
case 2:
scanQrHelper(navigate, routeName, true).then(data => onBarScanned(data));
break;
case 3:
if (!isClipboardEmpty) {
copyFromClipboard();
}
break;
}
},
);
};
const onLayout = _e => {

View File

@ -6,14 +6,13 @@ import {
FlatList,
InteractionManager,
PixelRatio,
Platform,
ScrollView,
StyleSheet,
Text,
findNodeHandle,
TouchableOpacity,
View,
I18nManager,
findNodeHandle,
} from 'react-native';
import { Icon } from 'react-native-elements';
import { useRoute, useNavigation, useFocusEffect } from '@react-navigation/native';
@ -33,8 +32,9 @@ import TransactionsNavigationHeader, { actionKeys } from '../../components/Trans
import { TransactionListItem } from '../../components/TransactionListItem';
import presentAlert from '../../components/Alert';
import PropTypes from 'prop-types';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
import { scanQrHelper } from '../../helpers/scan-qr';
import { useTheme } from '../../components/themes';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
const fs = require('../../blue_modules/fs');
const BlueElectrum = require('../../blue_modules/BlueElectrum');
@ -366,7 +366,13 @@ const WalletTransactions = ({ navigation }) => {
};
const choosePhoto = () => {
fs.showImagePickerAndReadImage().then(onBarCodeRead);
fs.showImagePickerAndReadImage()
.then(onBarCodeRead)
.catch(error => {
console.log(error);
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
presentAlert({ title: loc.errors.error, message: error.message });
});
};
const copyFromClipboard = async () => {
@ -404,70 +410,38 @@ const WalletTransactions = ({ navigation }) => {
const sendButtonLongPress = async () => {
const isClipboardEmpty = (await BlueClipboard().getClipboardContent()).trim().length === 0;
if (Platform.OS === 'ios') {
const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan];
if (!isClipboardEmpty) {
options.push(loc.wallets.list_long_clipboard);
}
ActionSheet.showActionSheetWithOptions(
{ options, cancelButtonIndex: 0, anchor: findNodeHandle(walletActionButtonsRef.current) },
buttonIndex => {
if (buttonIndex === 1) {
choosePhoto();
} else if (buttonIndex === 2) {
requestCameraAuthorization().then(() =>
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: name,
onBarScanned: onBarCodeRead,
showFileImportButton: false,
},
}),
);
} else if (buttonIndex === 3) {
copyFromClipboard();
}
},
);
} else if (Platform.OS === 'android') {
const buttons = [
{
text: loc._.cancel,
onPress: () => {},
style: 'cancel',
},
{
text: loc.wallets.list_long_choose,
onPress: choosePhoto,
},
{
text: loc.wallets.list_long_scan,
onPress: () =>
requestCameraAuthorization().then(() => {
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: name,
onBarScanned: onBarCodeRead,
showFileImportButton: false,
},
});
}),
},
];
if (!isClipboardEmpty) {
buttons.push({
text: loc.wallets.list_long_clipboard,
onPress: copyFromClipboard,
});
}
ActionSheet.showActionSheetWithOptions({
title: '',
message: '',
buttons,
});
const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan];
const cancelButtonIndex = 0;
if (!isClipboardEmpty) {
options.push(loc.wallets.list_long_clipboard);
}
ActionSheet.showActionSheetWithOptions(
{
title: loc.send.header,
options,
cancelButtonIndex,
anchor: findNodeHandle(walletActionButtonsRef.current),
},
async buttonIndex => {
switch (buttonIndex) {
case 0:
break;
case 1:
choosePhoto();
break;
case 2:
scanQrHelper(navigate, name, true).then(data => onBarCodeRead(data));
break;
case 3:
if (!isClipboardEmpty) {
copyFromClipboard();
}
break;
}
},
);
};
const navigateToViewEditCosigners = () => {