imobile_for_reactnative
Version:
iMobile for ReactNative,是SuperMap iMobile推出的一款基于React-Native框架的移动应用开发工具。基于该开发工具,用户可以使用JavaScript开发语言,开发出在Android和IOS操作系统下运行的原生移动GIS应用,入门门槛低,一次开发,处处运行。
27 lines (23 loc) • 499 B
text/typescript
import { Dimensions } from "react-native"
const screenWidth = Math.min(
Dimensions.get('window').width,
Dimensions.get('window').height,
)
/**
* 适配宽度 392.72dp 设备的大小
*
* 其他大小设备按宽度等比缩放
*/
export function dp(size: number): number {
return size * getDpRatio()
}
function getDpRatio():number {
//TODO 范围有待调整
if(screenWidth < 500) {
return screenWidth / 392.72
}
if(screenWidth < 1000) {
return 1.25
}
return 1.36
}