Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

useMaterialToolbarHeight.ts

11 lines518 Bytes

1import { useWindowDimensions } from "react-native";
2​
3import { useScaledTextRole } from "../features/settings/appearance/useScaledTextRole";
4​
5/** Reserve the same title/subtitle space in every pane, including icon-only and search headers. */
6export function useMaterialToolbarHeight() {
7 const title = useScaledTextRole("title");
8 const subtitle = useScaledTextRole("label");
9 const { fontScale } = useWindowDimensions();
10 return Math.ceil(Math.max(56, (title.lineHeight + subtitle.lineHeight) * fontScale + 1));