Skip to content

Commit 65c1869

Browse files
authored
fix(mobile): avoid android modal header overlap (#4907)
1 parent 7cc1cd5 commit 65c1869

File tree

5 files changed

+68
-17
lines changed

5 files changed

+68
-17
lines changed

apps/mobile/app.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export default ({ config }: ConfigContext): ExpoConfig => {
136136
],
137137

138138
require("./plugins/with-gradle-jvm-heap-size-increase.js"),
139+
require("./plugins/with-android-jdk-21.js"),
139140
require("./plugins/with-android-manifest-plugin.js"),
140141
"expo-secure-store",
141142
"@react-native-firebase/app",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { withGradleProperties } = require("@expo/config-plugins")
2+
3+
function setGradleProperty(config, key, value) {
4+
return withGradleProperties(config, (config) => {
5+
const keyIndex = config.modResults.findIndex(
6+
(item) => item.type === "property" && item.key === key,
7+
)
8+
9+
const nextItem = {
10+
type: "property",
11+
key,
12+
value,
13+
}
14+
15+
if (keyIndex === -1) {
16+
config.modResults.push(nextItem)
17+
} else {
18+
config.modResults.splice(keyIndex, 1, nextItem)
19+
}
20+
21+
return config
22+
})
23+
}
24+
25+
module.exports = function withAndroidJdk21(config) {
26+
let nextConfig = setGradleProperty(config, "react.internal.disableJavaVersionAlignment", "true")
27+
nextConfig = setGradleProperty(nextConfig, "kotlin.jvm.target.validation.mode", "warning")
28+
return nextConfig
29+
}

apps/mobile/src/components/layouts/header/NavigationHeader.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ import {
3333
useCanDismiss,
3434
useIsTopRouteInGroup,
3535
useNavigation,
36-
useScreenIsInModal,
3736
useScreenIsInSheetModal,
3837
} from "@/src/lib/navigation/hooks"
3938
import { ScreenItemContext } from "@/src/lib/navigation/ScreenItemContext"
4039

4140
import { ThemedBlurView } from "../../common/ThemedBlurView"
4241
import { PlatformActivityIndicator } from "../../ui/loading/PlatformActivityIndicator"
43-
import { getDefaultHeaderHeight } from "../utils"
42+
import { getNavigationHeaderLayout } from "../utils"
4443
import { SetNavigationHeaderHeightContext } from "../views/NavigationHeaderContext"
4544
import { FakeNativeHeaderTitle } from "./FakeNativeHeaderTitle"
4645

@@ -185,12 +184,12 @@ export const InternalNavigationHeader = ({
185184
const frame = useSafeAreaFrame()
186185

187186
const sheetModal = useScreenIsInSheetModal()
188-
const defaultHeight = useMemo(
187+
const { headerHeight: defaultHeight, headerTopInset } = useMemo(
189188
() =>
190-
getDefaultHeaderHeight({
189+
getNavigationHeaderLayout({
191190
landscape: frame.width > frame.height,
192-
modalPresentation: sheetModal,
193-
topInset: sheetModal ? 0 : insets.top,
191+
sheetModal,
192+
topInset: insets.top,
194193
}),
195194
[frame, insets.top, sheetModal],
196195
)
@@ -229,11 +228,9 @@ export const InternalNavigationHeader = ({
229228
hideableBottomHeight,
230229
)
231230

232-
const isModal = useScreenIsInModal()
233-
234231
const rootTitleBarStyle = useAnimatedStyle(() => {
235232
const styles = {
236-
paddingTop: isModal ? 0 : insets.top,
233+
paddingTop: headerTopInset,
237234
position: "relative",
238235
overflow: "hidden",
239236
} satisfies DefaultStyle
@@ -302,7 +299,7 @@ export const InternalNavigationHeader = ({
302299
style={{
303300
marginLeft: insets.left,
304301
marginRight: insets.right,
305-
height: !sheetModal ? defaultHeight - insets.top : defaultHeight,
302+
height: defaultHeight - headerTopInset,
306303
paddingHorizontal: titlebarPaddingHorizontal,
307304
}}
308305
pointerEvents={"box-none"}

apps/mobile/src/components/layouts/utils/index.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,26 @@ export function getDefaultHeaderHeight({
4141

4242
return headerHeight + (modalPresentation ? 0 : topInset)
4343
}
44+
45+
export function getNavigationHeaderLayout({
46+
landscape,
47+
sheetModal,
48+
topInset,
49+
}: {
50+
landscape: boolean
51+
sheetModal: boolean
52+
topInset: number
53+
}) {
54+
const effectiveModalPresentation = isIOS && sheetModal
55+
const headerTopInset = effectiveModalPresentation ? 0 : topInset
56+
57+
return {
58+
headerTopInset,
59+
effectiveModalPresentation,
60+
headerHeight: getDefaultHeaderHeight({
61+
landscape,
62+
modalPresentation: effectiveModalPresentation,
63+
topInset: headerTopInset,
64+
}),
65+
}
66+
}

apps/mobile/src/components/layouts/views/SafeNavigationScrollView.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ReAnimatedScrollView } from "../../common/AnimatedComponents"
2020
import type { InternalNavigationHeaderProps } from "../header/NavigationHeader"
2121
import { InternalNavigationHeader } from "../header/NavigationHeader"
2222
import { BottomTabBarBackgroundContext } from "../tabbar/contexts/BottomTabBarBackgroundContext"
23-
import { getDefaultHeaderHeight } from "../utils"
23+
import { getNavigationHeaderLayout } from "../utils"
2424
import {
2525
NavigationHeaderHeightContext,
2626
SetNavigationHeaderHeightContext,
@@ -64,12 +64,13 @@ export const SafeNavigationScrollView = ({
6464

6565
const frame = useSafeAreaFrame()
6666
const sheetModal = useScreenIsInSheetModal()
67-
const [headerHeight, setHeaderHeight] = useState(() =>
68-
getDefaultHeaderHeight({
69-
landscape: frame.width > frame.height,
70-
modalPresentation: sheetModal,
71-
topInset: insets.top,
72-
}),
67+
const [headerHeight, setHeaderHeight] = useState(
68+
() =>
69+
getNavigationHeaderLayout({
70+
landscape: frame.width > frame.height,
71+
sheetModal,
72+
topInset: insets.top,
73+
}).headerHeight,
7374
)
7475
const screenCtxValue = use(ScreenItemContext)
7576

0 commit comments

Comments
 (0)