mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {Platform} from 'react-native'
2import {getLocales} from 'expo-localization'
3
4import {fixLegacyLanguageCode} from '#/locale/helpers'
5import {dedupArray} from 'lib/functions'
6
7export const isIOS = Platform.OS === 'ios'
8export const isAndroid = Platform.OS === 'android'
9export const isNative = isIOS || isAndroid
10export const devicePlatform = isIOS ? 'ios' : isAndroid ? 'android' : 'web'
11export const isWeb = !isNative
12export const isMobileWebMediaQuery = 'only screen and (max-width: 1300px)'
13export const isMobileWeb =
14 isWeb &&
15 // @ts-ignore we know window exists -prf
16 global.window.matchMedia(isMobileWebMediaQuery)?.matches
17export const isIPhoneWeb = isWeb && /iPhone/.test(navigator.userAgent)
18
19export const deviceLocales = dedupArray(
20 getLocales?.()
21 .map?.(locale => fixLegacyLanguageCode(locale.languageCode))
22 .filter(code => typeof code === 'string'),
23) as string[]