mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 09:50:15 +01:00
REF: useMemo
This commit is contained in:
parent
8dee082001
commit
6aed1a4e93
@ -1,5 +1,6 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
import { useTheme } from '../../components/themes';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
export const styles = StyleSheet.create({
|
||||
root: {
|
||||
@ -18,12 +19,24 @@ export const styles = StyleSheet.create({
|
||||
});
|
||||
|
||||
export const useDynamicStyles = () => {
|
||||
const { colors } = useTheme();
|
||||
const theme = useTheme();
|
||||
|
||||
return StyleSheet.create({
|
||||
root: {
|
||||
backgroundColor: colors.elevated,
|
||||
},
|
||||
// More properties
|
||||
});
|
||||
const stylesHook = useMemo(
|
||||
() =>
|
||||
StyleSheet.create({
|
||||
root: {
|
||||
backgroundColor: theme.colors.elevated,
|
||||
// Add more dynamic styles as needed
|
||||
},
|
||||
container: {
|
||||
// Example of another dynamic style
|
||||
borderColor: theme.colors.inputBorderColor,
|
||||
borderWidth: 1,
|
||||
},
|
||||
// You can add more dynamically themed styles here
|
||||
}),
|
||||
[theme],
|
||||
); // Recompute styles only when theme changes
|
||||
|
||||
return stylesHook;
|
||||
};
|
||||
|
@ -78,36 +78,36 @@ const WalletXpub: React.FC = () => {
|
||||
setQRCodeSize(height > width ? width - 40 : e.nativeEvent.layout.width / 1.8);
|
||||
};
|
||||
|
||||
const handleShareButtonPressed = () => {
|
||||
Share.open({ message: xpub }).catch(error => console.log(error));
|
||||
};
|
||||
const handleShareButtonPressed = useCallback(() => {
|
||||
Share.open({ message: xpub }).catch(console.log);
|
||||
}, [xpub]);
|
||||
|
||||
return isLoading ? (
|
||||
<View style={[styles.container, stylesHook.root]}>
|
||||
<ActivityIndicator />
|
||||
</View>
|
||||
) : (
|
||||
return (
|
||||
<SafeArea style={[styles.root, stylesHook.root]} onLayout={onLayout}>
|
||||
<>
|
||||
<View style={styles.container}>
|
||||
{wallet && (
|
||||
<>
|
||||
<View>
|
||||
<BlueText>{wallet.typeReadable}</BlueText>
|
||||
</View>
|
||||
<BlueSpacing20 />
|
||||
</>
|
||||
)}
|
||||
<QRCodeComponent value={xpub} size={qrCodeSize} />
|
||||
{isLoading ? (
|
||||
<ActivityIndicator />
|
||||
) : (
|
||||
<>
|
||||
<View style={styles.container}>
|
||||
{wallet && (
|
||||
<>
|
||||
<View>
|
||||
<BlueText>{wallet.typeReadable}</BlueText>
|
||||
</View>
|
||||
<BlueSpacing20 />
|
||||
</>
|
||||
)}
|
||||
<QRCodeComponent value={xpub} size={qrCodeSize} />
|
||||
|
||||
<BlueSpacing20 />
|
||||
<BlueCopyTextToClipboard text={xPubText} />
|
||||
</View>
|
||||
<HandoffComponent title={loc.wallets.xpub_title} type={HandoffComponent.activityTypes.Xpub} userInfo={{ xpub: xPubText }} />
|
||||
<View style={styles.share}>
|
||||
<Button onPress={handleShareButtonPressed} title={loc.receive.details_share} />
|
||||
</View>
|
||||
</>
|
||||
<BlueSpacing20 />
|
||||
<BlueCopyTextToClipboard text={xPubText} />
|
||||
</View>
|
||||
<HandoffComponent title={loc.wallets.xpub_title} type={HandoffComponent.activityTypes.Xpub} userInfo={{ xpub: xPubText }} />
|
||||
<View style={styles.share}>
|
||||
<Button onPress={handleShareButtonPressed} title={loc.receive.details_share} />
|
||||
</View>
|
||||
</>
|
||||
)}
|
||||
</SafeArea>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user