mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 23:27:26 +01:00
Merge pull request #6453 from BlueWallet/layoutfix
Update useIsLargeScreen.ts
This commit is contained in:
commit
0bf4c3fc23
1 changed files with 4 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { useState, useEffect, useMemo } from 'react';
|
import { useState, useEffect, useMemo } from 'react';
|
||||||
import { Dimensions } from 'react-native';
|
import { Dimensions } from 'react-native';
|
||||||
import { isTablet } from 'react-native-device-info';
|
import { isTablet } from 'react-native-device-info';
|
||||||
|
import { isDesktop } from '../blue_modules/environment';
|
||||||
|
|
||||||
// Custom hook to determine if the screen is large
|
// Custom hook to determine if the screen is large
|
||||||
export const useIsLargeScreen = () => {
|
export const useIsLargeScreen = () => {
|
||||||
|
@ -27,12 +28,11 @@ export const useIsLargeScreen = () => {
|
||||||
|
|
||||||
// Determine if the window width is at least half of the screen width
|
// Determine if the window width is at least half of the screen width
|
||||||
const isLargeScreen = useMemo(() => {
|
const isLargeScreen = useMemo(() => {
|
||||||
// we dont want to return true on phones. only on tablets for now
|
const isRunningOnTabletOrDesktop = isTablet() || isDesktop;
|
||||||
const isRunningOnTablet = isTablet();
|
|
||||||
const halfScreenWidth = windowWidth >= screenWidth / 2;
|
const halfScreenWidth = windowWidth >= screenWidth / 2;
|
||||||
const condition = isRunningOnTablet && halfScreenWidth;
|
const condition = isRunningOnTabletOrDesktop && halfScreenWidth;
|
||||||
console.log(
|
console.log(
|
||||||
`Window width: ${windowWidth}, Screen width: ${screenWidth}, Is tablet or desktop: ${isRunningOnTablet}, Is large screen: ${condition}`,
|
`Window width: ${windowWidth}, Screen width: ${screenWidth}, Is tablet: ${isRunningOnTabletOrDesktop}, Is large screen: ${condition}`,
|
||||||
);
|
);
|
||||||
return condition;
|
return condition;
|
||||||
}, [windowWidth, screenWidth]);
|
}, [windowWidth, screenWidth]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue