Merge pull request #6950 from BlueWallet/memorycon

FIX: memory consumption bug by RN component
This commit is contained in:
GLaDOS 2024-08-21 08:43:55 +00:00 committed by GitHub
commit e55b4ac446
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 628 additions and 682 deletions

View file

@ -7,7 +7,6 @@ import {
I18nManager, I18nManager,
InputAccessoryView, InputAccessoryView,
Keyboard, Keyboard,
KeyboardAvoidingView,
Platform, Platform,
StyleSheet, StyleSheet,
TextInput, TextInput,
@ -188,7 +187,7 @@ export const BlueDoneAndDismissKeyboardInputAccessory = props => {
if (Platform.OS === 'ios') { if (Platform.OS === 'ios') {
return <InputAccessoryView nativeID={BlueDoneAndDismissKeyboardInputAccessory.InputAccessoryViewID}>{inputView}</InputAccessoryView>; return <InputAccessoryView nativeID={BlueDoneAndDismissKeyboardInputAccessory.InputAccessoryViewID}>{inputView}</InputAccessoryView>;
} else { } else {
return <KeyboardAvoidingView>{inputView}</KeyboardAvoidingView>; return inputView;
} }
}; };

View file

@ -5,7 +5,6 @@ import {
I18nManager, I18nManager,
Image, Image,
Keyboard, Keyboard,
KeyboardAvoidingView,
Platform, Platform,
StyleSheet, StyleSheet,
Text, Text,
@ -397,7 +396,6 @@ const LNDCreateInvoice = () => {
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}> <TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<View style={[styles.root, styleHooks.root]}> <View style={[styles.root, styleHooks.root]}>
<View style={[styles.amount, styleHooks.amount]}> <View style={[styles.amount, styleHooks.amount]}>
<KeyboardAvoidingView enabled={!Platform.isPad} behavior="position">
<AmountInput <AmountInput
isLoading={isLoading} isLoading={isLoading}
amount={amount} amount={amount}
@ -423,7 +421,6 @@ const LNDCreateInvoice = () => {
</View> </View>
<BlueDismissKeyboardInputAccessory /> <BlueDismissKeyboardInputAccessory />
{renderCreateButton()} {renderCreateButton()}
</KeyboardAvoidingView>
</View> </View>
{renderWalletSelectionButton()} {renderWalletSelectionButton()}
</View> </View>

View file

@ -1,17 +1,6 @@
import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native'; import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native';
import React, { useCallback, useEffect, useState } from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import { import { ActivityIndicator, I18nManager, Keyboard, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
ActivityIndicator,
I18nManager,
Keyboard,
KeyboardAvoidingView,
Platform,
ScrollView,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import { Icon } from '@rneui/themed'; import { Icon } from '@rneui/themed';
import { btcToSatoshi, fiatToBTC } from '../../blue_modules/currency'; import { btcToSatoshi, fiatToBTC } from '../../blue_modules/currency';
@ -302,8 +291,13 @@ const ScanLndInvoice = () => {
return ( return (
<SafeArea style={stylesHook.root}> <SafeArea style={stylesHook.root}>
<View style={[styles.root, stylesHook.root]}> <View style={[styles.root, stylesHook.root]}>
<ScrollView contentContainerStyle={styles.scroll} keyboardShouldPersistTaps="handled"> <ScrollView
<KeyboardAvoidingView enabled behavior="position" keyboardVerticalOffset={20}> contentContainerStyle={styles.scroll}
keyboardShouldPersistTaps="handled"
automaticallyAdjustContentInsets
automaticallyAdjustKeyboardInsets
contentInsetAdjustmentBehavior="automatic"
>
<View style={styles.scrollMargin}> <View style={styles.scrollMargin}>
<AmountInput <AmountInput
pointerEvents={isAmountInitiallyEmpty ? 'auto' : 'none'} pointerEvents={isAmountInitiallyEmpty ? 'auto' : 'none'}
@ -357,7 +351,7 @@ const ScanLndInvoice = () => {
)} )}
</BlueCard> </BlueCard>
</BlueCard> </BlueCard>
</KeyboardAvoidingView>
{renderWalletSelectionButton()} {renderWalletSelectionButton()}
</ScrollView> </ScrollView>
</View> </View>

View file

@ -1,10 +1,9 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { useRoute, RouteProp } from '@react-navigation/native'; import { useRoute, RouteProp } from '@react-navigation/native';
import * as bitcoin from 'bitcoinjs-lib'; import * as bitcoin from 'bitcoinjs-lib';
import { ActivityIndicator, Keyboard, KeyboardAvoidingView, Linking, Platform, StyleSheet, TextInput, View } from 'react-native'; import { ActivityIndicator, Keyboard, Linking, StyleSheet, TextInput, View } from 'react-native';
import * as BlueElectrum from '../../blue_modules/BlueElectrum'; import * as BlueElectrum from '../../blue_modules/BlueElectrum';
import { isTablet } from '../../blue_modules/environment';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
import Notifications from '../../blue_modules/notifications'; import Notifications from '../../blue_modules/notifications';
import { import {
@ -125,7 +124,6 @@ const Broadcast: React.FC = () => {
return ( return (
<SafeArea> <SafeArea>
<KeyboardAvoidingView enabled={!isTablet} behavior={Platform.OS === 'ios' ? 'position' : undefined}>
<View style={styles.wrapper} testID="BroadcastView"> <View style={styles.wrapper} testID="BroadcastView">
{BROADCAST_RESULT.success !== broadcastResult && ( {BROADCAST_RESULT.success !== broadcastResult && (
<BlueCard style={styles.mainCard}> <BlueCard style={styles.mainCard}>
@ -162,7 +160,6 @@ const Broadcast: React.FC = () => {
)} )}
{BROADCAST_RESULT.success === broadcastResult && tx && <SuccessScreen tx={tx} />} {BROADCAST_RESULT.success === broadcastResult && tx && <SuccessScreen tx={tx} />}
</View> </View>
</KeyboardAvoidingView>
</SafeArea> </SafeArea>
); );
}; };

View file

@ -10,7 +10,6 @@ import {
FlatList, FlatList,
I18nManager, I18nManager,
Keyboard, Keyboard,
KeyboardAvoidingView,
LayoutAnimation, LayoutAnimation,
NativeScrollEvent, NativeScrollEvent,
NativeSyntheticEvent, NativeSyntheticEvent,
@ -50,7 +49,6 @@ import { TOptions } from 'bip21';
import assert from 'assert'; import assert from 'assert';
import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { SendDetailsStackParamList } from '../../navigation/SendDetailsStackParamList'; import { SendDetailsStackParamList } from '../../navigation/SendDetailsStackParamList';
import { isTablet } from '../../blue_modules/environment';
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation'; import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
import { ContactList } from '../../class/contact-list'; import { ContactList } from '../../class/contact-list';
import { useStorage } from '../../hooks/context/useStorage'; import { useStorage } from '../../hooks/context/useStorage';
@ -1324,7 +1322,6 @@ const SendDetails = () => {
return ( return (
<View style={[styles.root, stylesHook.root]} onLayout={e => setWidth(e.nativeEvent.layout.width)}> <View style={[styles.root, stylesHook.root]} onLayout={e => setWidth(e.nativeEvent.layout.width)}>
<View> <View>
<KeyboardAvoidingView enabled={!isTablet} behavior="position">
<FlatList <FlatList
keyboardShouldPersistTaps="always" keyboardShouldPersistTaps="always"
scrollEnabled={addresses.length > 1} scrollEnabled={addresses.length > 1}
@ -1332,6 +1329,7 @@ const SendDetails = () => {
renderItem={renderBitcoinTransactionInfoFields} renderItem={renderBitcoinTransactionInfoFields}
horizontal horizontal
ref={scrollView} ref={scrollView}
automaticallyAdjustKeyboardInsets
pagingEnabled pagingEnabled
removeClippedSubviews={false} removeClippedSubviews={false}
onMomentumScrollBegin={Keyboard.dismiss} onMomentumScrollBegin={Keyboard.dismiss}
@ -1383,7 +1381,6 @@ const SendDetails = () => {
setCustomFee={setCustomFee} setCustomFee={setCustomFee}
setFeePrecalc={setFeePrecalc} setFeePrecalc={setFeePrecalc}
/> />
</KeyboardAvoidingView>
</View> </View>
<BlueDismissKeyboardInputAccessory /> <BlueDismissKeyboardInputAccessory />
{Platform.select({ {Platform.select({

View file

@ -1,6 +1,6 @@
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import { useRoute } from '@react-navigation/native'; import { useRoute } from '@react-navigation/native';
import { Keyboard, KeyboardAvoidingView, Platform, StyleSheet, TextInput, View } from 'react-native'; import { Keyboard, StyleSheet, TextInput, View } from 'react-native';
import { BlueButtonLink, BlueCard, BlueSpacing10, BlueSpacing20, BlueText } from '../../BlueComponents'; import { BlueButtonLink, BlueCard, BlueSpacing10, BlueSpacing20, BlueText } from '../../BlueComponents';
import Button from '../../components/Button'; import Button from '../../components/Button';
import SafeArea from '../../components/SafeArea'; import SafeArea from '../../components/SafeArea';
@ -86,11 +86,6 @@ const IsItMyAddress = () => {
return ( return (
<SafeArea style={styles.blueArea}> <SafeArea style={styles.blueArea}>
<KeyboardAvoidingView
enabled={!Platform.isPad}
behavior={Platform.OS === 'ios' ? 'position' : null}
keyboardShouldPersistTaps="handled"
>
<View style={styles.wrapper}> <View style={styles.wrapper}>
<BlueCard style={styles.mainCard}> <BlueCard style={styles.mainCard}>
<View style={[styles.input, stylesHooks.input]}> <View style={[styles.input, stylesHooks.input]}>
@ -131,7 +126,6 @@ const IsItMyAddress = () => {
<BlueText testID="Result">{result}</BlueText> <BlueText testID="Result">{result}</BlueText>
</BlueCard> </BlueCard>
</View> </View>
</KeyboardAvoidingView>
</SafeArea> </SafeArea>
); );
}; };

View file

@ -4,7 +4,6 @@ import React, { Component } from 'react';
import { import {
Alert, Alert,
Keyboard, Keyboard,
KeyboardAvoidingView,
Platform, Platform,
Pressable, Pressable,
ScrollView, ScrollView,
@ -284,7 +283,6 @@ export default class ElectrumSettings extends Component {
{this.state.config.host}:{this.state.config.port} {this.state.config.host}:{this.state.config.port}
</BlueText> </BlueText>
</BlueCard> </BlueCard>
<KeyboardAvoidingView>
<BlueCard> <BlueCard>
<View style={styles.inputWrap}> <View style={styles.inputWrap}>
<TextInput <TextInput
@ -390,7 +388,6 @@ export default class ElectrumSettings extends Component {
/> />
), ),
})} })}
</KeyboardAvoidingView>
{serverHistoryItems.length > 0 && !this.state.isLoading && ( {serverHistoryItems.length > 0 && !this.state.isLoading && (
<BlueCard> <BlueCard>
<View style={styles.serverHistoryTitle}> <View style={styles.serverHistoryTitle}>
@ -408,7 +405,12 @@ export default class ElectrumSettings extends Component {
render() { render() {
return ( return (
<ScrollView keyboardShouldPersistTaps="always" automaticallyAdjustContentInsets contentInsetAdjustmentBehavior="automatic"> <ScrollView
keyboardShouldPersistTaps="always"
automaticallyAdjustContentInsets
contentInsetAdjustmentBehavior="automatic"
automaticallyAdjustKeyboardInsets
>
<ListItem <ListItem
Component={Pressable} Component={Pressable}
title={loc.settings.electrum_offline_mode} title={loc.settings.electrum_offline_mode}

View file

@ -1,15 +1,5 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { import { ActivityIndicator, Linking, ScrollView, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
ActivityIndicator,
KeyboardAvoidingView,
Linking,
Platform,
ScrollView,
StyleSheet,
TextInput,
TouchableOpacity,
View,
} from 'react-native';
import Clipboard from '@react-native-clipboard/clipboard'; import Clipboard from '@react-native-clipboard/clipboard';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Text } from '@rneui/themed'; import { Text } from '@rneui/themed';
@ -161,7 +151,6 @@ export default class CPFP extends Component {
renderStage1(text) { renderStage1(text) {
return ( return (
<KeyboardAvoidingView enabled={!Platform.isPad} behavior="position">
<SafeArea style={styles.root}> <SafeArea style={styles.root}>
<BlueSpacing /> <BlueSpacing />
<BlueCard style={styles.center}> <BlueCard style={styles.center}>
@ -176,7 +165,6 @@ export default class CPFP extends Component {
/> />
</BlueCard> </BlueCard>
</SafeArea> </SafeArea>
</KeyboardAvoidingView>
); );
} }

View file

@ -5,7 +5,6 @@ import {
ActivityIndicator, ActivityIndicator,
Alert, Alert,
Keyboard, Keyboard,
KeyboardAvoidingView,
LayoutAnimation, LayoutAnimation,
Platform, Platform,
ScrollView, ScrollView,
@ -351,9 +350,8 @@ const WalletsAdd: React.FC = () => {
}; };
return ( return (
<ScrollView style={stylesHook.root} testID="ScrollView"> <ScrollView style={stylesHook.root} testID="ScrollView" automaticallyAdjustKeyboardInsets>
<BlueSpacing20 /> <BlueSpacing20 />
<KeyboardAvoidingView enabled behavior={Platform.OS === 'ios' ? 'padding' : undefined} keyboardVerticalOffset={62}>
<BlueFormLabel>{loc.wallets.add_wallet_name}</BlueFormLabel> <BlueFormLabel>{loc.wallets.add_wallet_name}</BlueFormLabel>
<View style={[styles.label, stylesHook.label]}> <View style={[styles.label, stylesHook.label]}>
<TextInput <TextInput
@ -475,7 +473,6 @@ const WalletsAdd: React.FC = () => {
<ActivityIndicator /> <ActivityIndicator />
)} )}
</View> </View>
</KeyboardAvoidingView>
</ScrollView> </ScrollView>
); );
}; };

View file

@ -7,7 +7,6 @@ import {
FlatList, FlatList,
InteractionManager, InteractionManager,
Keyboard, Keyboard,
KeyboardAvoidingView,
LayoutAnimation, LayoutAnimation,
ListRenderItemInfo, ListRenderItemInfo,
Platform, Platform,
@ -17,7 +16,7 @@ import {
View, View,
} from 'react-native'; } from 'react-native';
import { Badge, Icon } from '@rneui/themed'; import { Badge, Icon } from '@rneui/themed';
import { isDesktop, isTablet } from '../../blue_modules/environment'; import { isDesktop } from '../../blue_modules/environment';
import { encodeUR } from '../../blue_modules/ur'; import { encodeUR } from '../../blue_modules/ur';
import { import {
BlueButtonLink, BlueButtonLink,
@ -631,23 +630,19 @@ const ViewEditMultisigCosigners: React.FC = () => {
return ( return (
<View style={[styles.root, stylesHook.root]} ref={discardChangesRef}> <View style={[styles.root, stylesHook.root]} ref={discardChangesRef}>
<KeyboardAvoidingView
enabled={!isTablet}
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
keyboardVerticalOffset={62}
style={[styles.mainBlock, styles.root]}
>
<FlatList <FlatList
ListHeaderComponent={tipKeys} ListHeaderComponent={tipKeys}
data={data.current} data={data.current}
extraData={vaultKeyData} extraData={vaultKeyData}
renderItem={_renderKeyItem} renderItem={_renderKeyItem}
automaticallyAdjustKeyboardInsets
contentInsetAdjustmentBehavior="automatic"
automaticallyAdjustContentInsets
keyExtractor={(_item, index) => `${index}`} keyExtractor={(_item, index) => `${index}`}
/> />
<BlueSpacing10 /> <BlueSpacing10 />
{footer} {footer}
<BlueSpacing40 /> <BlueSpacing40 />
</KeyboardAvoidingView>
{renderProvideMnemonicsModal()} {renderProvideMnemonicsModal()}
@ -689,7 +684,6 @@ const styles = StyleSheet.create({
marginBottom: 32, marginBottom: 32,
}, },
headerText: { fontSize: 15, color: '#13244D' }, headerText: { fontSize: 15, color: '#13244D' },
mainBlock: { marginHorizontal: 16 },
alignItemsCenter: { alignItems: 'center', justifyContent: 'space-between' }, alignItemsCenter: { alignItems: 'center', justifyContent: 'space-between' },
shareModalHeight: { minHeight: 450 }, shareModalHeight: { minHeight: 450 },
tipKeys: { tipKeys: {

View file

@ -5,8 +5,6 @@ import {
I18nManager, I18nManager,
InteractionManager, InteractionManager,
Keyboard, Keyboard,
KeyboardAvoidingView,
Platform,
ScrollView, ScrollView,
StyleSheet, StyleSheet,
Switch, Switch,
@ -419,6 +417,7 @@ const WalletDetails = () => {
return ( return (
<ScrollView <ScrollView
automaticallyAdjustKeyboardInsets
contentInsetAdjustmentBehavior="automatic" contentInsetAdjustmentBehavior="automatic"
centerContent={isLoading} centerContent={isLoading}
contentContainerStyle={styles.scrollViewContent} contentContainerStyle={styles.scrollViewContent}
@ -453,7 +452,6 @@ const WalletDetails = () => {
} }
})()} })()}
<Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.wallets.add_wallet_name.toLowerCase()}</Text> <Text style={[styles.textLabel2, stylesHook.textLabel2]}>{loc.wallets.add_wallet_name.toLowerCase()}</Text>
<KeyboardAvoidingView enabled={!Platform.isPad} behavior={Platform.OS === 'ios' ? 'position' : null}>
<View style={[styles.input, stylesHook.input]}> <View style={[styles.input, stylesHook.input]}>
<TextInput <TextInput
value={walletName} value={walletName}
@ -467,7 +465,6 @@ const WalletDetails = () => {
testID="WalletNameInput" testID="WalletNameInput"
/> />
</View> </View>
</KeyboardAvoidingView>
<BlueSpacing20 /> <BlueSpacing20 />
<Text style={[styles.textLabel1, stylesHook.textLabel1]}>{loc.wallets.details_type.toLowerCase()}</Text> <Text style={[styles.textLabel1, stylesHook.textLabel1]}>{loc.wallets.details_type.toLowerCase()}</Text>
<Text style={[styles.textValue, stylesHook.textValue]}>{wallet.typeReadable}</Text> <Text style={[styles.textValue, stylesHook.textValue]}>{wallet.typeReadable}</Text>

View file

@ -1,12 +1,11 @@
import { useTheme } from '@react-navigation/native'; import { useTheme } from '@react-navigation/native';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Keyboard, KeyboardAvoidingView, Platform, StyleSheet, TextInput, View } from 'react-native'; import { Keyboard, ScrollView, StyleSheet, TextInput, View } from 'react-native';
import { generateChecksumWords } from '../../blue_modules/checksumWords'; import { generateChecksumWords } from '../../blue_modules/checksumWords';
import { BlueCard, BlueSpacing10, BlueSpacing20, BlueText } from '../../BlueComponents'; import { BlueCard, BlueSpacing10, BlueSpacing20, BlueText } from '../../BlueComponents';
import { randomBytes } from '../../class/rng'; import { randomBytes } from '../../class/rng';
import Button from '../../components/Button'; import Button from '../../components/Button';
import SafeArea from '../../components/SafeArea';
import loc from '../../loc'; import loc from '../../loc';
const GenerateWord = () => { const GenerateWord = () => {
@ -53,11 +52,12 @@ const GenerateWord = () => {
}; };
return ( return (
<SafeArea style={styles.blueArea}> <ScrollView
<KeyboardAvoidingView style={styles.blueArea}
enabled={!Platform.isPad}
behavior={Platform.OS === 'ios' ? 'position' : null}
keyboardShouldPersistTaps="handled" keyboardShouldPersistTaps="handled"
automaticallyAdjustContentInsets
automaticallyAdjustKeyboardInsets
contentInsetAdjustmentBehavior="automatic"
> >
<View style={styles.wrapper}> <View style={styles.wrapper}>
<BlueCard style={styles.mainCard}> <BlueCard style={styles.mainCard}>
@ -96,8 +96,7 @@ const GenerateWord = () => {
<BlueSpacing20 /> <BlueSpacing20 />
</BlueCard> </BlueCard>
</View> </View>
</KeyboardAvoidingView> </ScrollView>
</SafeArea>
); );
}; };

View file

@ -1,23 +1,12 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { useRoute } from '@react-navigation/native'; import { useRoute } from '@react-navigation/native';
import { import { ActivityIndicator, Keyboard, LayoutAnimation, Platform, ScrollView, StyleSheet, TextInput, View } from 'react-native';
ActivityIndicator,
Keyboard,
KeyboardAvoidingView,
LayoutAnimation,
Platform,
StyleSheet,
TextInput,
TouchableWithoutFeedback,
View,
} from 'react-native';
import { Icon } from '@rneui/themed'; import { Icon } from '@rneui/themed';
import Share from 'react-native-share'; import Share from 'react-native-share';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback'; import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
import { BlueDoneAndDismissKeyboardInputAccessory, BlueFormLabel, BlueSpacing10, BlueSpacing20, BlueSpacing40 } from '../../BlueComponents'; import { BlueDoneAndDismissKeyboardInputAccessory, BlueFormLabel, BlueSpacing10, BlueSpacing20, BlueSpacing40 } from '../../BlueComponents';
import presentAlert from '../../components/Alert'; import presentAlert from '../../components/Alert';
import { FButton, FContainer } from '../../components/FloatButtons'; import { FButton, FContainer } from '../../components/FloatButtons';
import SafeArea from '../../components/SafeArea';
import { useTheme } from '../../components/themes'; import { useTheme } from '../../components/themes';
import loc from '../../loc'; import loc from '../../loc';
import { useStorage } from '../../hooks/context/useStorage'; import { useStorage } from '../../hooks/context/useStorage';
@ -116,9 +105,13 @@ const SignVerify = () => {
); );
return ( return (
<SafeArea style={[styles.root, stylesHooks.root]}> <ScrollView
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}> automaticallyAdjustContentInsets
<KeyboardAvoidingView style={[styles.root, stylesHooks.root]}> automaticallyAdjustKeyboardInsets
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={styles.root}
style={[styles.root, stylesHooks.root]}
>
{!isKeyboardVisible && ( {!isKeyboardVisible && (
<> <>
<BlueSpacing20 /> <BlueSpacing20 />
@ -229,9 +222,7 @@ const SignVerify = () => {
/> />
), ),
})} })}
</KeyboardAvoidingView> </ScrollView>
</TouchableWithoutFeedback>
</SafeArea>
); );
}; };