Skip to content

Commit

Permalink
fix: Status banner contains extra space on header (#6510)
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisTofani authored Dec 5, 2024
1 parent 14d6543 commit bd558bd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
16 changes: 14 additions & 2 deletions ts/components/ui/IOScrollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import Animated, {
} from "react-native-reanimated";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { WithTestID } from "../../types/WithTestID";
import { useStatusAlertProps } from "../../hooks/useStatusAlertProps";

export type IOScrollViewActions =
| {
Expand Down Expand Up @@ -160,6 +161,7 @@ export const IOScrollView = ({
contentContainerStyle,
testID
}: IOScrollView) => {
const alertProps = useStatusAlertProps();
const theme = useIOTheme();

/* Navigation */
Expand Down Expand Up @@ -255,12 +257,22 @@ export const IOScrollView = ({
if (headerConfig) {
navigation.setOptions({
header: () => (
<HeaderSecondLevel {...headerConfig} scrollValues={scrollValues} />
<HeaderSecondLevel
{...headerConfig}
ignoreSafeAreaMargin={!!alertProps}
scrollValues={scrollValues}
/>
),
headerTransparent: headerConfig.transparent
});
}
}, [headerConfig, navigation, scrollPositionAbsolute, snapOffset]);
}, [
headerConfig,
navigation,
scrollPositionAbsolute,
snapOffset,
alertProps
]);

const RefreshControlComponent = refreshControlProps ? (
<RefreshControl {...refreshControlProps} />
Expand Down
2 changes: 0 additions & 2 deletions ts/components/ui/IOScrollViewWithLargeHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export const IOScrollViewWithLargeHeader = forwardRef<View, Props>(
contextualHelp,
contextualHelpMarkdown,
faqCategories,
ignoreSafeAreaMargin = false,
includeContentMargins = false,
headerActionsProp = {},
excludeEndContentMargin,
Expand All @@ -91,7 +90,6 @@ export const IOScrollViewWithLargeHeader = forwardRef<View, Props>(
};

const headerProps: ComponentProps<typeof HeaderSecondLevel> = {
ignoreSafeAreaMargin,
...useHeaderProps(
canGoback
? {
Expand Down
2 changes: 1 addition & 1 deletion ts/hooks/useHeaderSecondLevel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export const useHeaderSecondLevel = ({
const enableDiscreteTransitionProps =
enableDiscreteTransition && animatedRef
? {
ignoreSafeAreaMargin: !!alertProps,
enableDiscreteTransition,
animatedRef
}
Expand All @@ -142,6 +141,7 @@ export const useHeaderSecondLevel = ({
scrollValues,
variant,
backgroundColor,
ignoreSafeAreaMargin: !!alertProps,
...enableDiscreteTransitionProps
};
}, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jest.mock("../../../../store/hooks", () => ({
useIOStore: jest.fn()
}));

jest.mock("../../../../hooks/useStatusAlertProps", () => ({
useStatusAlertProps: jest.fn()
}));

const mockNavigate = jest.fn();
const mockReplace = jest.fn();
jest.mock("@react-navigation/native", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jest.mock("../../../store/hooks", () => ({
useIOStore: jest.fn()
}));

// Mock the useStatusAlertProps hook
jest.mock("../../../hooks/useStatusAlertProps", () => ({
useStatusAlertProps: jest.fn()
}));

describe("LanguagesPreferencesScreen", () => {
beforeAll(() => {
jest.spyOn(Alert, "alert");
Expand Down

0 comments on commit bd558bd

Please sign in to comment.