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 Oct 2, 2024
2 parents b1fdce2 + e2e5e14 commit be9761a
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 94 deletions.
19 changes: 14 additions & 5 deletions components/BlurredBalanceView.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import React from 'react';
import { ImageBackground, StyleSheet, View } from 'react-native';
import { StyleSheet, View } from 'react-native';
import { Icon } from '@rneui/themed';

export const BlurredBalanceView = () => {
return (
<View style={styles.container}>
{/* @ts-ignore: We just want the blur effect. No source prop needed */}
<ImageBackground blurRadius={6} style={styles.background} />
<View style={styles.background} />
<Icon name="eye-slash" type="font-awesome" color="#FFFFFF" />
</View>
);
};

const styles = StyleSheet.create({
container: { flexDirection: 'row', alignItems: 'center', borderRadius: 9 },
background: { backgroundColor: '#FFFFFF', opacity: 0.5, height: 30, width: 110, marginRight: 8, borderRadius: 9 },
container: {
flexDirection: 'row',
alignItems: 'center',
borderRadius: 9,
},
background: {
backgroundColor: 'rgba(255, 255, 255, 0.5)',
height: 30,
width: 110,
marginRight: 8,
borderRadius: 9,
},
});
31 changes: 31 additions & 0 deletions components/HeaderMenuButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import ToolTipMenu from './TooltipMenu';
import { useTheme } from './themes';
import { Icon } from '@rneui/themed';
import { Platform } from 'react-native';
import { Action } from './types';

interface HeaderMenuButtonProps {
onPressMenuItem: (id: string) => void;
actions: Action[];
disabled?: boolean;
}

const HeaderMenuButton: React.FC<HeaderMenuButtonProps> = ({ onPressMenuItem, actions, disabled }) => {
const { colors } = useTheme();
const styleProps = Platform.OS === 'android' ? { iconStyle: { transform: [{ rotate: '90deg' }] } } : {};
return (
<ToolTipMenu
testID="HeaderMenuButton"
disabled={disabled}
isButton
isMenuPrimaryAction
onPressMenuItem={onPressMenuItem}
actions={actions}
>
<Icon size={22} name="more-horiz" type="material" color={colors.foregroundColor} {...styleProps} />
</ToolTipMenu>
);
};

export default HeaderMenuButton;
21 changes: 11 additions & 10 deletions components/TransactionsNavigationHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import Clipboard from '@react-native-clipboard/clipboard';
import { I18nManager, Image, LayoutAnimation, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { I18nManager, Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import { LightningCustodianWallet, MultisigHDWallet } from '../class';
import WalletGradient from '../class/wallet-gradient';
Expand All @@ -11,6 +11,7 @@ import { FiatUnit } from '../models/fiatUnit';
import { BlurredBalanceView } from './BlurredBalanceView';
import { useSettings } from '../hooks/context/useSettings';
import ToolTipMenu from './TooltipMenu';
import useAnimateOnChange from '../hooks/useAnimateOnChange';

interface TransactionsNavigationHeaderProps {
wallet: TWallet;
Expand All @@ -36,16 +37,14 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
wallet
.allowOnchainAddress()
.then((value: boolean) => setAllowOnchainAddress(value))
.catch((e: Error) => {
console.log('This LNDhub wallet does not have an onchain address API.');
.catch(() => {
console.error('This LNDhub wallet does not have an onchain address API.');
setAllowOnchainAddress(false);
});
}
}, [wallet]);

useEffect(() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);

setWallet(initialWallet);
}, [initialWallet]);

Expand All @@ -61,7 +60,6 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
}, [unit, wallet]);

const handleBalanceVisibility = useCallback(() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
onWalletBalanceVisibilityChange?.(!wallet.hideBalance);
}, [onWalletBalanceVisibilityChange, wallet.hideBalance]);

Expand All @@ -76,7 +74,6 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
newWalletPreferredUnit = BitcoinUnit.BTC;
}

LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
onWalletUnitChange(newWalletPreferredUnit);
};

Expand Down Expand Up @@ -116,7 +113,6 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
}, []);

const balance = useMemo(() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
const hideBalance = wallet.hideBalance;
const balanceFormatted =
unit === BitcoinUnit.LOCAL_CURRENCY
Expand Down Expand Up @@ -165,6 +161,11 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
}
}, [wallet.type]);

useAnimateOnChange(balance);
useAnimateOnChange(wallet.hideBalance);
useAnimateOnChange(unit);
useAnimateOnChange(wallet.getID?.());

return (
<LinearGradient
colors={WalletGradient.gradientsFor(wallet.type)}
Expand All @@ -191,9 +192,9 @@ const TransactionsNavigationHeader: React.FC<TransactionsNavigationHeaderProps>
) : (
<View>
<Text
// @ts-ignore: // force component recreation on balance change. To fix right-to-left languages, like Farsis
key={balance}
testID="WalletBalance"
// @ts-ignore: Ugh
key={balance} // force component recreation on balance change. To fix right-to-left languages, like Farsi
numberOfLines={1}
minimumFontScale={0.5}
adjustsFontSizeToFit
Expand Down
13 changes: 13 additions & 0 deletions hooks/useAnimateOnChange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useEffect, useRef } from 'react';
import { LayoutAnimation } from 'react-native';

const useAnimateOnChange = <T>(value: T) => {
const prevValue = useRef<T | undefined>(undefined);
useEffect(() => {
if (prevValue.current !== undefined && prevValue.current !== value) {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
}
prevValue.current = value;
}, [value]);
};
export default useAnimateOnChange;
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"react-native-quick-actions": "0.3.13",
"react-native-randombytes": "3.6.1",
"react-native-rate": "1.2.12",
"react-native-reanimated": "3.15.3",
"react-native-reanimated": "3.15.4",
"react-native-safe-area-context": "4.11.0",
"react-native-screens": "3.34.0",
"react-native-secure-key-store": "github:BlueWallet/react-native-secure-key-store#2076b4849e88aa0a78e08bfbb4ce3923e0925cbc",
Expand Down
24 changes: 10 additions & 14 deletions screen/receive/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ import { SuccessView } from '../send/success';
import { useStorage } from '../../hooks/context/useStorage';
import { HandOffActivityType } from '../../components/types';
import SegmentedControl from '../../components/SegmentControl';
import ToolTipMenu from '../../components/TooltipMenu';
import { Icon } from '@rneui/themed';
import { CommonToolTipActions } from '../../typings/CommonToolTipActions';
import HeaderMenuButton from '../../components/HeaderMenuButton';

const segmentControlValues = [loc.wallets.details_address, loc.bip47.payment_code];

Expand Down Expand Up @@ -157,7 +156,7 @@ const ReceiveDetails = () => {

const toolTipActions = useMemo(() => {
const action = CommonToolTipActions.PaymentCode;
action.menuState = wallet.isBIP47Enabled();
action.menuState = wallet?.isBIP47Enabled();
return [action];
}, [wallet]);

Expand All @@ -167,12 +166,9 @@ const ReceiveDetails = () => {
}, [onEnablePaymentsCodeSwitchValue]);

const HeaderRight = useMemo(
() => (
<ToolTipMenu isButton isMenuPrimaryAction onPressMenuItem={onPressMenuItem} actions={[toolTipActions]}>
<Icon size={22} name="more-horiz" type="material" color={colors.foregroundColor} />
</ToolTipMenu>
),
[colors.foregroundColor, onPressMenuItem, toolTipActions],
() => <HeaderMenuButton actions={toolTipActions} onPressMenuItem={onPressMenuItem} />,

[onPressMenuItem, toolTipActions],
);

const handleClose = useCallback(() => {
Expand All @@ -195,11 +191,11 @@ const ReceiveDetails = () => {
);

useEffect(() => {
wallet.allowBIP47() &&
!wallet.isBIP47Enabled() &&
wallet?.allowBIP47() &&
wallet?.isBIP47Enabled() &&
setOptions({
headerLeft: () => (wallet.isBIP47Enabled() ? null : HeaderLeft),
headerRight: () => (wallet.isBIP47Enabled() ? HeaderLeft : HeaderRight),
headerLeft: () => (wallet?.isBIP47Enabled() ? null : HeaderLeft),
headerRight: () => (wallet?.isBIP47Enabled() ? HeaderLeft : HeaderRight),
});
}, [HeaderLeft, HeaderRight, colors.foregroundColor, setOptions, wallet]);

Expand Down Expand Up @@ -480,7 +476,7 @@ const ReceiveDetails = () => {
contentContainerStyle={[styles.root, stylesHook.root]}
keyboardShouldPersistTaps="always"
>
{wallet?.allowBIP47() && wallet.isBIP47Enabled() && (
{wallet?.allowBIP47() && wallet?.isBIP47Enabled() && (
<View style={styles.tabsContainer}>
<SegmentedControl
values={segmentControlValues}
Expand Down
21 changes: 2 additions & 19 deletions screen/send/SendDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
import DocumentPicker from 'react-native-document-picker';
import { Icon } from '@rneui/themed';
import RNFS from 'react-native-fs';

import { btcToSatoshi, fiatToBTC } from '../../blue_modules/currency';
import * as fs from '../../blue_modules/fs';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
Expand All @@ -40,7 +39,6 @@ import Button from '../../components/Button';
import CoinsSelected from '../../components/CoinsSelected';
import InputAccessoryAllFunds, { InputAccessoryAllFundsAccessoryViewID } from '../../components/InputAccessoryAllFunds';
import { useTheme } from '../../components/themes';
import ToolTipMenu from '../../components/TooltipMenu';
import { requestCameraAuthorization, scanQrHelper } from '../../helpers/scan-qr';
import loc, { formatBalance, formatBalanceWithoutSuffix } from '../../loc';
import { BitcoinUnit, Chain } from '../../models/bitcoinUnits';
Expand All @@ -58,6 +56,7 @@ import SelectFeeModal from '../../components/SelectFeeModal';
import { useKeyboard } from '../../hooks/useKeyboard';
import { DismissKeyboardInputAccessory, DismissKeyboardInputAccessoryViewID } from '../../components/DismissKeyboardInputAccessory';
import ActionSheet from '../ActionSheet';
import HeaderMenuButton from '../../components/HeaderMenuButton';

interface IPaymentDestinations {
address: string; // btc address or payment code
Expand Down Expand Up @@ -1055,18 +1054,7 @@ const SendDetails = () => {
const setHeaderRightOptions = () => {
navigation.setOptions({
// eslint-disable-next-line react/no-unstable-nested-components
headerRight: () => (
<ToolTipMenu
disabled={isLoading}
isButton
isMenuPrimaryAction
onPressMenuItem={headerRightOnPress}
actions={headerRightActions()}
testID="advancedOptionsMenuButton"
>
<Icon size={22} name="more-horiz" type="material" color={colors.foregroundColor} style={styles.advancedOptions} />
</ToolTipMenu>
),
headerRight: () => <HeaderMenuButton disabled={isLoading} onPressMenuItem={headerRightOnPress} actions={headerRightActions()} />,
});
};

Expand Down Expand Up @@ -1499,11 +1487,6 @@ const styles = StyleSheet.create({
alignItems: 'center',
paddingHorizontal: 10,
},
advancedOptions: {
minWidth: 40,
height: 40,
justifyContent: 'center',
},
frozenContainer: {
flexDirection: 'row',
justifyContent: 'center',
Expand Down
2 changes: 1 addition & 1 deletion screen/send/psbtMultisigQRCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const PsbtMultisigQRCode = () => {
};

const openScanner = async () => {
const scanned = await scanQrHelper(name, true, undefined);
const scanned = await scanQrHelper(name, true);
onBarScanned({ data: scanned });
};

Expand Down
13 changes: 4 additions & 9 deletions screen/wallets/Add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import WalletButton from '../../components/WalletButton';
import loc from '../../loc';
import { Chain } from '../../models/bitcoinUnits';
import { useStorage } from '../../hooks/context/useStorage';
import ToolTipMenu from '../../components/TooltipMenu';
import { Icon } from '@rneui/themed';
import { CommonToolTipActions } from '../../typings/CommonToolTipActions';
import { Action } from '../../components/types';
import { getLNDHub } from '../../helpers/lndHub';
import HeaderMenuButton from '../../components/HeaderMenuButton';

enum ButtonSelected {
// @ts-ignore: Return later to update
Expand Down Expand Up @@ -228,9 +227,7 @@ const WalletsAdd: React.FC = () => {

const HeaderRight = useMemo(
() => (
<ToolTipMenu
isButton
isMenuPrimaryAction
<HeaderMenuButton
onPressMenuItem={(id: string) => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
if (id === HDSegwitBech32Wallet.type) {
Expand All @@ -246,11 +243,9 @@ const WalletsAdd: React.FC = () => {
}
}}
actions={toolTipActions}
>
<Icon size={22} name="more-horiz" type="material" color={colors.foregroundColor} />
</ToolTipMenu>
/>
),
[colors.foregroundColor, handleOnLightningButtonPressed, navigateToEntropy, toolTipActions],
[handleOnLightningButtonPressed, navigateToEntropy, toolTipActions],
);

useEffect(() => {
Expand Down
17 changes: 3 additions & 14 deletions screen/wallets/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import {
DoneAndDismissKeyboardInputAccessory,
DoneAndDismissKeyboardInputAccessoryViewID,
} from '../../components/DoneAndDismissKeyboardInputAccessory';
import { Icon } from '@rneui/themed';
import { CommonToolTipActions } from '../../typings/CommonToolTipActions';
import { useKeyboard } from '../../hooks/useKeyboard';
import ToolTipMenu from '../../components/TooltipMenu';
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
import HeaderMenuButton from '../../components/HeaderMenuButton';

const WalletsImport = () => {
const navigation = useExtendedNavigation();
Expand Down Expand Up @@ -140,18 +139,8 @@ const WalletsImport = () => {
}, [askPassphrase, searchAccounts]);

const HeaderRight = useMemo(
() => (
<ToolTipMenu
isButton
testID="HeaderRightButton"
isMenuPrimaryAction
onPressMenuItem={toolTipOnPressMenuItem}
actions={toolTipActions}
>
<Icon size={22} name="more-horiz" type="material" color={colors.foregroundColor} />
</ToolTipMenu>
),
[toolTipOnPressMenuItem, toolTipActions, colors.foregroundColor],
() => <HeaderMenuButton onPressMenuItem={toolTipOnPressMenuItem} actions={toolTipActions} />,
[toolTipOnPressMenuItem, toolTipActions],
);

// Adding the ToolTipMenu to the header
Expand Down
Loading

0 comments on commit be9761a

Please sign in to comment.