Merge pull request #6611 from BlueWallet/tooltipfix

FIX: Tooltip was in ocassions missing styles
This commit is contained in:
GLaDOS 2024-05-26 23:08:53 +00:00 committed by GitHub
commit 034ddb1ac2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 43 additions and 26 deletions

View file

@ -1,5 +1,6 @@
import React from 'react';
import { Image, Keyboard, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { Image, Keyboard, StyleSheet, Text, TextInput, View } from 'react-native';
import { scanQrHelper } from '../helpers/scan-qr';
import loc from '../loc';
import { useTheme } from './themes';
@ -134,26 +135,25 @@ const AddressInput = ({
keyboardType={keyboardType}
/>
{editable ? (
<ToolTipMenu actions={actions} isButton onPressMenuItem={onMenuItemPressed}>
<TouchableOpacity
testID="BlueAddressInputScanQrButton"
disabled={isLoading}
onPress={async () => {
await scanButtonTapped();
Keyboard.dismiss();
// @ts-ignore: Fix later
scanQrHelper(launchedBy).then(onBarScanned);
}}
accessibilityRole="button"
style={[styles.scan, stylesHook.scan]}
accessibilityLabel={loc.send.details_scan}
accessibilityHint={loc.send.details_scan_hint}
>
<Image source={require('../img/scan-white.png')} accessible={false} />
<Text style={[styles.scanText, stylesHook.scanText]} accessible={false}>
{loc.send.details_scan}
</Text>
</TouchableOpacity>
<ToolTipMenu
actions={actions}
isButton
onPressMenuItem={onMenuItemPressed}
testID="BlueAddressInputScanQrButton"
disabled={isLoading}
onPress={async () => {
await scanButtonTapped();
Keyboard.dismiss();
if (launchedBy) scanQrHelper(launchedBy).then(value => onBarScanned({ data: value }));
}}
style={[styles.scan, stylesHook.scan]}
accessibilityLabel={loc.send.details_scan}
accessibilityHint={loc.send.details_scan_hint}
>
<Image source={require('../img/scan-white.png')} accessible={false} />
<Text style={[styles.scanText, stylesHook.scanText]} accessible={false}>
{loc.send.details_scan}
</Text>
</ToolTipMenu>
) : null}
</View>

View file

@ -44,8 +44,15 @@ const menuActions: Action[] =
text: loc.transactions.details_copy,
icon: actionIcons.Copy,
},
{ id: actionKeys.Share, text: loc.receive.details_share, icon: actionIcons.Share },
]
: [{ id: actionKeys.Share, text: loc.receive.details_share, icon: actionIcons.Share }];
: [
{
id: actionKeys.Copy,
text: loc.transactions.details_copy,
icon: actionIcons.Copy,
},
];
const QRCodeComponent: React.FC<QRCodeComponentProps> = ({
value = '',

View file

@ -16,6 +16,7 @@ const BaseToolTipMenu = (props: ToolTipMenuProps, ref: Ref<any>) => {
onMenuWillHide,
buttonStyle,
onPressMenuItem,
...restProps
} = props;
const menuItemMapped = useCallback(({ action, menuOptions }: { action: Action; menuOptions?: string[] }) => {
@ -70,8 +71,12 @@ const BaseToolTipMenu = (props: ToolTipMenuProps, ref: Ref<any>) => {
menuTitle: title,
menuItems,
}}
{...restProps}
style={buttonStyle}
>
{props.children}
<TouchableOpacity onPress={onPress} disabled={disabled} accessibilityRole="button" {...restProps}>
{props.children}
</TouchableOpacity>
</ContextMenuButton>
);
@ -98,7 +103,7 @@ const BaseToolTipMenu = (props: ToolTipMenuProps, ref: Ref<any>) => {
: {})}
>
{onPress ? (
<TouchableOpacity accessibilityRole="button" onPress={onPress}>
<TouchableOpacity accessibilityRole="button" onPress={onPress} {...restProps}>
{props.children}
</TouchableOpacity>
) : (
@ -108,7 +113,7 @@ const BaseToolTipMenu = (props: ToolTipMenuProps, ref: Ref<any>) => {
);
return isMenuPrimaryAction && onPress ? (
<TouchableOpacity onPress={onPress} disabled={disabled} accessibilityRole="button" style={buttonStyle}>
<TouchableOpacity onPress={onPress} disabled={disabled} accessibilityRole="button" {...restProps}>
{renderContextMenuButton()}
</TouchableOpacity>
) : isButton ? (

View file

@ -1,4 +1,4 @@
import { ViewStyle } from 'react-native';
import { AccessibilityRole, ViewStyle } from 'react-native';
export interface Action {
id: string | number;
@ -23,7 +23,12 @@ export interface ToolTipMenuProps {
renderPreview?: () => React.ReactNode;
onPress?: () => void;
previewValue?: string;
accessibilityRole?: AccessibilityRole;
disabled?: boolean;
testID?: string;
style?: ViewStyle | ViewStyle[];
accessibilityLabel?: string;
accessibilityHint?: string;
buttonStyle?: ViewStyle;
onMenuWillShow?: () => void;
onMenuWillHide?: () => void;