FIX: is tablet detection

This commit is contained in:
overtorment 2024-05-05 18:57:41 +01:00
parent e9e73f54ac
commit ead613aed4
4 changed files with 2 additions and 37 deletions

View file

@ -1,41 +1,6 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import { Platform } from 'react-native';
import { isTablet, getDeviceType } from 'react-native-device-info';
const isDesktop: boolean = getDeviceType() === 'Desktop';
const getIsTorCapable = (): boolean => {
let capable = true;
if (Platform.OS === 'android' && Platform.Version < 26) {
capable = false;
} else if (isDesktop) {
capable = false;
}
return capable;
};
const IS_TOR_DAEMON_DISABLED: string = 'is_tor_daemon_disabled';
export async function setIsTorDaemonDisabled(disabled: boolean = true): Promise<void> {
return AsyncStorage.setItem(IS_TOR_DAEMON_DISABLED, disabled ? '1' : '');
}
export async function isTorDaemonDisabled(): Promise<boolean> {
let result: boolean;
try {
const savedValue = await AsyncStorage.getItem(IS_TOR_DAEMON_DISABLED);
if (savedValue === null) {
result = false;
} else {
result = savedValue === '1';
}
} catch {
result = true;
}
return result;
}
export const isHandset: boolean = getDeviceType() === 'Handset';
export const isTorCapable: boolean = getIsTorCapable();
export { isDesktop, isTablet };

View file

@ -32,7 +32,7 @@ export const useIsLargeScreen = () => {
const halfScreenWidth = windowWidth >= screenWidth / 2;
const condition = (isRunningOnTablet && halfScreenWidth) || isDesktop;
console.debug(
`Window width: ${windowWidth}, Screen width: ${screenWidth}, Is tablet: ${isTablet}, Is large screen: ${condition}, isDesktkop: ${isDesktop}`,
`Window width: ${windowWidth}, Screen width: ${screenWidth}, Is tablet: ${isTablet()}, Is large screen: ${condition}, isDesktkop: ${isDesktop}`,
);
return condition;
}, [windowWidth, screenWidth]);

View file

@ -117,7 +117,7 @@ const Broadcast: React.FC = () => {
return (
<SafeArea>
<KeyboardAvoidingView enabled={!isTablet} behavior={Platform.OS === 'ios' ? 'position' : undefined}>
<KeyboardAvoidingView enabled={!isTablet()} behavior={Platform.OS === 'ios' ? 'position' : undefined}>
<View style={styles.wrapper} testID="BroadcastView">
{BROADCAST_RESULT.success !== broadcastResult && (
<BlueCard style={styles.mainCard}>