Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix incorrect device orientation detection

ammarahm-ed9af77e1161cd
diff --git a/apps/mobile/app/navigation/tabs-holder.js b/apps/mobile/app/navigation/tabs-holder.js
index b6a7c0c3a..a8e2da5b6 100644
--- a/apps/mobile/app/navigation/tabs-holder.js
+++ b/apps/mobile/app/navigation/tabs-holder.js
@@ -82,6 +82,7 @@ const _TabsHolder = () => {
const animatedTranslateY = useSharedValue(-9999);
const overlayRef = useRef();
const [orientation, setOrientation] = useState(getInitialOrientation());
+
const introCompleted = useSettingStore(
(state) => state.settings.introCompleted
);
@@ -192,7 +193,7 @@ const _TabsHolder = () => {
}
let size = event?.nativeEvent?.layout;
if (!size || (size.width === dimensions.width && deviceMode !== null)) {
- DDS.setSize(size);
+ DDS.setSize(size, orientation);
setDeviceMode(deviceMode, size);
checkDeviceType(size);
return;
@@ -209,8 +210,7 @@ const _TabsHolder = () => {
height: size.height
});
setWidthHeight(size);
- DDS.setSize(size);
-
+ DDS.setSize(size, orientation);
if (DDS.isLargeTablet()) {
setDeviceMode("tablet", size);
setTimeout(() => {
diff --git a/apps/mobile/app/services/device-detection.js b/apps/mobile/app/services/device-detection.js
index 1ee6a2ce2..28ccf1e62 100644
--- a/apps/mobile/app/services/device-detection.js
+++ b/apps/mobile/app/services/device-detection.js
@@ -40,7 +40,7 @@ export class DeviceDetectionService {
this.checkSmallTab();
}
- setSize(size) {
+ setSize(size, orientation) {
windowSize = size;
this.width = windowSize.width;
this.height = windowSize.height;
@@ -49,7 +49,7 @@ export class DeviceDetectionService {
this.isPhoneOrTablet();
this.isIosOrAndroid();
this.detectIphoneX();
- this.checkSmallTab(size.width > size.height ? "LANDSCAPE" : "PORTRAIT");
+ this.checkSmallTab(orientation);
}
getDeviceSize = () => {
@@ -66,7 +66,6 @@ export class DeviceDetectionService {
this.width = Dimensions.get("screen").width;
this.height = Dimensions.get("screen").height;
let deviceSize = this.getDeviceSize();
-
if (
(!DeviceInfo.isTablet() && orientation === "LANDSCAPE") ||
(DeviceInfo.isTablet() && (orientation === "PORTRAIT" || deviceSize < 9))