DEL: Remove outdated code for unsupported macOS

This commit is contained in:
Marcos Rodriguez Velez 2023-02-25 12:20:46 -04:00
parent 0cb6647177
commit 64a5863af8
11 changed files with 72 additions and 143 deletions

View file

@ -83,8 +83,7 @@ npx react-native run-ios
npm run maccatalystpatches npm run maccatalystpatches
``` ```
Once the patches are applied, open Xcode and select "My Mac" as destination. If you are running macOS Catalina, you may need to remove all iOS 14 Widget targets. Once the patches are applied, open Xcode and select "My Mac" as destination.
## TESTS ## TESTS

View file

@ -1,8 +1,7 @@
import AsyncStorage from '@react-native-async-storage/async-storage'; import AsyncStorage from '@react-native-async-storage/async-storage';
import { Platform } from 'react-native'; import { Platform } from 'react-native';
import { getSystemName, isTablet, getDeviceType } from 'react-native-device-info'; import { isTablet, getDeviceType } from 'react-native-device-info';
const isMacCatalina = getSystemName() === 'Mac OS X';
const isDesktop = getDeviceType() === 'Desktop'; const isDesktop = getDeviceType() === 'Desktop';
const getIsTorCapable = () => { const getIsTorCapable = () => {
let capable = true; let capable = true;
@ -37,4 +36,4 @@ export async function isTorDaemonDisabled() {
export const isHandset = getDeviceType() === 'Handset'; export const isHandset = getDeviceType() === 'Handset';
export const isTorCapable = getIsTorCapable(); export const isTorCapable = getIsTorCapable();
export { isMacCatalina, isDesktop, isTablet }; export { isDesktop, isTablet };

View file

@ -6,8 +6,6 @@ import DocumentPicker from 'react-native-document-picker';
import { launchCamera, launchImageLibrary } from 'react-native-image-picker'; import { launchCamera, launchImageLibrary } from 'react-native-image-picker';
import { presentCameraNotAuthorizedAlert } from '../class/camera'; import { presentCameraNotAuthorizedAlert } from '../class/camera';
import { isDesktop } from '../blue_modules/environment'; import { isDesktop } from '../blue_modules/environment';
import ActionSheet from '../screen/ActionSheet';
import BlueClipboard from './clipboard';
import alert from '../components/Alert'; import alert from '../components/Alert';
const LocalQRCode = require('@remobile/react-native-qrcode-local-image'); const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
@ -205,43 +203,8 @@ const showFilePickerAndReadFile = async function () {
} }
}; };
// Intended for macOS Catalina. Not for long press shortcut
const showActionSheet = async props => {
const isClipboardEmpty = (await BlueClipboard.getClipboardContent()).trim().length === 0;
let copyFromClipboardIndex;
const options = [loc._.cancel, loc.wallets.take_photo, loc.wallets.list_long_choose];
if (!isClipboardEmpty) {
options.push(loc.wallets.list_long_clipboard);
copyFromClipboardIndex = options.length - 1;
}
options.push(loc.wallets.import_file);
const importFileButtonIndex = options.length - 1;
return new Promise(resolve =>
ActionSheet.showActionSheetWithOptions({ options, cancelButtonIndex: 0, anchor: props.anchor }, async buttonIndex => {
if (buttonIndex === 1) {
takePhotoWithImagePickerAndReadPhoto().then(resolve);
} else if (buttonIndex === 2) {
showImagePickerAndReadImage()
.then(resolve)
.catch(error => alert(error.message));
} else if (buttonIndex === copyFromClipboardIndex) {
const clipboard = await BlueClipboard.getClipboardContent();
resolve(clipboard);
} else if (importFileButtonIndex) {
const { data } = await showFilePickerAndReadFile();
if (data) {
resolve(data);
}
}
}),
);
};
module.exports.writeFileAndExport = writeFileAndExport; module.exports.writeFileAndExport = writeFileAndExport;
module.exports.openSignedTransaction = openSignedTransaction; module.exports.openSignedTransaction = openSignedTransaction;
module.exports.showFilePickerAndReadFile = showFilePickerAndReadFile; module.exports.showFilePickerAndReadFile = showFilePickerAndReadFile;
module.exports.showImagePickerAndReadImage = showImagePickerAndReadImage; module.exports.showImagePickerAndReadImage = showImagePickerAndReadImage;
module.exports.takePhotoWithImagePickerAndReadPhoto = takePhotoWithImagePickerAndReadPhoto; module.exports.takePhotoWithImagePickerAndReadPhoto = takePhotoWithImagePickerAndReadPhoto;
module.exports.showActionSheet = showActionSheet;

View file

@ -39,6 +39,21 @@
<key>orderHint</key> <key>orderHint</key>
<integer>2</integer> <integer>2</integer>
</dict> </dict>
<key>Stickers.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
</dict>
<key>TodayExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>5</integer>
</dict>
<key>WidgetsExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>6</integer>
</dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
<dict> <dict>

View file

@ -1,13 +1,11 @@
import React, { useState, useContext, useRef } from 'react'; import React, { useState, useContext, useRef } from 'react';
import { useNavigation, useRoute, useTheme } from '@react-navigation/native'; import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
import { StyleSheet, View, KeyboardAvoidingView, Platform, TextInput, Keyboard, findNodeHandle } from 'react-native'; import { StyleSheet, View, KeyboardAvoidingView, Platform, TextInput, Keyboard } from 'react-native';
import loc from '../../loc'; import loc from '../../loc';
import { BlueButton, BlueButtonLink, BlueCard, BlueSpacing10, BlueSpacing20, BlueText, SafeBlueArea } from '../../BlueComponents'; import { BlueButton, BlueButtonLink, BlueCard, BlueSpacing10, BlueSpacing20, BlueText, SafeBlueArea } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle'; import navigationStyle from '../../components/navigationStyle';
import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueStorageContext } from '../../blue_modules/storage-context';
import { isMacCatalina } from '../../blue_modules/environment';
const fs = require('../../blue_modules/fs');
const IsItMyAddress = () => { const IsItMyAddress = () => {
/** @type {AbstractWallet[]} */ /** @type {AbstractWallet[]} */
@ -56,18 +54,14 @@ const IsItMyAddress = () => {
}; };
const importScan = () => { const importScan = () => {
if (isMacCatalina) { navigate('ScanQRCodeRoot', {
fs.showActionSheet({ anchor: findNodeHandle(scanButtonRef.current) }).then(onBarScanned); screen: 'ScanQRCode',
} else { params: {
navigate('ScanQRCodeRoot', { launchedBy: name,
screen: 'ScanQRCode', onBarScanned,
params: { showFileImportButton: true,
launchedBy: name, },
onBarScanned, });
showFileImportButton: true,
},
});
}
}; };
const clearAddressInput = () => { const clearAddressInput = () => {

View file

@ -1,21 +1,9 @@
import React, { useContext, useEffect, useRef, useState } from 'react'; import React, { useContext, useEffect, useRef, useState } from 'react';
import { import { ActivityIndicator, TouchableOpacity, ScrollView, View, TextInput, Linking, Platform, Text, StyleSheet } from 'react-native';
ActivityIndicator,
TouchableOpacity,
ScrollView,
View,
TextInput,
Linking,
Platform,
Text,
StyleSheet,
findNodeHandle,
} from 'react-native';
import Clipboard from '@react-native-clipboard/clipboard'; import Clipboard from '@react-native-clipboard/clipboard';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import DocumentPicker from 'react-native-document-picker'; import DocumentPicker from 'react-native-document-picker';
import { useNavigation, useRoute, useTheme, useIsFocused } from '@react-navigation/native'; import { useNavigation, useRoute, useTheme, useIsFocused } from '@react-navigation/native';
import { isMacCatalina } from '../../blue_modules/environment';
import RNFS from 'react-native-fs'; import RNFS from 'react-native-fs';
import Biometric from '../../class/biometrics'; import Biometric from '../../class/biometrics';
@ -220,18 +208,14 @@ const PsbtWithHardwareWallet = () => {
}; };
const openScanner = () => { const openScanner = () => {
if (isMacCatalina) { navigation.navigate('ScanQRCodeRoot', {
fs.showActionSheet({ anchor: findNodeHandle(openScannerButton.current) }).then(data => onBarScanned({ data })); screen: 'ScanQRCode',
} else { params: {
navigation.navigate('ScanQRCodeRoot', { launchedBy: route.name,
screen: 'ScanQRCode', showFileImportButton: false,
params: { onBarScanned,
launchedBy: route.name, },
showFileImportButton: false, });
onBarScanned,
},
});
}
}; };
if (txHex) return _renderBroadcastHex(); if (txHex) return _renderBroadcastHex();

View file

@ -15,9 +15,7 @@ import {
import navigationStyle from '../../components/navigationStyle'; import navigationStyle from '../../components/navigationStyle';
import Privacy from '../../blue_modules/Privacy'; import Privacy from '../../blue_modules/Privacy';
import loc from '../../loc'; import loc from '../../loc';
import { isMacCatalina } from '../../blue_modules/environment';
import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueStorageContext } from '../../blue_modules/storage-context';
const fs = require('../../blue_modules/fs');
const WalletsImport = () => { const WalletsImport = () => {
const navigation = useNavigation(); const navigation = useNavigation();
@ -94,18 +92,14 @@ const WalletsImport = () => {
}; };
const importScan = () => { const importScan = () => {
if (isMacCatalina) { navigation.navigate('ScanQRCodeRoot', {
fs.showActionSheet().then(onBarScanned); screen: 'ScanQRCode',
} else { params: {
navigation.navigate('ScanQRCodeRoot', { launchedBy: route.name,
screen: 'ScanQRCode', onBarScanned,
params: { showFileImportButton: true,
launchedBy: route.name, },
onBarScanned, });
showFileImportButton: true,
},
});
}
}; };
const speedBackdoorTap = () => { const speedBackdoorTap = () => {

View file

@ -23,7 +23,7 @@ import loc from '../../loc';
import { FContainer, FButton } from '../../components/FloatButtons'; import { FContainer, FButton } from '../../components/FloatButtons';
import { useFocusEffect, useIsFocused, useNavigation, useRoute, useTheme } from '@react-navigation/native'; import { useFocusEffect, useIsFocused, useNavigation, useRoute, useTheme } from '@react-navigation/native';
import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueStorageContext } from '../../blue_modules/storage-context';
import { isDesktop, isMacCatalina, isTablet } from '../../blue_modules/environment'; import { isDesktop, isTablet } from '../../blue_modules/environment';
import BlueClipboard from '../../blue_modules/clipboard'; import BlueClipboard from '../../blue_modules/clipboard';
import navigationStyle from '../../components/navigationStyle'; import navigationStyle from '../../components/navigationStyle';
import { TransactionListItem } from '../../components/TransactionListItem'; import { TransactionListItem } from '../../components/TransactionListItem';
@ -265,7 +265,7 @@ const WalletsList = () => {
<FContainer ref={walletActionButtonsRef}> <FContainer ref={walletActionButtonsRef}>
<FButton <FButton
onPress={onScanButtonPressed} onPress={onScanButtonPressed}
onLongPress={isMacCatalina ? undefined : sendButtonLongPress} onLongPress={ sendButtonLongPress}
icon={<Image resizeMode="stretch" source={scanImage} />} icon={<Image resizeMode="stretch" source={scanImage} />}
text={loc.send.details_scan} text={loc.send.details_scan}
/> />
@ -281,11 +281,8 @@ const WalletsList = () => {
}; };
const onScanButtonPressed = () => { const onScanButtonPressed = () => {
if (isMacCatalina) { scanqrHelper(navigate, routeName, false).then(onBarScanned);
fs.showActionSheet({ anchor: findNodeHandle(walletActionButtonsRef.current) }).then(onBarScanned);
} else {
scanqrHelper(navigate, routeName, false).then(onBarScanned);
}
}; };
const onBarScanned = value => { const onBarScanned = value => {
@ -303,9 +300,7 @@ const WalletsList = () => {
const sendButtonLongPress = async () => { const sendButtonLongPress = async () => {
const isClipboardEmpty = (await BlueClipboard.getClipboardContent()).trim().length === 0; const isClipboardEmpty = (await BlueClipboard.getClipboardContent()).trim().length === 0;
if (Platform.OS === 'ios') { if (Platform.OS === 'ios') {
if (isMacCatalina) {
fs.showActionSheet({ anchor: findNodeHandle(walletActionButtonsRef.current) }).then(onBarScanned);
} else {
const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan]; const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan];
if (!isClipboardEmpty) { if (!isClipboardEmpty) {
options.push(loc.wallets.list_long_clipboard); options.push(loc.wallets.list_long_clipboard);
@ -320,9 +315,9 @@ const WalletsList = () => {
} else if (buttonIndex === 3) { } else if (buttonIndex === 3) {
copyFromClipboard(); copyFromClipboard();
} }
}, }
); );
}
} else if (Platform.OS === 'android') { } else if (Platform.OS === 'android') {
const buttons = [ const buttons = [
{ {

View file

@ -27,7 +27,7 @@ import ActionSheet from '../ActionSheet';
import loc from '../../loc'; import loc from '../../loc';
import { FContainer, FButton } from '../../components/FloatButtons'; import { FContainer, FButton } from '../../components/FloatButtons';
import { BlueStorageContext } from '../../blue_modules/storage-context'; import { BlueStorageContext } from '../../blue_modules/storage-context';
import { isDesktop, isMacCatalina } from '../../blue_modules/environment'; import { isDesktop } from '../../blue_modules/environment';
import BlueClipboard from '../../blue_modules/clipboard'; import BlueClipboard from '../../blue_modules/clipboard';
import LNNodeBar from '../../components/LNNodeBar'; import LNNodeBar from '../../components/LNNodeBar';
import TransactionsNavigationHeader from '../../components/TransactionsNavigationHeader'; import TransactionsNavigationHeader from '../../components/TransactionsNavigationHeader';
@ -371,10 +371,7 @@ const WalletTransactions = () => {
}; };
const sendButtonLongPress = async () => { const sendButtonLongPress = async () => {
if (isMacCatalina) { const isClipboardEmpty = (await BlueClipboard.getClipboardContent()).trim().length === 0;
fs.showActionSheet({ anchor: walletActionButtonsRef.current }).then(onBarCodeRead);
} else {
const isClipboardEmpty = (await BlueClipboard.getClipboardContent()).trim().length === 0;
if (Platform.OS === 'ios') { if (Platform.OS === 'ios') {
const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan]; const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan];
if (!isClipboardEmpty) { if (!isClipboardEmpty) {
@ -435,7 +432,7 @@ const WalletTransactions = () => {
buttons, buttons,
}); });
} }
}
}; };
const navigateToViewEditCosigners = () => { const navigateToViewEditCosigners = () => {

View file

@ -13,7 +13,6 @@ import {
Switch, Switch,
Text, Text,
View, View,
findNodeHandle,
} from 'react-native'; } from 'react-native';
import { Icon, Badge } from 'react-native-elements'; import { Icon, Badge } from 'react-native-elements';
import { useFocusEffect, useNavigation, useRoute, useTheme } from '@react-navigation/native'; import { useFocusEffect, useNavigation, useRoute, useTheme } from '@react-navigation/native';
@ -41,7 +40,6 @@ import MultipleStepsListItem, {
import Privacy from '../../blue_modules/Privacy'; import Privacy from '../../blue_modules/Privacy';
import Biometric from '../../class/biometrics'; import Biometric from '../../class/biometrics';
import { SquareButton } from '../../components/SquareButton'; import { SquareButton } from '../../components/SquareButton';
import { isMacCatalina } from '../../blue_modules/environment';
import { encodeUR } from '../../blue_modules/ur'; import { encodeUR } from '../../blue_modules/ur';
import QRCodeComponent from '../../components/QRCodeComponent'; import QRCodeComponent from '../../components/QRCodeComponent';
import alert from '../../components/Alert'; import alert from '../../components/Alert';
@ -437,33 +435,24 @@ const ViewEditMultisigCosigners = () => {
}; };
const scanOrOpenFile = () => { const scanOrOpenFile = () => {
if (isMacCatalina) { setIsProvideMnemonicsModalVisible(false);
fs.showActionSheet({ anchor: findNodeHandle(openScannerButtonRef.current) }).then(result => { setTimeout(
// Triggers FlatList re-render () =>
setImportText(result); navigate('ScanQRCodeRoot', {
// screen: 'ScanQRCode',
_handleUseMnemonicPhrase(result); params: {
}); launchedBy: route.name,
} else { onBarScanned: result => {
setIsProvideMnemonicsModalVisible(false); // Triggers FlatList re-render
setTimeout( setImportText(result);
() => //
navigate('ScanQRCodeRoot', { _handleUseMnemonicPhrase(result);
screen: 'ScanQRCode',
params: {
launchedBy: route.name,
onBarScanned: result => {
// Triggers FlatList re-render
setImportText(result);
//
_handleUseMnemonicPhrase(result);
},
showFileImportButton: true,
}, },
}), showFileImportButton: true,
650, },
); }),
} 650,
);
}; };
const hideProvideMnemonicsModal = () => { const hideProvideMnemonicsModal = () => {

View file

@ -18,4 +18,4 @@ echo > blue_modules/torrific.js
echo "Updating Podfile" echo "Updating Podfile"
cd ios && pod update && cd .. cd ios && pod update && cd ..
echo "" echo ""
echo "NOTE: react-native-tor is not currently compatible with Mac Catalyst. If you are running macOS Catalina, you will need to remove the iOS 14 Widgets from the project targets." echo "NOTE: react-native-tor is not currently compatible with Mac Catalyst.