Repository navigation
Safe Area: Fix - Remove bottom blank space on iOS screens #2522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cmgustavo
wants to merge
1
commit into
bitpay:develop
Choose a base branch
from
cmgustavo:bug/screen-bottom-blank-space-01
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+416
−211
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/components/modal/cloudflare-challenge/CloudflareChallenge.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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
Amountitself (edges={ALL_EDGES}on its root SafeAreaView) instead ofAmountModal, so it covers both callers:AmountModalandAmountScreen(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 keepsmarginBottom: 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.There was a problem hiding this comment.
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.