A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
detect small or large tablets
ammarahm-ed73d9432d1083
diff --git a/apps/mobile/src/utils/deviceDetection.js b/apps/mobile/src/utils/deviceDetection.jsindex e2dd83c91..573bdbf1c 100644--- a/apps/mobile/src/utils/deviceDetection.js+++ b/apps/mobile/src/utils/deviceDetection.js@@ -1,7 +1,6 @@import {Dimensions, PixelRatio, Platform} from 'react-native';-import DeviceInfo from 'react-native-device-info';-const windowSize = Dimensions.get('window');+let windowSize = Dimensions.get('window');export class DeviceDetectionService {constructor() {@@ -14,23 +13,65 @@ export class DeviceDetectionService {this.isPhoneOrTablet();this.isIosOrAndroid();this.detectIphoneX();- //this.checkOrientation();+ this.checkSmallTab();}- checkOrientation() {- this.width = Dimensions.get('window').width;- this.height = Dimensions.get('window').height;- if (this.width < this.height) {- this.isTab = false;- this.isPhone = true;- } else {+ setNewValues() {+ windowSize = Dimensions.get('window');+ this.pixelDensity = PixelRatio.get();+ this.width = windowSize.width;+ this.height = windowSize.height;+ this.adjustedWidth = this.width * this.pixelDensity;+ this.adjustedHeight = this.height * this.pixelDensity;+ this.isPhoneOrTablet();+ this.isIosOrAndroid();+ this.detectIphoneX();+ this.checkSmallTab();+ }++ getDeviceSize = () => {+ let dpi = this.pixelDensity * 160;+ let deviceWidthInInches = this.adjustedWidth / dpi;+ let deviceHeightInInches = this.adjustedHeight / dpi;+ let diagonalSize = Math.sqrt(+ Math.pow(deviceWidthInInches, 2) + Math.pow(deviceHeightInInches, 2),+ );+ return diagonalSize;+ };++ checkSmallTab(orientation) {+ this.width = Dimensions.get('screen').width;+ this.height = Dimensions.get('screen').height;+ let deviceSize = this.getDeviceSize();+ console.log(+ 'device size',+ deviceSize,+ this.width,+ this.height,+ deviceSize < 9,+ DeviceInfo.isTablet(),+ );+ if (DeviceInfo.isTablet() && (orientation === "PORTRAIT" || deviceSize < 9)) {+ console.log('small tab');this.isTab = true;this.isPhone = false;+ this.isSmallTab = true;+ } else {+ if (!DeviceInfo.isTablet() ) {+ this.isTab = false;+ this.isPhone = true;+ this.isSmallTab = false;+ } else {+ this.isTab = true;+ this.isSmallTab = false;+ this.isPhone = true;+ }+}}isPhoneOrTablet() {- /* if (Platform.isPad) {+ /* if (Platform.isPad) {this.isTab = true;this.isPhone = false;}