Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Nov 21, 2023
2 parents fe38107 + ca31762 commit 386cc5a
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 72 deletions.
22 changes: 13 additions & 9 deletions Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,18 @@ const DrawerRoot = () => {
const isLargeScreen = useMemo(() => {
return Platform.OS === 'android' ? isTablet() : (dimensions.width >= Dimensions.get('screen').width / 2 && isTablet()) || isDesktop;
}, [dimensions.width]);
const drawerStyle = useMemo(() => ({ width: isLargeScreen ? 320 : '0%' }), [isLargeScreen]);
const drawerContent = useCallback(props => (isLargeScreen ? <DrawerList {...props} /> : null), [isLargeScreen]);
const drawerStyle = useMemo(
() => ({
drawerPosition: I18nManager.isRTL ? 'right' : 'left',
drawerStyle: { width: isLargeScreen ? 320 : '0%' },
drawerType: isLargeScreen ? 'permanent' : 'back',
}),
[isLargeScreen],
);
const drawerContent = useCallback(props => <DrawerList {...props} />, []);

return (
<Drawer.Navigator
screenOptions={drawerStyle}
drawerType={isLargeScreen ? 'permanent' : null}
drawerContent={drawerContent}
drawerPosition={I18nManager.isRTL ? 'right' : 'left'}
>
<Drawer.Navigator screenOptions={drawerStyle} drawerContent={drawerContent}>
<Drawer.Screen name="Navigation" component={Navigation} options={{ headerShown: false, gestureEnabled: false }} />
</Drawer.Navigator>
);
Expand Down Expand Up @@ -509,13 +511,14 @@ const PaymentCodeStackRoot = () => {

const RootStack = createNativeStackNavigator();
const NavigationDefaultOptions = { headerShown: false, presentation: isDesktop ? 'containedModal' : 'modal' };
const NavigationFormModalOptions = { headerShown: false, presentation: isDesktop ? 'containedModal' : 'formSheet' };
const StatusBarLightOptions = { statusBarStyle: 'light' };
const Navigation = () => {
return (
<RootStack.Navigator initialRouteName="UnlockWithScreenRoot" screenOptions={{ headerHideShadow: true, statusBarStyle: 'auto' }}>
{/* stacks */}
<RootStack.Screen name="WalletsRoot" component={WalletsRoot} options={{ headerShown: false, translucent: false }} />
<RootStack.Screen name="AddWalletRoot" component={AddWalletRoot} options={NavigationDefaultOptions} />
<RootStack.Screen name="AddWalletRoot" component={AddWalletRoot} options={NavigationFormModalOptions} />
<RootStack.Screen name="SendDetailsRoot" component={SendDetailsRoot} options={NavigationDefaultOptions} />
<RootStack.Screen name="LNDCreateInvoiceRoot" component={LNDCreateInvoiceRoot} options={NavigationDefaultOptions} />
<RootStack.Screen name="ScanLndInvoiceRoot" component={ScanLndInvoiceRoot} options={NavigationDefaultOptions} />
Expand Down Expand Up @@ -559,6 +562,7 @@ const Navigation = () => {
presentation: isDesktop ? 'containedModal' : 'fullScreenModal',
statusBarHidden: true,
}}
initialParams={ScanQRCode.initialParams}
/>

<RootStack.Screen name="PaymentCodeRoot" component={PaymentCodeStackRoot} options={NavigationDefaultOptions} />
Expand Down
8 changes: 3 additions & 5 deletions blue_modules/storage-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const WalletTransactionsStatus = { NONE: false, ALL: true };
export const BlueStorageContext = createContext();
export const BlueStorageProvider = ({ children }) => {
const [wallets, setWallets] = useState([]);
const [selectedWallet, setSelectedWallet] = useState('');
const [selectedWalletID, setSelectedWalletID] = useState('');
const [walletTransactionUpdateStatus, setWalletTransactionUpdateStatus] = useState(WalletTransactionsStatus.NONE);
const [walletsInitialized, setWalletsInitialized] = useState(false);
const [preferredFiatCurrency, _setPreferredFiatCurrency] = useState(FiatUnit.USD);
Expand Down Expand Up @@ -227,7 +227,6 @@ export const BlueStorageProvider = ({ children }) => {
const setIsAdvancedModeEnabled = BlueApp.setIsAdvancedModeEnabled;
const getHodlHodlSignatureKey = BlueApp.getHodlHodlSignatureKey;
const addHodlHodlContract = BlueApp.addHodlHodlContract;
const getHodlHodlContracts = BlueApp.getHodlHodlContracts;
const setDoNotTrack = BlueApp.setDoNotTrack;
const isDoNotTrackEnabled = BlueApp.isDoNotTrackEnabled;
const getItem = BlueApp.getItem;
Expand All @@ -241,16 +240,15 @@ export const BlueStorageProvider = ({ children }) => {
txMetadata,
saveToDisk,
getTransactions,
selectedWallet,
setSelectedWallet,
selectedWalletID,
setSelectedWalletID,
addWallet,
deleteWallet,
currentSharedCosigner,
setSharedCosigner,
addAndSaveWallet,
setItem,
getItem,
getHodlHodlContracts,
isAdvancedModeEnabled,
fetchWalletBalances,
fetchWalletTransactions,
Expand Down
38 changes: 19 additions & 19 deletions components/WalletsCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { LightningCustodianWallet, LightningLdkWallet, MultisigHDWallet } from '
import WalletGradient from '../class/wallet-gradient';
import { BluePrivateBalance } from '../BlueComponents';
import { BlueStorageContext } from '../blue_modules/storage-context';
import { isHandset, isTablet, isDesktop } from '../blue_modules/environment';
import { isTablet, isDesktop } from '../blue_modules/environment';
import { useTheme } from './themes';

const nStyles = StyleSheet.create({
Expand Down Expand Up @@ -137,7 +137,7 @@ const iStyles = StyleSheet.create({
},
});

const WalletCarouselItem = ({ item, index, onPress, handleLongPress, isSelectedWallet }) => {
const WalletCarouselItem = ({ item, _, onPress, handleLongPress, isSelectedWallet }) => {
const scaleValue = new Animated.Value(1.0);
const { colors } = useTheme();
const { walletTransactionUpdateStatus } = useContext(BlueStorageContext);
Expand Down Expand Up @@ -239,7 +239,6 @@ const WalletCarouselItem = ({ item, index, onPress, handleLongPress, isSelectedW

WalletCarouselItem.propTypes = {
item: PropTypes.any,
index: PropTypes.number.isRequired,
onPress: PropTypes.func.isRequired,
handleLongPress: PropTypes.func.isRequired,
isSelectedWallet: PropTypes.bool,
Expand All @@ -262,21 +261,22 @@ const ListHeaderComponent = () => <View style={cStyles.separatorStyle} />;

const WalletsCarousel = forwardRef((props, ref) => {
const { preferredFiatCurrency, language } = useContext(BlueStorageContext);
const { horizontal, data, handleLongPress, onPress, selectedWallet } = props;
const renderItem = useCallback(
({ item, index }) =>
item ? (
<WalletCarouselItem
isSelectedWallet={!props.horizontal && props.selectedWallet ? props.selectedWallet === item.getID() : undefined}
isSelectedWallet={!horizontal && selectedWallet ? selectedWallet === item.getID() : undefined}
item={item}
index={index}
handleLongPress={props.handleLongPress}
onPress={props.onPress}
handleLongPress={handleLongPress}
onPress={onPress}
/>
) : (
<NewWalletPanel onPress={props.onPress} />
<NewWalletPanel onPress={onPress} />
),
// eslint-disable-next-line react-hooks/exhaustive-deps
[props.horizontal, props.selectedWallet, props.handleLongPress, props.onPress, preferredFiatCurrency, language],
[horizontal, selectedWallet, handleLongPress, onPress, preferredFiatCurrency, language],
);
const flatListRef = useRef();

Expand All @@ -298,7 +298,7 @@ const WalletsCarousel = forwardRef((props, ref) => {
console.log(error);
flatListRef.current.scrollToOffset({ offset: error.averageItemLength * error.index, animated: true });
setTimeout(() => {
if (props.data.length !== 0 && flatListRef.current !== null) {
if (data.length !== 0 && flatListRef.current !== null) {
flatListRef.current.scrollToIndex({ index: error.index, animated: true });
}
}, 100);
Expand All @@ -307,40 +307,40 @@ const WalletsCarousel = forwardRef((props, ref) => {
const { width } = useWindowDimensions();
const sliderHeight = 195;
const itemWidth = width * 0.82 > 375 ? 375 : width * 0.82;
return isHandset ? (
return horizontal ? (
<FlatList
ref={flatListRef}
renderItem={renderItem}
extraData={props.data}
extraData={data}
keyExtractor={(_, index) => index.toString()}
showsVerticalScrollIndicator={false}
pagingEnabled
disableIntervalMomentum={isHandset}
disableIntervalMomentum={horizontal}
snapToInterval={itemWidth} // Adjust to your content width
decelerationRate="fast"
contentContainerStyle={props.horizontal ? cStyles.content : cStyles.contentLargeScreen}
contentContainerStyle={cStyles.content}
directionalLockEnabled
showsHorizontalScrollIndicator={false}
initialNumToRender={10}
ListHeaderComponent={ListHeaderComponent}
style={props.horizontal ? { minHeight: sliderHeight + 9 } : {}}
style={{ minHeight: sliderHeight + 9 }}
onScrollToIndexFailed={onScrollToIndexFailed}
{...props}
/>
) : (
<View style={cStyles.contentLargeScreen}>
{props.data.map((item, index) =>
{data.map((item, index) =>
item ? (
<WalletCarouselItem
isSelectedWallet={!props.horizontal && props.selectedWallet ? props.selectedWallet === item.getID() : undefined}
isSelectedWallet={!horizontal && selectedWallet ? selectedWallet === item.getID() : undefined}
item={item}
index={index}
handleLongPress={props.handleLongPress}
onPress={props.onPress}
handleLongPress={handleLongPress}
onPress={onPress}
key={index}
/>
) : (
<NewWalletPanel key={index} onPress={props.onPress} />
<NewWalletPanel key={index} onPress={onPress} />
),
)}
</View>
Expand Down
6 changes: 3 additions & 3 deletions ios/BlueWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@
);
mainGroup = 83CBB9F61A601CBA00E9B192;
packageReferences = (
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */,
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */,
);
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1827,7 +1827,7 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */ = {
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/EFPrefix/EFQRCode.git";
requirement = {
Expand All @@ -1840,7 +1840,7 @@
/* Begin XCSwiftPackageProductDependency section */
6DFC806F24EA0B6C007B8700 /* EFQRCode */ = {
isa = XCSwiftPackageProductDependency;
package = 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */;
package = 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */;
productName = EFQRCode;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
1 change: 1 addition & 0 deletions loc/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"node_alias": "Node alias",
"expiresIn": "Expires in {time} minutes",
"payButton": "Pay",
"payment": "Payment",
"placeholder": "Invoice or address",
"open_channel": "Open Channel",
"funding_amount_placeholder": "Funding amount, for example 0.001",
Expand Down
6 changes: 3 additions & 3 deletions screen/lnd/lndCreateInvoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const currency = require('../../blue_modules/currency');
const torrific = isTorCapable ? require('../../blue_modules/torrific') : require('../../scripts/maccatalystpatches/torrific.js');

const LNDCreateInvoice = () => {
const { wallets, saveToDisk, setSelectedWallet, isTorDisabled } = useContext(BlueStorageContext);
const { wallets, saveToDisk, setSelectedWalletID, isTorDisabled } = useContext(BlueStorageContext);
const { walletID, uri } = useRoute().params;
const wallet = useRef(wallets.find(item => item.getID() === walletID) || wallets.find(item => item.chain === Chain.OFFCHAIN));
const { name } = useRoute();
Expand Down Expand Up @@ -106,7 +106,7 @@ const LNDCreateInvoice = () => {
const newWallet = wallets.find(w => w.getID() === walletID);
if (newWallet) {
wallet.current = newWallet;
setSelectedWallet(newWallet.getID());
setSelectedWalletID(newWallet.getID());
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -115,7 +115,7 @@ const LNDCreateInvoice = () => {
useFocusEffect(
useCallback(() => {
if (wallet.current) {
setSelectedWallet(walletID);
setSelectedWalletID(walletID);
if (wallet.current.getUserHasSavedExport()) {
renderReceiveDetails();
} else {
Expand Down
4 changes: 2 additions & 2 deletions screen/lnd/lndViewInvoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Button from '../../components/Button';

const LNDViewInvoice = () => {
const { invoice, walletID } = useRoute().params;
const { wallets, setSelectedWallet, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext);
const { wallets, setSelectedWalletID, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext);
const wallet = wallets.find(w => w.getID() === walletID);
const { colors, closeImage } = useTheme();
const { goBack, navigate, setParams, setOptions, getParent } = useNavigation();
Expand Down Expand Up @@ -98,7 +98,7 @@ const LNDViewInvoice = () => {
}, [colors, isModal]);

useEffect(() => {
setSelectedWallet(walletID);
setSelectedWalletID(walletID);
console.log('LNDViewInvoice - useEffect');
if (!invoice.ispaid) {
fetchInvoiceInterval.current = setInterval(async () => {
Expand Down
14 changes: 12 additions & 2 deletions screen/send/ScanQRCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ const ScanQRCode = () => {
const [isLoading, setIsLoading] = useState(false);
const navigation = useNavigation();
const route = useRoute();
const showFileImportButton = route.params.showFileImportButton || false;
const { launchedBy, onBarScanned, onDismiss, onBarScannerDismissWithoutData = () => {} } = route.params;
const { launchedBy, onBarScanned, onDismiss, showFileImportButton, onBarScannerDismissWithoutData = () => {} } = route.params;
const scannedCache = {};
const { colors } = useTheme();
const isFocused = useIsFocused();
Expand Down Expand Up @@ -404,3 +403,14 @@ const ScanQRCode = () => {
};

export default ScanQRCode;
ScanQRCode.initialParams = {
isLoading: false,
cameraStatusGranted: undefined,
backdoorPressed: undefined,
launchedBy: undefined,
urTotal: undefined,
urHave: undefined,
backdoorText: '',
backdoorVisible: false,
animatedQRCodeData: {},
}
4 changes: 2 additions & 2 deletions screen/send/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const fs = require('../../blue_modules/fs');
const btcAddressRx = /^[a-zA-Z0-9]{26,35}$/;

const SendDetails = () => {
const { wallets, setSelectedWallet, sleep, txMetadata, saveToDisk } = useContext(BlueStorageContext);
const { wallets, setSelectedWalletID, sleep, txMetadata, saveToDisk } = useContext(BlueStorageContext);
const navigation = useNavigation();
const { name, params: routeParams } = useRoute();
const scrollView = useRef();
Expand Down Expand Up @@ -230,7 +230,7 @@ const SendDetails = () => {
// change header and reset state on wallet change
useEffect(() => {
if (!wallet) return;
setSelectedWallet(wallet.getID());
setSelectedWalletID(wallet.getID());

// reset other values
setUtxo(null);
Expand Down
4 changes: 2 additions & 2 deletions screen/transactions/transactionStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const buttonStatus = Object.freeze({
});

const TransactionsStatus = () => {
const { setSelectedWallet, wallets, txMetadata, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext);
const { setSelectedWalletID, wallets, txMetadata, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext);
const { hash, walletID } = useRoute().params;
const { navigate, setOptions, goBack } = useNavigation();
const { colors } = useTheme();
Expand Down Expand Up @@ -196,7 +196,7 @@ const TransactionsStatus = () => {
useEffect(() => {
const wID = wallet.current?.getID();
if (wID) {
setSelectedWallet(wallet.current?.getID());
setSelectedWalletID(wallet.current?.getID());
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [wallet.current]);
Expand Down
23 changes: 11 additions & 12 deletions screen/wallets/addMultisigStep2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ActivityIndicator,
FlatList,
I18nManager,
InteractionManager,
Keyboard,
KeyboardAvoidingView,
LayoutAnimation,
Expand Down Expand Up @@ -461,17 +462,15 @@ const WalletsAddMultisigStep2 = () => {
fs.showActionSheet({ anchor: findNodeHandle(openScannerButton.current) }).then(onBarScanned);
} else {
setIsProvideMnemonicsModalVisible(false);
setTimeout(() =>
requestCameraAuthorization().then(
() =>
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
onBarScanned,
showFileImportButton: true,
},
}),
650,
InteractionManager.runAfterInteractions(() =>
requestCameraAuthorization().then(() =>
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
onBarScanned,
showFileImportButton: true,
},
}),
),
);
}
Expand Down Expand Up @@ -795,7 +794,7 @@ const styles = StyleSheet.create({
});

WalletsAddMultisigStep2.navigationOptions = navigationStyle({
headerTitle: null,
title: null,
gestureEnabled: false,
swipeEnabled: false,
});
Expand Down
Loading

0 comments on commit 386cc5a

Please sign in to comment.