Update useIsLargeScreen.ts

This commit is contained in:
Marcos Rodriguez Velez 2024-04-18 18:50:40 -04:00
parent b9ee72f58c
commit 0222884dfe
No known key found for this signature in database
GPG key ID: 6030B2F48CCE86D7

View file

@ -1,7 +1,6 @@
import { useState, useEffect, useMemo } from 'react';
import { Dimensions } from 'react-native';
import { isTablet } from 'react-native-device-info';
import { isDesktop } from '../blue_modules/environment';
// Custom hook to determine if the screen is large
export const useIsLargeScreen = () => {
@ -28,12 +27,12 @@ export const useIsLargeScreen = () => {
// Determine if the window width is at least half of the screen width
const isLargeScreen = useMemo(() => {
// we dont want to return true on phones. only on tablets and desktops
const isTabletOrDesktop = isTablet() || isDesktop;
// we dont want to return true on phones. only on tablets for now
const isRunningOnTablet = isTablet();
const halfScreenWidth = windowWidth >= screenWidth / 2;
const condition = isTabletOrDesktop && halfScreenWidth;
const condition = isRunningOnTablet && halfScreenWidth;
console.log(
`Window width: ${windowWidth}, Screen width: ${screenWidth}, Is tablet or desktop: ${isTabletOrDesktop}, Is large screen: ${condition}`,
`Window width: ${windowWidth}, Screen width: ${screenWidth}, Is tablet or desktop: ${isRunningOnTablet}, Is large screen: ${condition}`,
);
return condition;
}, [windowWidth, screenWidth]);