Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const Provider: React.FC = ({ children }) => {
const { height: windowHeight, width: windowWidth } = useDimensions().window
const [stylesState, setStylesState] = useState(defaultStyles)
const [scaleHeight, setScaleHeight] = useState(initialScaleHeight)
const [scaleSize, setScaleSize] = useState(initialScaleSize)
const [fontScale, setFontScale] = useState(initialFontScale)
const isGteIpadSize =
Math.min(initialHeight, initialWidth) >= iPadShortEdge &&
Math.max(initialHeight, initialWidth) >= iPadLongEdge
React.useEffect(() => {
const isLandscape = windowHeight < windowWidth
const _scaleHeight =
windowHeight / Math.max(isLandscape ? iPhone11ShortEdge : iPhone11LongEdge, windowHeight)
const _scaleSize =
windowWidth / Math.max(isLandscape ? iPhone11LongEdge : iPhone11ShortEdge, windowWidth)
const _fontScale = PixelRatio.getFontScale() * _scaleSize
setScaleHeight(_scaleHeight)
setScaleSize(_scaleSize)