Skip to content

Commit 09e62f3

Browse files
committed
refactor: updated the determineIsTablet
1 parent 2a7b5d9 commit 09e62f3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/helpers/device/DeviceInfo.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,17 @@ const vmax = Math.max(vh, vw) || vw;
5050
* Uses a singleton approach to avoid re-evaluating each time.
5151
*/
5252
const determineIsTablet = (): boolean => {
53-
const { width, height } = Dimensions.get("window");
54-
const aspectRatio = height / width;
53+
const { width, height } = Dimensions.get("screen");
54+
const minDimension = Math.min(width, height);
55+
const maxDimension = Math.max(width, height);
5556

57+
const aspectRatio = maxDimension / minDimension;
5658
const minTabletWidth = 600; // dp
5759
const maxPhoneAspectRatio = 1.6; // Typical phone aspect ratio
5860

5961
return (
6062
(isAndroid || isIOS) &&
61-
(width >= minTabletWidth || aspectRatio <= maxPhoneAspectRatio)
63+
(minDimension >= minTabletWidth || aspectRatio <= maxPhoneAspectRatio)
6264
);
6365
};
6466

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@freakycoder/react-native-helpers",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
44
"description": "All helpers in one; iPhone series support, dimensions helper, hasNotch helper, normalize text helper and text helpers for React Native with very easy use",
55
"keywords": [
66
"ios",

0 commit comments

Comments
 (0)