Skip to content

Commit

Permalink
fix(suite-native): use react-native-keyboard-controller for keyboard …
Browse files Browse the repository at this point in the history
…handling
  • Loading branch information
yanascz committed Feb 11, 2025
1 parent 25ffdcd commit 68efa08
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 127 deletions.
2 changes: 1 addition & 1 deletion scripts/list-outdated-dependencies/mobile-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ expo-updates
jotai
lottie-react-native
react-native-gesture-handler
react-native-keyboard-aware-scroll-view
react-native-keyboard-controller
react-native-mmkv
react-native-quick-crypto
react-native-restart
Expand Down
2 changes: 1 addition & 1 deletion suite-native/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"react-native": "0.76.1",
"react-native-edge-to-edge": "^1.3.1",
"react-native-gesture-handler": "^2.21.0",
"react-native-keyboard-aware-scroll-view": "0.9.5",
"react-native-keyboard-controller": "1.16.2",
"react-native-mmkv": "2.12.2",
"react-native-quick-crypto": "^0.7.6",
"react-native-reanimated": "^3.16.7",
Expand Down
17 changes: 10 additions & 7 deletions suite-native/app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect } from 'react';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { KeyboardProvider } from 'react-native-keyboard-controller';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { useDispatch, useSelector } from 'react-redux';

Expand Down Expand Up @@ -80,13 +81,15 @@ const PureApp = () => (
<IntlProvider>
<StoreProvider>
<SentryProvider>
<SafeAreaProvider>
<StylesProvider>
<NavigationContainerWithAnalytics>
<AppComponent />
</NavigationContainerWithAnalytics>
</StylesProvider>
</SafeAreaProvider>
<KeyboardProvider>
<SafeAreaProvider>
<StylesProvider>
<NavigationContainerWithAnalytics>
<AppComponent />
</NavigationContainerWithAnalytics>
</StylesProvider>
</SafeAreaProvider>
</KeyboardProvider>
</SentryProvider>
</StoreProvider>
</IntlProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ReactNode } from 'react';
import { KeyboardAvoidingView, Platform } from 'react-native';

import { Box, PictogramTitleHeader, VStack } from '@suite-native/atoms';
import { Screen, ScreenFooterGradient } from '@suite-native/navigation';
import { KeyboardAvoidingScreen, ScreenFooterGradient } from '@suite-native/navigation';

import { AccountImportScreenHeader } from './AccountImportScreenHeader';

Expand All @@ -21,13 +20,13 @@ export const AccountImportSummaryScreen = ({
footer,
testID,
}: AccountImportSummaryScreenProps) => (
<Screen
<KeyboardAvoidingScreen
header={<AccountImportScreenHeader />}
footer={
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
<>
<ScreenFooterGradient />
<Box marginHorizontal="sp16">{footer}</Box>
</KeyboardAvoidingView>
</>
}
>
<VStack spacing="sp32" flex={1}>
Expand All @@ -43,5 +42,5 @@ export const AccountImportSummaryScreen = ({
{children}
</Box>
</VStack>
</Screen>
</KeyboardAvoidingScreen>
);
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Translation, useTranslate } from '@suite-native/intl';
import {
AccountsImportStackParamList,
AccountsImportStackRoutes,
Screen,
KeyboardAvoidingScreen,
StackProps,
} from '@suite-native/navigation';
import { ScanQRBottomSheet } from '@suite-native/qr-code';
Expand All @@ -36,9 +36,6 @@ import { XpubImportSection, networkTypeToTitleMap } from '../components/XpubImpo

const FORM_BUTTON_FADE_IN_DURATION = 200;

// Extra padding needed to make multiline xpub input form visible even with the sticky footer.
const EXTRA_KEYBOARD_AVOIDING_VIEW_HEIGHT = 350;

const cameraStyle = prepareNativeStyle(_ => ({
alignItems: 'center',
marginTop: 20,
Expand Down Expand Up @@ -173,10 +170,9 @@ export const XpubScanScreen = ({
};

return (
<Screen
<KeyboardAvoidingScreen
header={<AccountImportScreenHeader closeActionType="back" />}
footer={<XpubHint networkType={networkType} handleOpen={handleOpenHint} />}
extraKeyboardAvoidingViewHeight={EXTRA_KEYBOARD_AVOIDING_VIEW_HEIGHT}
>
<Card>
<SelectableNetworkItem symbol={networkSymbol} />
Expand Down Expand Up @@ -232,6 +228,6 @@ export const XpubScanScreen = ({
onCodeScanned={handleBarCodeScanned}
onClose={handleToggleScanner}
/>
</Screen>
</KeyboardAvoidingScreen>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from 'react';

import { Text, VStack } from '@suite-native/atoms';
import { TitleHeader, VStack } from '@suite-native/atoms';
import { Screen } from '@suite-native/navigation';

import { PassphraseScreenHeader } from './PassphraseScreenHeader';
Expand All @@ -18,10 +18,7 @@ export const PassphraseContentScreenWrapper = ({
}: PassphraseContentScreenWrapperProps) => (
<Screen header={<PassphraseScreenHeader />}>
<VStack marginTop="sp8" spacing="sp16">
<VStack>
<Text variant="titleMedium">{title}</Text>
{subtitle && <Text>{subtitle}</Text>}
</VStack>
<TitleHeader title={title} subtitle={subtitle} titleVariant="titleMedium" />
{children}
</VStack>
</Screen>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const PassphraseEnterOnTrezorScreen = () => {
};

return (
// TODO: Use just Screen
<PassphraseContentScreenWrapper
title={<Translation id="modulePassphrase.title" />}
subtitle={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { LayoutChangeEvent, View } from 'react-native';
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';

import { EventType, analytics } from '@suite-native/analytics';
import { Box, Button, HStack, Text, VStack } from '@suite-native/atoms';
import { Box, Button, HStack, Text, TitleHeader, VStack } from '@suite-native/atoms';
import { Icon } from '@suite-native/icons';
import { Translation, useTranslate } from '@suite-native/intl';
import { useOpenLink } from '@suite-native/link';
import { KeyboardAvoidingScreen } from '@suite-native/navigation';
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';

import { PassphraseContentScreenWrapper } from '../../components/passphrase/PassphraseContentScreenWrapper';
import { PassphraseForm } from '../../components/passphrase/PassphraseForm';
import { PassphraseScreenHeader } from '../../components/passphrase/PassphraseScreenHeader';

const ANIMATION_DURATION = 300;

Expand Down Expand Up @@ -70,18 +71,20 @@ export const PassphraseFormScreen = () => {
};

return (
<PassphraseContentScreenWrapper
title={<Translation id="modulePassphrase.title" />}
subtitle={
<Translation
id="modulePassphrase.subtitle"
values={{
bold: chunks => <Text variant="highlight">{chunks}</Text>,
}}
<KeyboardAvoidingScreen header={<PassphraseScreenHeader />}>
<VStack marginTop="sp8" spacing="sp16">
<TitleHeader
title={<Translation id="modulePassphrase.title" />}
subtitle={
<Translation
id="modulePassphrase.subtitle"
values={{
bold: chunks => <Text variant="highlight">{chunks}</Text>,
}}
/>
}
titleVariant="titleMedium"
/>
}
>
<VStack spacing="sp16">
<View
style={applyStyle(animationWrapperStyle)}
onLayout={(event: LayoutChangeEvent) =>
Expand Down Expand Up @@ -158,6 +161,6 @@ export const PassphraseFormScreen = () => {
inputLabel={translate('modulePassphrase.form.createWalletInputLabel')}
/>
</VStack>
</PassphraseContentScreenWrapper>
</KeyboardAvoidingScreen>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import { useDispatch } from 'react-redux';
import { isFulfilled } from '@reduxjs/toolkit';

import { EventType, analytics } from '@suite-native/analytics';
import { AlertBox, Text, VStack } from '@suite-native/atoms';
import { AlertBox, Text, TitleHeader, VStack } from '@suite-native/atoms';
import {
finishPassphraseFlow,
verifyPassphraseOnEmptyWalletThunk,
} from '@suite-native/device-authorization';
import { Translation, useTranslate } from '@suite-native/intl';
import { KeyboardAvoidingScreen } from '@suite-native/navigation';

import { PassphraseContentScreenWrapper } from '../../components/passphrase/PassphraseContentScreenWrapper';
import { PassphraseForm } from '../../components/passphrase/PassphraseForm';
import { PassphraseScreenHeader } from '../../components/passphrase/PassphraseScreenHeader';

export const PassphraseVerifyEmptyWalletScreen = () => {
const dispatch = useDispatch();
Expand All @@ -34,15 +35,17 @@ export const PassphraseVerifyEmptyWalletScreen = () => {
}, [dispatch]);

return (
<PassphraseContentScreenWrapper
title={
<Translation id="modulePassphrase.emptyPassphraseWallet.verifyEmptyWallet.title" />
}
subtitle={
<Translation id="modulePassphrase.emptyPassphraseWallet.verifyEmptyWallet.description" />
}
>
<VStack spacing="sp16">
<KeyboardAvoidingScreen header={<PassphraseScreenHeader />}>
<VStack marginTop="sp8" spacing="sp16">
<TitleHeader
title={
<Translation id="modulePassphrase.emptyPassphraseWallet.verifyEmptyWallet.title" />
}
subtitle={
<Translation id="modulePassphrase.emptyPassphraseWallet.verifyEmptyWallet.description" />
}
titleVariant="titleMedium"
/>
<AlertBox
variant="warning"
title={
Expand All @@ -60,6 +63,6 @@ export const PassphraseVerifyEmptyWalletScreen = () => {
inputLabel={translate('modulePassphrase.form.verifyPassphraseInputLabel')}
/>
</VStack>
</PassphraseContentScreenWrapper>
</KeyboardAvoidingScreen>
);
};
15 changes: 0 additions & 15 deletions suite-native/module-send/src/components/SendScreen.tsx

This file was deleted.

9 changes: 3 additions & 6 deletions suite-native/module-send/src/screens/SendAccountsScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { AccountsList, OnSelectAccount } from '@suite-native/accounts';
import { useTranslate } from '@suite-native/intl';
import {
Screen,
ScreenHeader,
SendStackParamList,
SendStackRoutes,
StackProps,
} from '@suite-native/navigation';

import { SendScreen } from '../components/SendScreen';

// TODO: So far we do not want enable send form for any other networkS than Bitcoin-like coins.
// This filter will be removed in a follow up PR.
const BITCOIN_LIKE_FILTER = 'bitcoin';
Expand All @@ -25,15 +24,13 @@ export const SendAccountsScreen = ({

// TODO: move text content to @suite-native/intl package when is copy ready
return (
<SendScreen
screenHeader={<ScreenHeader content={translate('moduleSend.accountsList.title')} />}
>
<Screen header={<ScreenHeader content={translate('moduleSend.accountsList.title')} />}>
{/* TODO: Enable filtering same as receive screen account list has. */}
<AccountsList
onSelectAccount={navigateToSendFormScreen}
filterValue={BITCOIN_LIKE_FILTER}
hideTokensIntoModal
/>
</SendScreen>
</Screen>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AccountsRootState, DeviceRootState, SendRootState } from '@suite-common
import { Box, Text, VStack } from '@suite-native/atoms';
import { Translation, useTranslate } from '@suite-native/intl';
import {
Screen,
ScreenHeader,
SendStackParamList,
SendStackRoutes,
Expand All @@ -13,7 +14,6 @@ import {

import { AddressReviewStepList } from '../components/AddressReviewStepList';
import { SendConfirmOnDeviceImage } from '../components/SendConfirmOnDeviceImage';
import { SendScreen } from '../components/SendScreen';
import {
selectIsReceiveAddressOutputConfirmed,
selectIsTransactionReviewInProgress,
Expand Down Expand Up @@ -43,8 +43,8 @@ export const SendAddressReviewScreen = ({
}, [isAddressConfirmed, accountKey, navigation, tokenContract]);

return (
<SendScreen
screenHeader={
<Screen
header={
<ScreenHeader
content={translate('moduleSend.review.outputs.title')}
closeActionType={isTransactionReviewInProgress ? 'close' : 'back'}
Expand All @@ -61,6 +61,6 @@ export const SendAddressReviewScreen = ({
<AddressReviewStepList />
</VStack>
</Box>
</SendScreen>
</Screen>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AccountsRootState, DeviceRootState, SendRootState } from '@suite-common
import { Text, VStack } from '@suite-native/atoms';
import { Translation, useTranslate } from '@suite-native/intl';
import {
Screen,
ScreenHeader,
SendStackParamList,
SendStackRoutes,
Expand All @@ -15,7 +16,6 @@ import {

import { ReviewDestinationTagCard } from '../components/ReviewDestinationTagCard';
import { SendConfirmOnDeviceImage } from '../components/SendConfirmOnDeviceImage';
import { SendScreen } from '../components/SendScreen';
import { useHandleOnDeviceTransactionReview } from '../hooks/useHandleOnDeviceTransactionReview';
import {
selectIsDestinationTagOutputConfirmed,
Expand Down Expand Up @@ -65,8 +65,8 @@ export const SendDestinationTagReviewScreen = ({
}, [isDestinationTagConfirmed, accountKey, navigation, tokenContract, transaction]);

return (
<SendScreen
screenHeader={
<Screen
header={
<ScreenHeader
content={translate('moduleSend.review.outputs.title')}
closeActionType={isTransactionReviewInProgress ? 'close' : 'back'}
Expand All @@ -80,6 +80,6 @@ export const SendDestinationTagReviewScreen = ({
</Text>
<ReviewDestinationTagCard destinationTag={destinationTag} />
</VStack>
</SendScreen>
</Screen>
);
};
Loading

0 comments on commit 68efa08

Please sign in to comment.