isTablet in const "isFull" is not getting real value in the physical samsung tab6
See original GitHub issueWe were experiencing a bug in our app that we couldn’t simulate in the android studio emulator. After a lot of time trying to understand the reasons that we couldn’t simulate what tue QA analyst was showing on the physical device, we found that the
useDetectDevice returns a wrong isTablet value for the input, therefore the alignment was completely different in the physical device. We searched a bit deeper and found out that some android widths and heights from Dimensions are not accurate.
To solve the issue we applied a local patch
` import { Platform, Dimensions } from ‘react-native’; import type { IUseDetectDevice } from ‘./model’;
const msp = (dim, limit) => { return (dim.scale * dim.width) >= limit || (dim.scale * dim.height) >= limit; };
const isTablet = () => { const dim = Dimensions.get(‘screen’); return ((dim.scale < 2 && msp(dim, 1000)) || (dim.scale >= 2 && msp(dim, 1900))); };
const useDetectDevice: IUseDetectDevice = { isAndroid: Platform.OS === ‘android’, isIOS: Platform.OS === ‘ios’, isTablet: isTablet(), };
export { useDetectDevice }; `
by changing to it, the problem was solved. Another way that we could solve the problem is to be able to send a property down to the Dropdown and instead of checking
const isFull = orientation === 'LANDSCAPE' && !isTablet;
We could do const isFull = orientation === 'LANDSCAPE' && ( !customProp || !isTablet);
Is there a way this could be fixed? We don’t want to use a local fix.
pictures of the problem happening:
after changing isTablet function the result
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (4 by maintainers)
Hello there, sorry for the delay. It didn’t work 😦
It’s still considering it not to be a tablet I guess.
Is there a chance the code below could be implemented? Our patch worked with it. In many emulators as well as in the physical device.
const isTablet = () => { const dim = Dimensions.get(‘screen’); return ((dim.scale < 2 && msp(dim, 1000)) || (dim.scale >= 2 && msp(dim, 1900))); };
hi @jeandiego @thaynarbo , I have updated function “isTablet” in release 2.4.0. Not sure is it working. Can you help me re-check issue?