4 changed files with 52 additions and 10 deletions
@ -0,0 +1,14 @@
|
||||
import React from 'react'; |
||||
import { Ionicons } from '@expo/vector-icons'; |
||||
|
||||
interface IconComponentProps { |
||||
name: string; |
||||
size: number; |
||||
color: string; |
||||
} |
||||
|
||||
const IconComponent: React.FC<IconComponentProps> = ({ name, size, color }) => { |
||||
return <Ionicons name={name as any} size={size} color={color} />; |
||||
}; |
||||
|
||||
export default IconComponent;
|
@ -1 +1,29 @@
|
||||
|
||||
import { Dimensions } from 'react-native'; |
||||
|
||||
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window'); |
||||
|
||||
// 设计稿尺寸
|
||||
const DESIGN_WIDTH = 430; |
||||
const DESIGN_HEIGHT = 932; |
||||
|
||||
// 计算缩放比例
|
||||
const widthScale = SCREEN_WIDTH / DESIGN_WIDTH; |
||||
const heightScale = SCREEN_HEIGHT / DESIGN_HEIGHT; |
||||
|
||||
// 创建尺寸转换函数
|
||||
export const size = { |
||||
// 宽度适配
|
||||
w: (width: number) => width * widthScale, |
||||
// 高度适配
|
||||
h: (height: number) => height * heightScale, |
||||
// 字体大小适配
|
||||
f: (fontSize: number) => fontSize * widthScale, |
||||
// 边距适配
|
||||
m: (margin: number) => margin * widthScale, |
||||
// 圆角适配
|
||||
r: (radius: number) => radius * widthScale, |
||||
// 获取屏幕宽度
|
||||
screenWidth: SCREEN_WIDTH, |
||||
// 获取屏幕高度
|
||||
screenHeight: SCREEN_HEIGHT, |
||||
};
|
Loading…
Reference in new issue