styles.js
import { Dimensions } from 'react-native';
// 아이폰 14 PRO
export const basicDimensions = {
height: 852,
width: 393,
};
export const height = // 높이 변환 작업
(Dimensions.get('screen').height * (1 / basicDimensions.height)).toFixed(2);
export const width = // 가로 변환 작업
(Dimensions.get('screen').width * (1 / basicDimensions.width)).toFixed(2);
import React from 'react';
import {StyleSheet, View, TouchableOpacity, Text} from 'react-native';
import {colors, width, height} from '../config/globalStyles'; //width,height 받아오기
import MyIcon from '../config/Icon-font.js';
return (
<View style={styles.notification}>
<TouchableOpacity activeOpacity={0.8} style={styles.notification}>
<View style={styles.notificationBody}>
<MyIcon
name={'alarm-3'}
size={width * 25} <!--아이콘에서도-->
color={colors.borderGrey}
/>
<Text style={styles.notificationContent}>{content}</Text>
</View>
<Text style={styles.notificationTime}>방금 전</Text>
</TouchableOpacity>
</View>
);
};
export default Notification;
const styles = StyleSheet.create({
notification: {
width: '100%',
height: height * 70, //높이를 지정해줄 때도
backgroundColor: colors.bottomTabBarBackgroundColor,
padding: width * 10, // padding 값을 줄 때도
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
},
notificationBody: {
flexDirection: 'row',
alignItems: 'center',
},
notificationContent: {
marginLeft: width * 10, // margin 값을 줄 때도
fontSize: width * 13, // 폰트 사이즈를 지정해줄 때도!
},
notificationTime: {
fontSize: width * 11,
color: colors.grey,
},
});
[React Native] Dimensions.get('window')와 Dimensions.get('screen')의 차이점 | millo's tech blog