Files
jrshikoku/components/ActionSheetComponents/useSheetMaxHeight.ts
2026-03-30 02:12:07 +00:00

12 lines
410 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useWindowDimensions } from "react-native";
/**
* スマホ(短辺 < 600dpのみ maxHeight を返す。タブレットでは undefined。
*/
export function useSheetMaxHeight(ratio = 0.7): number | undefined {
const { width, height } = useWindowDimensions();
const shortSide = Math.min(width, height);
if (shortSide >= 600) return undefined; // タブレット
return height * ratio;
}