mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
FIX: is tablet detection
This commit is contained in:
parent
e9e73f54ac
commit
ead613aed4
4 changed files with 2 additions and 37 deletions
|
@ -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 };
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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}>
|
||||
|
|
Loading…
Add table
Reference in a new issue