Open History to see the last commit
1import { useWindowDimensions } from "react-native";
2import { useSafeAreaInsets } from "react-native-safe-area-context";
3
4import { useScaledTextRole } from "../../features/settings/appearance/useScaledTextRole";
5import { useAndroidControlSizing } from "./useAndroidControlSizing";
6
7/**
8 * Shared Android header geometry; class-based spacing uses the app's 14dp rem.
9 * `singleLine` sizes the toolbar for a title row with the subtitle inline.
10 */
11export function useToolbarLayout(embedded = false, singleLine = false) {
12 const insets = useSafeAreaInsets();
13 const title = useScaledTextRole("title");
14 const subtitle = useScaledTextRole("label");
15 const { scale } = useAndroidControlSizing();
16 const { fontScale } = useWindowDimensions();
17 return {
18 height: Math.ceil(
19 singleLine
20 ? Math.max(48, 48 * scale, title.lineHeight * fontScale + 1)
21 : Math.max(48, 56 * scale, (title.lineHeight + subtitle.lineHeight) * fontScale + 1),
22 ),
23 paddingTop: embedded ? 8 * scale : Math.max(insets.top, 12 * scale),
24 paddingBottom: 7 * scale,
25 };
26}