({
isLoading,
onChangeText,
type = 'default',
testID = 'BlueAddressInputScanQrButton',
beforePress,
}: AddressInputScanButtonProps)
| 20 | } |
| 21 | |
| 22 | export const AddressInputScanButton = ({ |
| 23 | isLoading, |
| 24 | onChangeText, |
| 25 | type = 'default', |
| 26 | testID = 'BlueAddressInputScanQrButton', |
| 27 | beforePress, |
| 28 | }: AddressInputScanButtonProps) => { |
| 29 | const { colors } = useTheme(); |
| 30 | const { isClipboardGetContentEnabled } = useSettings(); |
| 31 | |
| 32 | const stylesHook = StyleSheet.create({ |
| 33 | scan: { |
| 34 | backgroundColor: colors.scanLabel, |
| 35 | }, |
| 36 | scanText: { |
| 37 | color: colors.inverseForegroundColor, |
| 38 | }, |
| 39 | }); |
| 40 | |
| 41 | const toolTipOnPress = useCallback(async () => { |
| 42 | if (beforePress) { |
| 43 | await beforePress(); |
| 44 | } |
| 45 | Keyboard.dismiss(); |
| 46 | scanQrHelper().then(onChangeText); |
| 47 | }, [beforePress, onChangeText]); |
| 48 | |
| 49 | const actions = useMemo(() => { |
| 50 | const availableActions = [ |
| 51 | CommonToolTipActions.ChoosePhoto, |
| 52 | CommonToolTipActions.ImportFile, |
| 53 | { |
| 54 | ...CommonToolTipActions.PasteFromClipboard, |
| 55 | hidden: !isClipboardGetContentEnabled, |
| 56 | }, |
| 57 | ]; |
| 58 | |
| 59 | return availableActions; |
| 60 | }, [isClipboardGetContentEnabled]); |
| 61 | |
| 62 | const onMenuItemPressed = useCallback( |
| 63 | async (action: string) => { |
| 64 | switch (action) { |
| 65 | case CommonToolTipActions.PasteFromClipboard.id: |
| 66 | try { |
| 67 | let getImage: string | null = null; |
| 68 | let hasImage = false; |
| 69 | if (Platform.OS === 'android') { |
| 70 | hasImage = true; |
| 71 | } else { |
| 72 | hasImage = await Clipboard.hasImage(); |
| 73 | } |
| 74 | |
| 75 | if (hasImage) { |
| 76 | getImage = await Clipboard.getImage(); |
| 77 | } |
| 78 | |
| 79 | if (getImage) { |
nothing calls this directly
no test coverage detected