diff --git a/suite-native/module-authorize-device/src/components/connect/PinOnKeypad.tsx b/suite-native/module-authorize-device/src/components/connect/PinOnKeypad.tsx index d4e590f05d9..36e1788a51b 100644 --- a/suite-native/module-authorize-device/src/components/connect/PinOnKeypad.tsx +++ b/suite-native/module-authorize-device/src/components/connect/PinOnKeypad.tsx @@ -1,7 +1,11 @@ +import { useState } from 'react'; +import { LayoutChangeEvent } from 'react-native'; + import { PinFormValues, pinFormSchema } from '@suite-common/validators'; import { Box, Card, HStack, Image, Loader, Text, VStack } from '@suite-native/atoms'; import { Form, useForm } from '@suite-native/forms'; import { Translation, TxKeyPath } from '@suite-native/intl'; +import { getScreenHeight } from '@trezor/env-utils'; import { prepareNativeStyle, useNativeStyles } from '@trezor/styles'; import { PinFormControlButtons } from './PinFormControlButtons'; @@ -65,6 +69,14 @@ const loaderWrapperStyle = prepareNativeStyle(utils => ({ backgroundColor: utils.colors.backgroundSurfaceElevation1, })); +const imageStyle = prepareNativeStyle(() => ({ + flex: 1, + width: '100%', + maxHeight: 194, +})); + +const SCREEN_HEIGHT = getScreenHeight(); + export const PinOnKeypad = ({ variant, onSuccess }: PinOnKeypadProps) => { const { applyStyle } = useNativeStyles(); const form = useForm({ @@ -74,41 +86,67 @@ export const PinOnKeypad = ({ variant, onSuccess }: PinOnKeypadProps) => { }, }); + const [isImageDisplayed, setIsImageDisplayed] = useState(true); + const translations = translationsMap[variant]; + // Hide image if the screen is too small to fit both the image and the pin matrix. + const handlePinMatrixLayoutEvent = (event: LayoutChangeEvent) => { + if (event.nativeEvent.layout.height > 0.5 * SCREEN_HEIGHT) { + setIsImageDisplayed(false); + + return; + } + setIsImageDisplayed(true); + }; + return ( - - -
- - - - - - } /> - - - - - {pinMatrix.map(pinRow => ( - - {pinRow.map(value => ( - - ))} - - ))} + + {isImageDisplayed && ( + + )} + + + + + + + + } /> + - - {form.formState.isSubmitted && ( - - - - - + + + {pinMatrix.map(pinRow => ( + + {pinRow.map(value => ( + + ))} + + ))} - )} - - + + {form.formState.isSubmitted && ( + + + + + + + )} +
+ +
); }; diff --git a/suite-native/module-device-settings/src/components/DeviceInteractionScreenWrapper.tsx b/suite-native/module-device-settings/src/components/DeviceInteractionScreenWrapper.tsx index 904239008ee..857a12a9d22 100644 --- a/suite-native/module-device-settings/src/components/DeviceInteractionScreenWrapper.tsx +++ b/suite-native/module-device-settings/src/components/DeviceInteractionScreenWrapper.tsx @@ -30,7 +30,6 @@ export const DeviceInteractionScreenWrapper = ({ return ( } - hasBottomInset={false} isScrollable={false} > {children}