Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/amount/Amount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {useAppDispatch} from '../../utils/hooks';
import useAppSelector from '../../utils/hooks/useAppSelector';
import KeyEvent from 'react-native-keyevent';
import ArchaxFooter from '../archax/archax-footer';
import {SafeAreaView, StyleSheet, View} from 'react-native';
import {StyleSheet, View} from 'react-native';
import {ALL_EDGES, SafeAreaView} from '../safe-area/SafeAreaView';
import {createSelector} from 'reselect';
import {RootState} from '../../store';
import {logReactProfiler} from '../../utils/reactPerformanceProfiler';
Expand Down Expand Up @@ -513,7 +514,7 @@ const Amount: React.FC<AmountProps> = ({
);

return (
<SafeAreaView style={styles.amountContainer}>
<SafeAreaView style={styles.amountContainer} edges={ALL_EDGES}>
<View
style={[
styles.viewContainer,
Expand Down
3 changes: 2 additions & 1 deletion src/components/amount/AmountModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {useTheme} from '../../contexts';
import React from 'react';
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
import {SafeAreaView, StyleSheet, View} from 'react-native';
import {StyleSheet, View} from 'react-native';
import {SafeAreaView} from '../safe-area/SafeAreaView';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modal's SafeAreaView now uses the default edges (top/left/right). On notch iPhones, the keypad and action button at the bottom of the full-screen modal will render under the home indicator. Pass edges={ALL_EDGES} here, or add the bottom inset to the CTA explicitly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The fix went into Amount itself (edges={ALL_EDGES} on its root SafeAreaView) instead of AmountModal, so it covers both callers: AmountModal and AmountScreen (the send flow amount screen, where the Continue button had dropped to 15pt from the bottom edge).

Because the wrapper measures insets at the view's own position, inside AmountModal (which keeps marginBottom: 25) the bottom inset should resolve to the remaining ~9pt, matching the previous behavior rather than adding a full 34pt. Still to be checked on the simulator.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on the iOS simulator (iPhone 17 Pro, 769cbd9): the AmountScreen Continue button and the swap amount sheet both sit ~50pt above the bottom edge, clear of the home indicator.

import CloseModal from '../../../assets/img/close-modal-icon.svg';
import Button from '../../components/button/Button';
import {BaseText} from '../../components/styled/Text';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, {useCallback, useEffect, useRef, useState} from 'react';
import {
ActivityIndicator,
SafeAreaView,
StyleSheet,
TouchableOpacity,
View,
} from 'react-native';
import {SafeAreaView} from '../../safe-area/SafeAreaView';
import {WebView, WebViewNavigation} from 'react-native-webview';
import CookieManager from '@preeternal/react-native-cookie-manager';
import {useTranslation} from 'react-i18next';
Expand Down
121 changes: 121 additions & 0 deletions src/components/safe-area/SafeAreaView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import React from 'react';
import {
Platform,
SafeAreaView as NativeSafeAreaView,
StyleSheet,
ViewStyle,
} from 'react-native';
import {
Edge,
SafeAreaListener,
SafeAreaView as ContextSafeAreaView,
} from 'react-native-safe-area-context';

type Props = React.ComponentProps<typeof NativeSafeAreaView> & {
/**
* iOS only. Edges that get the safe area inset. Defaults to top, left and
* right. Screens with a fixed bottom CTA that is not inside
* CtaContainerAbsolute pass ALL_EDGES so the CTA stays above the home
* indicator.
*/
edges?: ReadonlyArray<Edge>;
};

const DEFAULT_EDGES: ReadonlyArray<Edge> = ['top', 'left', 'right'];
export const ALL_EDGES: ReadonlyArray<Edge> = [
'top',
'left',
'right',
'bottom',
];

// Style keys that place the view inside its parent. They go on the outer
// wrapper so the extra view does not change the layout of the screen.
const OUTER_STYLE_KEYS: ReadonlyArray<keyof ViewStyle> = [
'display',
'position',
'top',
'bottom',
'left',
'right',
'start',
'end',
'zIndex',
'flex',
'flexGrow',
'flexShrink',
'flexBasis',
'alignSelf',
'aspectRatio',
'width',
'height',
'minWidth',
'maxWidth',
'minHeight',
'maxHeight',
'margin',
'marginTop',
'marginBottom',
'marginLeft',
'marginRight',
'marginStart',
'marginEnd',
'marginHorizontal',
'marginVertical',
];

const splitStyle = (style: Props['style']) => {
const flat = (StyleSheet.flatten(style) || {}) as ViewStyle;
// `flex: undefined` overrides the default `flex: 1` of SafeAreaListener.
const outer: ViewStyle = {flex: undefined};
const inner: ViewStyle = {};
(Object.keys(flat) as Array<keyof ViewStyle>).forEach(key => {
const target = OUTER_STYLE_KEYS.includes(key) ? outer : inner;
(target as any)[key] = flat[key];
});
return {outer, inner};
};

const noop = () => {};

/**
* Drop-in replacement for the react-native core SafeAreaView.
*
* On iOS the core component pads all four edges, including the bottom one.
* That clips scrollable content above the home indicator and leaves a blank
* strip at the bottom of the screen. Here the bottom inset is excluded; fixed
* bottom CTAs add their own inset (see CtaContainerAbsolute).
*
* The react-native-safe-area-context SafeAreaView applies the insets of its
* nearest native provider, not the insets at its own position. Under a stack
* header that adds the status bar height a second time. SafeAreaListener
* renders a native provider right here, so the insets are measured where the
* view is (0 at the top under a header, like the core component), without
* changing the insets that useSafeAreaInsets() returns to the children.
*/
export const SafeAreaView = React.forwardRef<
React.ComponentRef<typeof NativeSafeAreaView>,
Props
>(({style, edges = DEFAULT_EDGES, ...props}, ref) => {
if (Platform.OS !== 'ios') {
return <NativeSafeAreaView ref={ref} style={style} {...props} />;
}
const {outer, inner} = splitStyle(style);
return (
<SafeAreaListener style={outer} onChange={noop}>
<ContextSafeAreaView
ref={ref as any}
edges={edges}
style={[styles.fill, inner]}
{...props}
/>
</SafeAreaListener>
);
});
SafeAreaView.displayName = 'SafeAreaView';

const styles = StyleSheet.create({
fill: {flexGrow: 1, flexShrink: 1},
});

export default SafeAreaView;
2 changes: 1 addition & 1 deletion src/components/styled/Containers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {
Dimensions,
Text,
Platform,
SafeAreaView,
ScrollView,
StyleSheet,
View,
TextInput,
TouchableOpacity as RNTouchableOpacity,
ViewStyle,
} from 'react-native';
import {SafeAreaView} from '../safe-area/SafeAreaView';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import {useTheme} from '../../contexts';
import {
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/auth/screens/CreateAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {NativeStackScreenProps} from '@react-navigation/native-stack';
import React, {useEffect, useRef, useState} from 'react';
import {Controller, useForm} from 'react-hook-form';
import {Trans, useTranslation} from 'react-i18next';
import {Keyboard, SafeAreaView, TextInput} from 'react-native';
import {Keyboard, TextInput} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import A from '../../../components/anchor/Anchor';
import Button from '../../../components/button/Button';
import Checkbox from '../../../components/checkbox/Checkbox';
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/auth/screens/ForgotPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {NativeStackScreenProps} from '@react-navigation/native-stack';
import React, {useEffect, useState} from 'react';
import {Controller, useForm} from 'react-hook-form';
import {useTranslation} from 'react-i18next';
import {Keyboard, SafeAreaView} from 'react-native';
import {Keyboard} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import Button from '../../../components/button/Button';
import BoxInput from '../../../components/form/BoxInput';
import haptic from '../../../components/haptic-feedback/haptic';
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/auth/screens/SecureAccount.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {useLayoutEffect, useRef} from 'react';
import {useTranslation} from 'react-i18next';
import {
SafeAreaView,
ScrollView as RNScrollView,
View,
ViewProps,
Expand All @@ -10,6 +9,7 @@ import {
TextProps,
StyleSheet,
} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import {
HeaderRightContainer,
ScreenGutter,
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/auth/screens/TwoFactor.Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {NativeStackScreenProps} from '@react-navigation/native-stack';
import React, {useEffect} from 'react';
import {Controller, useForm} from 'react-hook-form';
import {useTranslation} from 'react-i18next';
import {Keyboard, SafeAreaView, StyleSheet} from 'react-native';
import {Keyboard, StyleSheet} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import {useDispatch, useSelector} from 'react-redux';
import Button from '../../../components/button/Button';
import BoxInput from '../../../components/form/BoxInput';
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/auth/screens/TwoFactor.Pair.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {NativeStackScreenProps} from '@react-navigation/native-stack';
import React, {useEffect} from 'react';
import {Controller, useForm} from 'react-hook-form';
import {useTranslation} from 'react-i18next';
import {Keyboard, SafeAreaView, StyleSheet} from 'react-native';
import {Keyboard, StyleSheet} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import {useDispatch, useSelector} from 'react-redux';
import Button from '../../../components/button/Button';
import BoxInput from '../../../components/form/BoxInput';
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/auth/screens/VerifyEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import AuthFormContainer, {
} from '../components/AuthFormContainer';
import {
BackHandler,
SafeAreaView,
View,
ViewProps,
Text,
TextProps,
StyleSheet,
} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import {RootStacks} from '../../../Root';
import {TabsScreens} from '../../tabs/TabsStack';
import {BitpayIdScreens} from '../../bitpay-id/BitpayIdGroup';
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/bitpay-id/components/BasePairing.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, {useEffect, useRef} from 'react';
import {useTranslation} from 'react-i18next';
import {useDispatch, useSelector} from 'react-redux';
import {SafeAreaView, View, ViewProps, StyleSheet} from 'react-native';
import {View, ViewProps, StyleSheet} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import Spinner from '../../../components/spinner/Spinner';
import {ScreenGutter} from '../../../components/styled/Containers';
import {RootState} from '../../../store';
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/bitpay-id/screens/EnableTwoFactor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
ViewProps,
ScrollView,
ScrollViewProps,
SafeAreaView,
Text,
TextProps,
Keyboard,
StyleSheet,
} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import {TouchableOpacity} from '@components/base/TouchableOpacity';
import yup from '../../../lib/yup';
import {yupResolver} from '@hookform/resolvers/yup';
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/bitpay-id/screens/ProfileSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, {useEffect} from 'react';
import {useTranslation} from 'react-i18next';
import {useTheme} from '../../../contexts';
import {
SafeAreaView,
ScrollView as RNScrollView,
ScrollViewProps,
View,
Expand All @@ -12,6 +11,7 @@ import {
TextProps,
StyleSheet,
} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import Avatar from '../../../components/avatar/BitPayIdAvatar';
import {
ActiveOpacity,
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/bitpay-id/screens/ReceiveSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {useEffect, useMemo, useState} from 'react';
import {useTranslation} from 'react-i18next';
import {uniqBy} from '../../../utils/array';
import {
SafeAreaView,
ScrollView as RNScrollView,
ScrollViewProps,
View,
Expand All @@ -11,6 +10,7 @@ import {
TextProps,
StyleSheet,
} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import {useNavigation, useTheme} from '@react-navigation/native';
import {NativeStackScreenProps} from '@react-navigation/native-stack';
import {TouchableOpacity} from '@components/base/TouchableOpacity';
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/bitpay-id/screens/TwoFactorEnabled.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {useRef} from 'react';
import {SafeAreaView, View, ViewProps, StyleSheet} from 'react-native';
import {View, ViewProps, StyleSheet} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import Button from '../../../components/button/Button';
import {ScreenGutter} from '../../../components/styled/Containers';
import SuccessSvg from '../../../../assets/img/success.svg';
Expand Down
9 changes: 2 additions & 7 deletions src/navigation/onboarding/screens/TermsOfUse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import {CommonActions, useTheme} from '@react-navigation/native';
import {NativeStackScreenProps} from '@react-navigation/native-stack';
import React, {ReactElement, useLayoutEffect, useState} from 'react';
import {useTranslation} from 'react-i18next';
import {
DeviceEventEmitter,
ScrollView,
SafeAreaView,
View,
StyleSheet,
} from 'react-native';
import {DeviceEventEmitter, ScrollView, View, StyleSheet} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import {useAndroidBackHandler} from 'react-navigation-backhandler';
import Button from '../../../components/button/Button';
import {CtaContainerAbsolute} from '../../../components/styled/Containers';
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/scan/screens/Scan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import {
ActivityIndicator,
Alert,
Linking,
SafeAreaView,
StyleSheet,
View,
} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import {BaseText, Link} from '../../../components/styled/Text';

const styles = StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/services/screens/BuyAndSellRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ import {useTheme} from '../../../contexts';
import Modal from 'react-native-modal';
import {
ActivityIndicator,
SafeAreaView,
StyleSheet,
TextProps,
View,
ViewProps,
} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import WebView, {
WebViewMessageEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
View,
StyleSheet,
Text,
SafeAreaView,
ViewProps,
TextProps,
} from 'react-native';
import {SafeAreaView} from '../../../components/safe-area/SafeAreaView';
import Modal from 'react-native-modal';
import {
useTheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import {
ViewProps,
TextProps,
ScrollView,
SafeAreaView,
} from 'react-native';
import {
ALL_EDGES,
SafeAreaView,
} from '../../../components/safe-area/SafeAreaView';
import {useNavigation} from '@react-navigation/native';
import Button, {ButtonState} from '../../../components/button/Button';
import {BaseText} from '../../../components/styled/Text';
Expand Down Expand Up @@ -137,7 +140,7 @@ const styles = StyleSheet.create({
});

const Container: React.FC<ViewProps> = ({style, ...rest}) => (
<SafeAreaView style={[styles.container, style]} {...rest} />
<SafeAreaView style={[styles.container, style]} edges={ALL_EDGES} {...rest} />
);

const HeaderContainer: React.FC<ViewProps> = ({style, ...rest}) => (
Expand Down
Loading
Loading