| 1 | import { useWindowDimensions } from "react-native"; |
| 2 | import { useSafeAreaInsets } from "react-native-safe-area-context"; |
| 3 | |
| 4 | import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole"; |
| 5 | import { useAndroidControlSizing } from "./useAndroidControlSizing"; |
| 6 | |
| 7 | /** Shared Android header geometry; class-based spacing uses the app's 14dp rem. */ |
| 8 | export function useMaterialToolbarLayout(embedded = false) { |
| 9 | const insets = useSafeAreaInsets(); |
| 10 | const title = useScaledTextRole("title"); |
| 11 | const subtitle = useScaledTextRole("label"); |
| 12 | const { scale } = useAndroidControlSizing(); |
| 13 | const { fontScale } = useWindowDimensions(); |
| 14 | return { |
| 15 | height: Math.ceil( |
| 16 | Math.max(48, 56 * scale, (title.lineHeight + subtitle.lineHeight) * fontScale + 1), |
| 17 | ), |
| 18 | paddingTop: embedded ? 8 * scale : Math.max(insets.top, 12 * scale), |
| 19 | paddingBottom: 7 * scale, |
| 20 | }; |
| 21 | } |