import * as Device from 'expo-device'; import * as React from 'react'; import { Button, ScrollView, View } from 'react-native'; import HeadingText from '../components/HeadingText'; import MonoText from '../components/MonoText'; import Colors from '../constants/Colors'; interface DeviceConstant { name?: string; value?: any; } interface DeviceMethod { name?: string; method: () => Promise; } const deviceTypeMap = { [Device.DeviceType.UNKNOWN]: 'unknown', [Device.DeviceType.PHONE]: 'phone', [Device.DeviceType.TABLET]: 'tablet', [Device.DeviceType.DESKTOP]: 'desktop', [Device.DeviceType.TV]: 'tv', }; function DeviceConstants({ name, value }: DeviceConstant) { return ( {name} {typeof value === 'boolean' ? String(value) : value} ); } function DeviceMethods({ name = '', method }: DeviceMethod) { const [value, setValue] = React.useState(''); const getValueAsync = async () => { let value: any; try { value = await method(); if (typeof value === 'boolean') { value = value.toString(); } else if (Array.isArray(value)) { value = value.join('\n'); } } catch (error) { alert(error); value = error.message; } setValue(value); }; return ( {name} {value}