Skip to content

Commit 4b4e3a6

Browse files
authored
fix: order screen header inset (#30143)
## **Description** Perps header regressed on iOS for order screens, including close position. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: fixes iOS header inset for perps order screens ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** <!-- Every checklist item must be consciously assessed before marking this PR as "Ready for review". A checked box means you deliberately considered that responsibility, not that you literally performed every action listed. Unchecked boxes are ambiguous: they are not an implicit "N/A" and they are not a silent "skip". See `docs/readme/ready-for-review.md` for the full checklist semantics. --> - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [ ] I've tested on Android - Ideally on a mid-range device; emulator is acceptable - [ ] I've tested with a power user scenario - Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [ ] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). ## **Pre-merge reviewer checklist** <!-- Reviewer checklist items follow the same semantics as the author checklist: an unchecked box is ambiguous, a checked box means the reviewer consciously assessed that responsibility. See `docs/readme/ready-for-review.md`. --> - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk UI layout adjustment limited to Perps order/close-position screens; main risk is unintended spacing changes on devices with/without notches. > > **Overview** > Fixes an iOS safe-area regression on Perps order flows by **removing top safe-area insets from the screen `SafeAreaView`** (`PerpsOrderView`, `PerpsClosePositionView`) and **applying top inset padding directly in `PerpsOrderHeader`** via `useSafeAreaInsets`. > > This prevents double/incorrect top padding while keeping bottom safe-area handling intact. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7a59985. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 34d3395 commit 4b4e3a6

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

app/components/UI/Perps/Views/PerpsClosePositionView/PerpsClosePositionView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ const PerpsClosePositionView: React.FC = () => {
569569
);
570570

571571
return (
572-
<SafeAreaView style={styles.container}>
572+
<SafeAreaView style={styles.container} edges={['bottom']}>
573573
<PerpsOrderHeader
574574
asset={position.symbol}
575575
price={currentPrice}

app/components/UI/Perps/Views/PerpsOrderView/PerpsOrderView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ const PerpsOrderViewContentBase: React.FC<PerpsOrderViewContentProps> = ({
13251325
}
13261326

13271327
return (
1328-
<SafeAreaView style={styles.container} edges={['top', 'bottom']}>
1328+
<SafeAreaView style={styles.container} edges={['bottom']}>
13291329
{/* Header */}
13301330
<PerpsOrderHeader
13311331
asset={getPerpsDisplaySymbol(orderForm.asset)}

app/components/UI/Perps/components/PerpsOrderHeader/PerpsOrderHeader.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useNavigation } from '@react-navigation/native';
22
import React, { useCallback, useMemo } from 'react';
33
import { TouchableOpacity, View } from 'react-native';
4+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
45
import { PerpsOrderHeaderSelectorsIDs } from '../../Perps.testIds';
56
import ButtonIcon, {
67
ButtonIconSizes,
@@ -54,6 +55,7 @@ const PerpsOrderHeader: React.FC<PerpsOrderHeaderProps> = ({
5455
const { colors } = useTheme();
5556
const styles = useMemo(() => createStyles(colors), [colors]);
5657
const navigation = useNavigation();
58+
const { top: topInset } = useSafeAreaInsets();
5759

5860
const handleBack = useCallback(() => {
5961
if (onBack) {
@@ -96,8 +98,16 @@ const PerpsOrderHeader: React.FC<PerpsOrderHeaderProps> = ({
9698
}
9799
}, [priceChange, price]);
98100

101+
const headerStyle = useMemo(
102+
() => [
103+
styles.header,
104+
topInset > 0 ? { paddingTop: 16 + topInset } : undefined,
105+
],
106+
[styles.header, topInset],
107+
);
108+
99109
return (
100-
<View style={styles.header} testID={PerpsOrderHeaderSelectorsIDs.HEADER}>
110+
<View style={headerStyle} testID={PerpsOrderHeaderSelectorsIDs.HEADER}>
101111
<ButtonIcon
102112
testID={PerpsOrderHeaderSelectorsIDs.BACK_BUTTON}
103113
iconName={IconName.ArrowLeft}

0 commit comments

Comments
 (0)