本文整理匯總了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設備