Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dbcaad9
fix: adjust ios and android safe area insets padding style
chrispader Nov 27, 2024
b011c91
fix: extract Android specific safe area logic and simplify safe area …
chrispader Nov 27, 2024
edcdfbe
fix: bottom inset spacing on IOURequestStepConfirmation screen
chrispader Nov 27, 2024
9aa9b50
fix: make IOU submit button spacing consistent
chrispader Nov 27, 2024
d9ae806
fix: MoneyRequestConfirmationList bottom padding
chrispader Nov 27, 2024
d5f53d1
fix: useSafeAreaInsets hook
chrispader Nov 27, 2024
c52550f
fix: bottom insets/padding in "New chat"
chrispader Nov 27, 2024
a543d86
fix: padding broken in other forms
chrispader Nov 27, 2024
fef2955
Merge branch 'main' into @chrispader/fix-53161
chrispader Nov 27, 2024
8a6d727
fix: linting
chrispader Nov 27, 2024
62297e2
fix: adjust android insets percentage
chrispader Nov 27, 2024
ff72555
fix: improve more screens
chrispader Nov 27, 2024
ae74a60
refactor: implement better inset and padding handling in ScreenWrapper
chrispader Nov 27, 2024
cabc507
Merge branch 'main' into @chrispader/screen-wrapper-better-inset-padd…
chrispader Nov 27, 2024
7ebc864
Merge branch 'main' into @chrispader/fix-53161
chrispader Nov 27, 2024
71c00f1
feat: add useEdgeSpacing hook
chrispader Nov 27, 2024
33c2afa
fix: set inset bottom to 0 if keyboard is open
chrispader Nov 27, 2024
692d96c
Merge branch '@chrispader/screen-wrapper-better-inset-padding-handlin…
chrispader Nov 27, 2024
aa31378
Revert "Merge branch '@chrispader/screen-wrapper-better-inset-padding…
chrispader Nov 27, 2024
c50e214
fix: new chat confirm page
chrispader Nov 27, 2024
605c404
fix: video controls on native
chrispader Nov 27, 2024
6eb84c5
fix: new chat confirm page
chrispader Nov 28, 2024
e3b589b
fix: improve video player insets
chrispader Nov 28, 2024
8748e79
fix: remove useKeyboardState hook usage
chrispader Nov 28, 2024
30483a8
fix: simplify fixes
chrispader Nov 28, 2024
08e9a18
fix: remaining bugs
chrispader Nov 28, 2024
50e3290
fix: iou confirmation
chrispader Nov 28, 2024
1aff99c
fix: remove unnecessary change
chrispader Nov 28, 2024
7e411ab
fix: use full insets on android
chrispader Nov 28, 2024
6cbbf31
fix: new chat
chrispader Nov 28, 2024
c75fd3c
fix: simplify iou request confirmation
chrispader Nov 28, 2024
4761ed5
add insetsPercentage parameter to useStyledSafeAreaInsets hook
chrispader Nov 28, 2024
e44e493
fix: remove unused code
chrispader Nov 28, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
/>
);
}
Expand Down
43 changes: 0 additions & 43 deletions src/components/SafeAreaConsumer/index.android.tsx

This file was deleted.

8 changes: 5 additions & 3 deletions src/components/SafeAreaConsumer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ function SafeAreaConsumer({children}: SafeAreaConsumerProps) {

return (
<SafeAreaInsetsContext.Consumer>
{(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},
});
}}
Expand Down
3 changes: 2 additions & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function BaseSelectionList<TItem extends ListItem>(
alternateTextNumberOfLines = 2,
textInputRef,
headerMessageStyle,
confirmButtonStyles,
shouldHideListOnInitialRender = true,
textInputIconLeft,
sectionTitleStyles,
Expand Down Expand Up @@ -835,7 +836,7 @@ function BaseSelectionList<TItem extends ListItem>(
<Button
success={!shouldUseDefaultTheme}
large
style={[styles.w100]}
style={[styles.w100, confirmButtonStyles]}
text={confirmButtonText || translate('common.confirm')}
onPress={onConfirm}
pressOnEnter
Expand Down
3 changes: 3 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
/** Styles to apply to the header message */
headerMessageStyle?: StyleProp<ViewStyle>;

/** Styles to apply to submit button */
confirmButtonStyles?: StyleProp<ViewStyle>;

/** Text to display on the confirm button */
confirmButtonText?: string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import type {EdgeInsets} from 'react-native-safe-area-context';
// eslint-disable-next-line no-restricted-imports
import {useSafeAreaInsets as useSafeAreaInsetsInternal} from 'react-native-safe-area-context';
import StatusBar from '@libs/StatusBar';
import useStyleUtils from './useStyleUtils';

function useSafeAreaInsets(): EdgeInsets {
const StyleUtils = useStyleUtils();
const insets = useSafeAreaInsetsInternal();
const adjustedInsets = StyleUtils.getSafeAreaInsets(insets);

return {
...insets,
top: StatusBar.currentHeight ?? insets.top,
};
return adjustedInsets;
}

export default useSafeAreaInsets;
4 changes: 0 additions & 4 deletions src/hooks/useSafeAreaInsets/index.ts

This file was deleted.

9 changes: 4 additions & 5 deletions src/hooks/useStyledSafeAreaInsets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line no-restricted-imports
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import useSafeAreaInsets from './useSafeAreaInsets';
import useStyleUtils from './useStyleUtils';

/**
Expand All @@ -21,15 +20,15 @@ import useStyleUtils from './useStyleUtils';
* // Use these values to style your component accordingly
* }
*/
function useStyledSafeAreaInsets() {
function useStyledSafeAreaInsets(safeAreaInsetsPercentage?: number) {
const StyleUtils = useStyleUtils();
const insets = useSafeAreaInsets();

const {paddingTop, paddingBottom} = StyleUtils.getSafeAreaPadding(insets ?? undefined);
const {paddingTop, paddingBottom} = StyleUtils.getSafeAreaPadding(insets, safeAreaInsetsPercentage);
return {
paddingTop,
paddingBottom,
insets: insets ?? undefined,
insets,
safeAreaPaddingBottomStyle: {paddingBottom},
};
}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/NewChatConfirmPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ function NewChatConfirmPage({newGroupDraft, allPersonalDetails}: NewChatConfirmP
}, []);

return (
<ScreenWrapper testID={NewChatConfirmPage.displayName}>
<ScreenWrapper
testID={NewChatConfirmPage.displayName}
includeSafeAreaPaddingBottom={false}
>
<HeaderWithBackButton
title={translate('common.group')}
onBackButtonPress={navigateBack}
Expand Down
22 changes: 18 additions & 4 deletions src/pages/NewChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function NewChatPage() {
const {isSmallScreenWidth} = useResponsiveLayout();
const styles = useThemeStyles();
const personalData = useCurrentUserPersonalDetails();
const {insets} = useStyledSafeAreaInsets();
const {insets, safeAreaPaddingBottomStyle} = useStyledSafeAreaInsets();
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});
const selectionListRef = useRef<SelectionListHandle>(null);

Expand Down Expand Up @@ -252,14 +252,27 @@ function NewChatPage() {
return (
<Button
onPress={() => toggleOption(item)}
style={[styles.pl2]}
style={[styles.pl2, insets.bottom ? styles.mb5 : undefined]}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change has introduced a regression in #53261 , there is no need to add the extra margin.

text={translate('newChatPage.addToGroup')}
innerStyles={buttonInnerStyles}
small
/>
);
},
[selectedOptions, setSelectedOptions, styles, translate],
[
insets.bottom,
selectedOptions,
setSelectedOptions,
styles.alignItemsCenter,
styles.buttonDefaultHovered,
styles.flexRow,
styles.mb5,
styles.ml0,
styles.ml5,
styles.optionSelectCircle,
styles.pl2,
translate,
],
);

const createGroup = useCallback(() => {
Expand Down Expand Up @@ -297,7 +310,7 @@ function NewChatPage() {
return (
<ScreenWrapper
shouldEnableKeyboardAvoidingView={false}
includeSafeAreaPaddingBottom={isOffline}
includeSafeAreaPaddingBottom={false}
shouldShowOfflineIndicator={false}
includePaddingTop={false}
shouldEnablePickerAvoiding={false}
Expand Down Expand Up @@ -331,6 +344,7 @@ function NewChatPage() {
isLoadingNewOptions={!!isSearchingForReports}
initiallyFocusedOptionKey={firstKeyForList}
shouldTextInputInterceptSwipe
confirmButtonStyles={insets.bottom ? [safeAreaPaddingBottomStyle, styles.mb5] : undefined}
/>
{isSmallScreenWidth && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalD
import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useAutoFocusInput from '@hooks/useAutoFocusInput';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -41,7 +40,6 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat
const {onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const {inputCallbackRef} = useAutoFocusInput();
const [shouldValidateOnChange, setShouldValidateOnChange] = useState(false);
const {isOffline} = useNetwork();
const {canUseDefaultRooms} = usePermissions();
const {activeWorkspaceID} = useActiveWorkspace();

Expand Down Expand Up @@ -114,7 +112,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat
<ScreenWrapper
shouldEnableMaxHeight
shouldShowOfflineIndicator={false}
includeSafeAreaPaddingBottom={isOffline}
includeSafeAreaPaddingBottom={false}
testID="BaseOnboardingPersonalDetails"
style={[styles.defaultModalContainer, shouldUseNativeStyles && styles.pt8]}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ function IOURequestStepConfirmation({
shouldEnableMaxHeight={DeviceCapabilities.canUseTouchScreen()}
testID={IOURequestStepConfirmation.displayName}
>
<View style={[styles.flex1, styles.mb6]}>
<View style={styles.flex1}>
<HeaderWithBackButton
title={headerTitle}
onBackButtonPress={navigateBack}
Expand Down
1 change: 1 addition & 0 deletions src/pages/iou/request/step/IOURequestStepDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function IOURequestStepDescription({
shouldShowWrapper
testID={IOURequestStepDescription.displayName}
shouldShowNotFoundPage={shouldShowNotFoundPage}
includeSafeAreaPaddingBottom={false}
>
<FormProvider
style={[styles.flexGrow1, styles.ph5]}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ function IOURequestStepDistance({
allowBubble
pressOnEnter
large
style={[styles.w100, styles.mb4, styles.ph4, styles.flexShrink0]}
style={[styles.w100, styles.mb5, styles.ph4, styles.flexShrink0]}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While handling missing styles, we missed noticing the size mismatch for Next button with the Manual tab. We fixed this in #60386

onPress={submitWaypoints}
text={buttonText}
isLoading={!isOffline && (isLoadingRoute || shouldFetchRoute || isLoading)}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepMerchant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function IOURequestStepMerchant({
onBackButtonPress={navigateBack}
shouldShowWrapper
testID={IOURequestStepMerchant.displayName}
includeSafeAreaPaddingBottom
includeSafeAreaPaddingBottom={false}
>
<FormProvider
style={[styles.flexGrow1, styles.ph5]}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceNewRoomPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function WorkspaceNewRoomPage() {
return (
<ScreenWrapper
shouldEnableKeyboardAvoidingView={false}
includeSafeAreaPaddingBottom={isOffline}
includeSafeAreaPaddingBottom={false}
shouldShowOfflineIndicator={false}
includePaddingTop={false}
shouldEnablePickerAvoiding={false}
Expand Down
3 changes: 3 additions & 0 deletions src/styles/utils/getSafeAreaInsets/defaultInsets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const defaultInsets = {top: 0, bottom: 0, left: 0, right: 0};

export default defaultInsets;
18 changes: 18 additions & 0 deletions src/styles/utils/getSafeAreaInsets/index.android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type {EdgeInsets} from 'react-native-safe-area-context';
import StatusBar from '@libs/StatusBar';
import defaultInsets from './defaultInsets';

/**
* On Android we want to use the StatusBar height rather than the top safe area inset.
* @returns
*/
function getSafeAreaInsets(safeAreaInsets: EdgeInsets | null): EdgeInsets {
const insets = safeAreaInsets ?? defaultInsets;

return {
...insets,
top: StatusBar.currentHeight ?? insets.top,
};
}

export default getSafeAreaInsets;
13 changes: 13 additions & 0 deletions src/styles/utils/getSafeAreaInsets/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type {EdgeInsets} from 'react-native-safe-area-context';
import defaultInsets from './defaultInsets';

/**
* Noop on web and iOS. This utility function is only needed on Android.
* @returns
*/
function getSafeAreaInsets(safeAreaInsets: EdgeInsets | null): EdgeInsets {
const insets = safeAreaInsets ?? defaultInsets;
return insets;
}

export default getSafeAreaInsets;
21 changes: 19 additions & 2 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import createTooltipStyleUtils from './generators/TooltipStyleUtils';
import getContextMenuItemStyles from './getContextMenuItemStyles';
import getHighResolutionInfoWrapperStyle from './getHighResolutionInfoWrapperStyle';
import getNavigationModalCardStyle from './getNavigationModalCardStyles';
import getSafeAreaInsets from './getSafeAreaInsets';
import getSignInBgStyles from './getSignInBgStyles';
import {compactContentContainerStyles} from './optionRowStyles';
import positioning from './positioning';
Expand Down Expand Up @@ -327,7 +328,22 @@ type SafeAreaPadding = {
/**
* Takes safe area insets and returns padding to use for a View
*/
function getSafeAreaPadding(insets?: EdgeInsets, insetsPercentage: number = getPlatform() === CONST.PLATFORM.IOS ? variables.safeInsertPercentage : 1): SafeAreaPadding {
function getSafeAreaPadding(insets?: EdgeInsets, insetsPercentageProp?: number): SafeAreaPadding {
const platform = getPlatform();
let insetsPercentage = insetsPercentageProp;
if (insetsPercentage == null) {
switch (platform) {
case CONST.PLATFORM.IOS:
insetsPercentage = variables.iosSafeAreaInsetsPercentage;
break;
case CONST.PLATFORM.ANDROID:
insetsPercentage = variables.androidSafeAreaInsetsPercentage;
break;
default:
insetsPercentage = 1;
}
}

return {
paddingTop: insets?.top ?? 0,
paddingBottom: (insets?.bottom ?? 0) * insetsPercentage,
Expand All @@ -340,7 +356,7 @@ function getSafeAreaPadding(insets?: EdgeInsets, insetsPercentage: number = getP
* Takes safe area insets and returns margin to use for a View
*/
function getSafeAreaMargins(insets?: EdgeInsets): ViewStyle {
return {marginBottom: (insets?.bottom ?? 0) * variables.safeInsertPercentage};
return {marginBottom: (insets?.bottom ?? 0) * variables.iosSafeAreaInsetsPercentage};
}

function getZoomSizingStyle(
Expand Down Expand Up @@ -1190,6 +1206,7 @@ const staticStyleUtils = {
getModalPaddingStyles,
getOuterModalStyle,
getPaymentMethodMenuWidth,
getSafeAreaInsets,
getSafeAreaMargins,
getSafeAreaPadding,
getSignInWordmarkWidthStyle,
Expand Down
3 changes: 2 additions & 1 deletion src/styles/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export default {
extraSmallMobileResponsiveHeightBreakpoint: 667,
mobileResponsiveWidthBreakpoint: 800,
tabletResponsiveWidthBreakpoint: 1024,
safeInsertPercentage: 0.7,
iosSafeAreaInsetsPercentage: 0.7,
androidSafeAreaInsetsPercentage: 1,
sideBarWidth: 375,
pdfPageMaxWidth: 992,
tooltipzIndex: 10050,
Expand Down