How to use the expo-constants.platform function in expo-constants

To help you get started, we’ve selected a few expo-constants examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / expo-constants_v4.x.x / flow_v0.69.0-v0.103.x / test_expo-constants.js View on Github external
it('should raise an error when lead to an incompatible type', () => {
        if (Constants.platform && Constants.platform.ios) {
          // $ExpectError
          (Constants.platform.ios.buildNumber: number);
          // $ExpectError
          (Constants.platform.ios.platform: number);
          // $ExpectError
          (Constants.platform.ios.model: number);
          // $ExpectError
          (Constants.platform.ios.userInterfaceIdiom: number);
          // $ExpectError
          (Constants.platform.ios.systemVersion: number);
        }
      });
    });
github flow-typed / flow-typed / definitions / npm / expo-constants_v4.x.x / flow_v0.69.0-v0.103.x / test_expo-constants.js View on Github external
it('should have versionCode prop', () => {
        if (Constants.platform && Constants.platform.android) {
          (Constants.platform.android.versionCode: number);

          // $ExpectError: check any
          (Constants.platform.android.versionCode: boolean);
        }
      });
    });
github flow-typed / flow-typed / definitions / npm / expo-constants_v4.x.x / flow_v0.69.0-v0.103.x / test_expo-constants.js View on Github external
it('should have specific ios props', () => {
        if (Constants.platform && Constants.platform.ios) {
          (Constants.platform.ios.buildNumber: string);
          (Constants.platform.ios.platform: string);
          (Constants.platform.ios.model: string);
          (Constants.platform.ios.userInterfaceIdiom:
            | 'handset'
            | 'tablet'
            | 'unsupported');
          (Constants.platform.ios.systemVersion: string);
        }
      });
      it('should raise an error when lead to an incompatible type', () => {
github molenzwiebel / Mimic / frontend / utils / constants.ts View on Github external
export function getNotificationPlatform() {
    return Constants.platform!.ios
        ? NotificationPlatform.IOS
        : Constants.platform!.android
            ? NotificationPlatform.ANDROID
            : NotificationPlatform.WEB;
}
github molenzwiebel / Mimic / frontend / utils / notch.ts View on Github external
import Constants from "expo-constants";

const hasiPhoneNotch =
    Constants.platform!.ios &&
    ["iPhone X", "iPhone Xs", "iPhone Xs Max", "iPhone Xr"].includes(Constants.platform!.ios.model);
const notchHeight = Constants.statusBarHeight + (hasiPhoneNotch ? 0 : 0);

export default notchHeight;
export const bottomMargin = hasiPhoneNotch ? 28 : 0;
github mirshko / unleaded / src / constants / index.js View on Github external
import Constants from "expo-constants";

const constants = {
  headerOffset: 80,
  buildNumber: Constants.manifest.ios.buildNumber,
  version: Constants.manifest.version,
  systemVersion: Constants.platform.ios.systemVersion,
  model: Constants.platform.ios.model,
  spacing: {
    tiny: 2,
    small: 4,
    medium: 8,
    large: 16,
    mlarge: 20,
    xlarge: 24,
    xxlarge: 32
  }
};

const feedbackTemplate = `

---
Build: ${constants.buildNumber}
github amandeepmittal / mobilenet-tfjs-expo / App.js View on Github external
getPermissionAsync = async () => {
    if (Constants.platform.ios) {
      const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL)
      if (status !== 'granted') {
        alert('Sorry, we need camera roll permissions to make this work!')
      }
    }
  }
github molenzwiebel / Mimic / frontend / components / NotificationPrompt.tsx View on Github external
function NotificationImage({ width, height }: { width: number; height: number }) {
    const image = Constants.platform!.ios ? IMAGES.ios : IMAGES.android;
    const ratio = image.height / image.width;

    const renderWidth = Math.min(width - 40, image.width);
    const renderMargin = (width - renderWidth) / 2;
    const renderHeight = renderWidth * ratio;

    const style = {
        position: "absolute" as "absolute",
        width: renderWidth,
        left: 0,
        marginLeft: renderMargin,
        marginRight: renderMargin,
        top: height * 0.6,
        height: renderHeight
    };
github yinxin630 / fiora-app / utils / platform.js View on Github external
import { Platform } from 'react-native';
import Constants from 'expo-constants';
import packageInfo from '../package';

const os = Platform.OS === 'ios' ? 'iOS' : 'Android';

export const isiOS = Platform.OS === 'ios';
export const isAndroid = Platform.OS === 'android';

export default {
    os,
    browser: 'App',
    environment: `App ${process.env.NODE_ENV === 'development' ? '开发版' : packageInfo.version} on ${os} ${isiOS ? Constants.platform.ios.systemVersion : Constants.systemVersion} ${isiOS ? Constants.platform.ios.model : ''}`,
};