From 0dbb67ebebf82a2e9c21c5cc1485057a055b3cf6 Mon Sep 17 00:00:00 2001
From: Vit Horacek <36083550+mountiny@users.noreply.github.com>
Date: Thu, 28 Nov 2024 12:03:04 +0100
Subject: [PATCH] Merge pull request #53223 from margelo/@chrispader/fix-53161
[CP Staging] Fix: Android edge-to-edge related inset/padding issues
(cherry picked from commit 6430cd7df57910d2e929c5b1d413cd2435a9bf2f)
(CP triggered by mountiny)
---
.../AttachmentViewVideo/index.tsx | 2 +-
.../SafeAreaConsumer/index.android.tsx | 43 -------------------
src/components/SafeAreaConsumer/index.tsx | 8 ++--
.../SelectionList/BaseSelectionList.tsx | 3 +-
src/components/SelectionList/types.ts | 3 ++
.../index.android.ts => useSafeAreaInsets.ts} | 9 ++--
src/hooks/useSafeAreaInsets/index.ts | 4 --
src/hooks/useStyledSafeAreaInsets.ts | 9 ++--
src/pages/NewChatConfirmPage.tsx | 5 ++-
src/pages/NewChatPage.tsx | 22 ++++++++--
.../BaseOnboardingPersonalDetails.tsx | 4 +-
.../step/IOURequestStepConfirmation.tsx | 2 +-
.../step/IOURequestStepDescription.tsx | 1 +
.../request/step/IOURequestStepDistance.tsx | 2 +-
.../request/step/IOURequestStepMerchant.tsx | 2 +-
src/pages/workspace/WorkspaceNewRoomPage.tsx | 2 +-
.../utils/getSafeAreaInsets/defaultInsets.ts | 3 ++
.../utils/getSafeAreaInsets/index.android.ts | 18 ++++++++
src/styles/utils/getSafeAreaInsets/index.ts | 13 ++++++
src/styles/utils/index.ts | 21 ++++++++-
src/styles/variables.ts | 3 +-
21 files changed, 102 insertions(+), 77 deletions(-)
delete mode 100644 src/components/SafeAreaConsumer/index.android.tsx
rename src/hooks/{useSafeAreaInsets/index.android.ts => useSafeAreaInsets.ts} (65%)
delete mode 100644 src/hooks/useSafeAreaInsets/index.ts
create mode 100644 src/styles/utils/getSafeAreaInsets/defaultInsets.ts
create mode 100644 src/styles/utils/getSafeAreaInsets/index.android.ts
create mode 100644 src/styles/utils/getSafeAreaInsets/index.ts
diff --git a/src/components/Attachments/AttachmentView/AttachmentViewVideo/index.tsx b/src/components/Attachments/AttachmentView/AttachmentViewVideo/index.tsx
index 4db93266fe0a..e42c1e3e2fb8 100644
--- a/src/components/Attachments/AttachmentView/AttachmentViewVideo/index.tsx
+++ b/src/components/Attachments/AttachmentView/AttachmentViewVideo/index.tsx
@@ -21,7 +21,7 @@ function AttachmentViewVideo({source, isHovered = false, shouldUseSharedVideoEle
shouldUseSharedVideoElement={shouldUseSharedVideoElement && !shouldUseNarrowLayout}
isVideoHovered={isHovered}
videoDuration={duration}
- style={[styles.w100, styles.h100]}
+ style={[styles.w100, styles.h100, styles.pb5]}
/>
);
}
diff --git a/src/components/SafeAreaConsumer/index.android.tsx b/src/components/SafeAreaConsumer/index.android.tsx
deleted file mode 100644
index 7cecfb5d5107..000000000000
--- a/src/components/SafeAreaConsumer/index.android.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import React from 'react';
-// eslint-disable-next-line no-restricted-imports
-import {SafeAreaInsetsContext} from 'react-native-safe-area-context';
-import useStyleUtils from '@hooks/useStyleUtils';
-import StatusBar from '@libs/StatusBar';
-import type SafeAreaConsumerProps from './types';
-
-const defaultInsets = {top: 0, bottom: 0, left: 0, right: 0};
-
-/**
- * This component is a light wrapper around the SafeAreaInsetsContext.Consumer. There are several places where we
- * may need not just the insets, but the computed styles so we save a few lines of code with this.
- */
-function SafeAreaConsumer({children}: SafeAreaConsumerProps) {
- const StyleUtils = useStyleUtils();
-
- return (
-
- {(insets) => {
- const safeInsets = insets ?? defaultInsets;
-
- const androidInsets = {
- ...safeInsets,
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
- top: StatusBar.currentHeight || safeInsets.top,
- };
-
- const {paddingTop, paddingBottom} = StyleUtils.getSafeAreaPadding(androidInsets);
-
- return children({
- paddingTop,
- paddingBottom,
- insets: androidInsets,
- safeAreaPaddingBottomStyle: {paddingBottom},
- });
- }}
-
- );
-}
-
-SafeAreaConsumer.displayName = 'SafeAreaConsumer';
-
-export default SafeAreaConsumer;
diff --git a/src/components/SafeAreaConsumer/index.tsx b/src/components/SafeAreaConsumer/index.tsx
index 926ff91258f9..88770e1f0639 100644
--- a/src/components/SafeAreaConsumer/index.tsx
+++ b/src/components/SafeAreaConsumer/index.tsx
@@ -13,12 +13,14 @@ function SafeAreaConsumer({children}: SafeAreaConsumerProps) {
return (
- {(insets) => {
- const {paddingTop, paddingBottom} = StyleUtils.getSafeAreaPadding(insets ?? undefined);
+ {(safeAreaInsets) => {
+ const insets = StyleUtils.getSafeAreaInsets(safeAreaInsets);
+ const {paddingTop, paddingBottom} = StyleUtils.getSafeAreaPadding(insets);
+
return children({
paddingTop,
paddingBottom,
- insets: insets ?? undefined,
+ insets,
safeAreaPaddingBottomStyle: {paddingBottom},
});
}}
diff --git a/src/components/SelectionList/BaseSelectionList.tsx b/src/components/SelectionList/BaseSelectionList.tsx
index 0e12e993cc79..100a04edbb25 100644
--- a/src/components/SelectionList/BaseSelectionList.tsx
+++ b/src/components/SelectionList/BaseSelectionList.tsx
@@ -87,6 +87,7 @@ function BaseSelectionList(
alternateTextNumberOfLines = 2,
textInputRef,
headerMessageStyle,
+ confirmButtonStyles,
shouldHideListOnInitialRender = true,
textInputIconLeft,
sectionTitleStyles,
@@ -834,7 +835,7 @@ function BaseSelectionList(