forked from BlueWallet/BlueWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request BlueWallet#6413 from BlueWallet/listtsx
REF: WalletsList TSX
- Loading branch information
Showing
5 changed files
with
193 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useState, useEffect, useMemo } from 'react'; | ||
import { Dimensions } from 'react-native'; | ||
import { isTablet } from 'react-native-device-info'; | ||
|
||
// Custom hook to determine if the screen is large | ||
export const useIsLargeScreen = () => { | ||
const [windowWidth, setWindowWidth] = useState(Dimensions.get('window').width); | ||
const screenWidth = useMemo(() => Dimensions.get('screen').width, []); | ||
|
||
useEffect(() => { | ||
const updateScreenUsage = () => { | ||
const newWindowWidth = Dimensions.get('window').width; | ||
if (newWindowWidth !== windowWidth) { | ||
console.log(`Window width changed: ${newWindowWidth}`); | ||
setWindowWidth(newWindowWidth); | ||
} | ||
}; | ||
|
||
// Add event listener for dimension changes | ||
const subscription = Dimensions.addEventListener('change', updateScreenUsage); | ||
|
||
// Cleanup function to remove the event listener | ||
return () => { | ||
subscription.remove(); | ||
}; | ||
}, [windowWidth]); | ||
|
||
// 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 for now | ||
const isRunningOnTablet = isTablet(); | ||
const halfScreenWidth = windowWidth >= screenWidth / 2; | ||
const condition = isRunningOnTablet && halfScreenWidth; | ||
console.log( | ||
`Window width: ${windowWidth}, Screen width: ${screenWidth}, Is tablet or desktop: ${isRunningOnTablet}, Is large screen: ${condition}`, | ||
); | ||
return condition; | ||
}, [windowWidth, screenWidth]); | ||
|
||
return isLargeScreen; | ||
}; |
Oops, something went wrong.