本文整理汇总了TypeScript中react-native.Dimensions类的典型用法代码示例。如果您正苦于以下问题:TypeScript Dimensions类的具体用法?TypeScript Dimensions怎么用?TypeScript Dimensions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dimensions类的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('/')
};
};
示例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
};
};
示例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;
},
};
示例4:
const dimensionConverter: DimensionConverterFactory = (viewport, axis) => (
target: number
) => target / 100 * Dimensions.get(viewport)[axis];
示例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设备