當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Dimensions.get方法代碼示例

本文整理匯總了TypeScript中react-native.Dimensions.get方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Dimensions.get方法的具體用法?TypeScript Dimensions.get怎麽用?TypeScript Dimensions.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在react-native.Dimensions的用法示例。


在下文中一共展示了Dimensions.get方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: String

export const clientInfo = () => {
    const dim = Dimensions.get('screen');
    logger.debug(Platform, dim);

    const OS = 'android';
    const { Version } = Platform;

    return {
        platform: OS,
        version: String(Version),
        appVersion: [OS, String(Version)].join('/')
    };
};
開發者ID:lukethompson,項目名稱:aws-amplify,代碼行數:13,代碼來源:android.ts

示例2: dimToMake

export const clientInfo = () => {
    const dim = Dimensions.get('screen');
    logger.debug(Platform, dim);
    const OS = 'ios';
    const { Version } = Platform;
    const { make, model } = dimToMake(dim);
    return {
        'platform': OS,
        'version': String(Version),
        'appVersion': [OS, String(Version)].join('/'),
        'make': make,
        'model': model
    };
};
開發者ID:lukethompson,項目名稱:aws-amplify,代碼行數:14,代碼來源:ios.ts

示例3: setVar

import { Navigation } from 'react-native-navigation';

// Add some static re-usable css variables here
setVar('--hairline-width', StyleSheet.hairlineWidth);

// Add themes here
setTheme('default');
setThemeVars('default', {
  '--primary-color': '#ff2244',
  '--gutter': 8,
});

export default {
  async update() {
    // Add device width and height
    const { width, height } = Dimensions.get('window');
    setVar('--window-width', width);
    setVar('--window-height', height);

    // Add navigation constants
    const res = await Navigation.constants();
    setVar('--bottom-tabs-height', res.bottomTabsHeight);
    setVar('--status-bar-height', res.statusBarHeight);
    setVar('--top-bar-height', res.topBarHeight);

    // Add dynamic variables here
    // ...
    return true;
  },
};
開發者ID:birkir,項目名稱:kvikmyndr-app,代碼行數:30,代碼來源:theme.ts

示例4:

const dimensionConverter: DimensionConverterFactory = (viewport, axis) => (
  target: number
) => target / 100 * Dimensions.get(viewport)[axis];
開發者ID:Popmotion,項目名稱:popmotion,代碼行數:3,代碼來源:unit-conversion.ts

示例5: deviceWidth

import { Dimensions, Platform } from 'react-native';
import * as DeviceInfo from 'react-native-device-info';
import urlParse from 'url-parse';

let deviceInfo = null;
const DESIGN_IMAGE_WIDTH = 750; // 設計稿寬度
const screen = Dimensions.get('screen');
const DEVICE_WIDTH = Math.min(screen.width, screen.height);
const DEVICE_HEIGHT = Math.max(screen.width, screen.height);

export const util = {
  /**
   * 設備寬度
   */
  get deviceWidth(): number {
    return DEVICE_WIDTH;
  },
  /**
   * 設備高度
   */
  get deviceHeight(): number {
    return DEVICE_HEIGHT;
  },
  /**
   * 是否是iOS設備
   */
  get isIOS(): boolean {
    return Platform.OS === 'ios';
  },
  /**
   * 是否是Android設備
開發者ID:hstarorg,項目名稱:FlyingChat,代碼行數:31,代碼來源:util.ts


注:本文中的react-native.Dimensions.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。