따꿍의 프로젝트
[2025.09.06] 모달 코딩하기 본문

모달 컴포넌트에 대해서 배웠다
import { View, Text, Modal, StyleSheet, Pressable } from 'react-native';
import React from 'react';
import commonColors from '../../assets/colors/commonColors';
const ConfirmModal = ({
modalVisible,
setModalVisible,
title,
text,
buttonText,
}) => {
return (
<Modal
animationType='fade'
transparent={true}
visible={modalVisible}
onRequestClose={() => {
setModalVisible(!modalVisible);
}}
>
<View style={styles.overlay}>
<View style={styles.modalView}>
<Text style={styles.titleText}>{title}</Text>
<Text style={styles.contentText}>{text}</Text>
<Pressable onPress={() => setModalVisible(!modalVisible)}>
<View style={styles.button}>
<Text style={styles.buttonText}>{buttonText}</Text>
</View>
</Pressable>
</View>
</View>
</Modal>
);
};
const styles = StyleSheet.create({
overlay: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'rgba(0,0,0,0.3)', // dim background
},
modalView: {
width: '80%',
backgroundColor: commonColors.white,
borderRadius: 20,
padding: 20,
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
},
titleText: {
fontWeight: 700,
marginBottom: 10,
},
contentText: { marginBottom: 10 },
button: {
height: 50,
backgroundColor: commonColors.blue,
borderRadius: 25,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
buttonText: {
color: commonColors.white,
fontWeight: 700,
},
});
export default ConfirmModal;'웹프로젝트 > 졸작' 카테고리의 다른 글
| [2025.10.14] 카카오 도서 API에서 Book 테이블 크롤링하기 (0) | 2025.10.15 |
|---|---|
| [2025.10.13] pdf에서 텍스트 추출 (0) | 2025.10.13 |
| [2025.09.06] 검색 기능 구현 (0) | 2025.09.06 |
| [2025.08.29] 바뀐 DB에 따라 기존 코드 수정 (0) | 2025.08.29 |
| [20205.08.25] UserBookProgress의 is_bookmarked column 삭제 후 UserBookBookmark 생성 (0) | 2025.08.29 |
