๐A modal is a UI container that overlays the screen and blocks user interaction,
directing focus to a single task or piece of information.
It is commonly used for user login, password input, image zooming, and similar interactions.
1.react-native-freelifemakers-ui NPM Module Install
npm install react-native-freelifemakers-ui
2.Usage
โ๏ธOpens a modal when the button is clicked.
import {FlmModal, FlmButton, FlmText} from 'react-native-freelifemakers-ui';
<FlmButton
title="๊ธฐ๋ณธ ๋ชจ๋ฌ ์ด๊ธฐ/Open Default Modal"
onPress={() => setModal1Visible(true)}
/>
<FlmModal
isVisible={isModal1Visible}
onClose={() => setModal1Visible(false)}
title="๊ธฐ๋ณธ ๋ชจ๋ฌ/Default Modal"
message="์๋ฌด๋ฐ ์ปค์คํ
์คํ์ผ์ด ์ ์ฉ๋์ง ์์์ต๋๋ค.
/No custom styles were applied."
animationDirection="slideUp"
/>
3.Full Code
import React, { useState } from "react";
import { View, StyleSheet, SafeAreaView, ScrollView } from "react-native";
import { FlmModal, FlmButton, FlmText } from "react-native-freelifemakers-ui";
export default function FlmModalApp() {
const [isModal1Visible, setModal1Visible] = useState(false);
const [isModal2Visible, setModal2Visible] = useState(false);
// ์ปค์คํ
์คํ์ผ ์ ์ฉ / Apply custom style
const [isModal3Visible, setModal3Visible] = useState(false);
// ๋ค๋ฅธ ์ปค์คํ
์คํ์ผ / Apply another custom style
const [isModal4Visible, setModal4Visible] = useState(false);
return (
<SafeAreaView style={appStyles.safeArea}>
<ScrollView style={appStyles.scrollViewContent}>
<View style={appStyles.section}>
<FlmText style={appStyles.header}>FlmModal ์ปค์คํฐ๋ง์ด์ง ์์</FlmText>
{/* --- 1. ๊ธฐ๋ณธ ์ฌ๋ผ์ด๋ ๋ชจ๋ฌ / Default Slide Modal
-- 'slideUp', 'slideDown', 'slideLeft', 'slideRight',
'fade', 'none' --- */}
<FlmText>
1. ๊ธฐ๋ณธ ์ฌ๋ผ์ด๋ ๋ชจ๋ฌ / Default --
slideUp,slideDown,slideLeft,slideRight, fade, none
</FlmText>
<FlmButton
title="๊ธฐ๋ณธ ๋ชจ๋ฌ ์ด๊ธฐ/Open Default Modal"
onPress={() => setModal1Visible(true)}
/>
<FlmModal
isVisible={isModal1Visible}
onClose={() => setModal1Visible(false)}
title="๊ธฐ๋ณธ ๋ชจ๋ฌ/Default Modal"
message="์๋ฌด๋ฐ ์ปค์คํ
์คํ์ผ์ด ์ ์ฉ๋์ง ์์์ต๋๋ค.
/No custom styles were applied."
animationDirection="slideUp"
/>
<FlmText>2. ์ปค์คํ
๋ชจ๋ฌ/Custom Modal</FlmText>
{/* --- 2. ๋ฐฐ๊ฒฝ์, ํฌ๋ช
๋ ๋ณ๊ฒฝ ๋ชจ๋ฌ /
Modal to change background color and transparency --- */}
<View style={{ marginTop: 20 }}>
<FlmButton
title="๋ฐฐ๊ฒฝ ์ปค์คํ
๋ชจ๋ฌ ์ด๊ธฐ/Background Custom Modal"
onPress={() => setModal2Visible(true)}
/>
</View>
<FlmModal
isVisible={isModal2Visible}
onClose={() => setModal2Visible(false)}
title="๋ฐฐ๊ฒฝ ์ปค์คํ
/Background Custom"
message="๋ฐฐ๊ฒฝ์ด ํ๋์ ๋ฐํฌ๋ช
์ผ๋ก ๋ณ๊ฒฝ๋์์ต๋๋ค.
/The background has been changed to a blue, translucent color."
animationDirection="fade"
// ํ๋์ ๋ฐํฌ๋ช
๋ฐฐ๊ฒฝ / Blue translucent background
backdropColor="rgba(0,0,255,0.3)"
/>
{/* --- 3. ๋ชจ๋ฌ ์ปจํ
์ธ ์คํ์ผ ๋ณ๊ฒฝ ๋ชจ๋ฌ /
Modal content style change modal --- */}
<View style={{ marginTop: 20 }}>
<FlmButton
title="์ปจํ
์ธ ์คํ์ผ ์ปค์คํ
๋ชจ๋ฌ ์ด๊ธฐ
/Open custom modal with content style"
onPress={() => setModal3Visible(true)}
/>
</View>
<FlmModal
isVisible={isModal3Visible}
onClose={() => setModal3Visible(false)}
title="์ปจํ
์ธ ์ปค์คํ
/Content customization"
message="๋ชจ๋ฌ ์ปจํ
์ธ ๋ฐ์ค์ ๋ชจ์์ด ๋ณ๊ฒฝ๋์์ต๋๋ค.
/The appearance of the modal content box has changed."
animationDirection="slideRight"
modalContentStyle={{
backgroundColor: "#FFF0F5", // ์ฐํ ๋ถํ์ / Light pink
borderRadius: 5, // ๋ ๋ฅ๊ทผ ๋ชจ์๋ฆฌ / Less rounded corners
borderWidth: 2, // ํ
๋๋ฆฌ ์ถ๊ฐ / Add border
borderColor: "#FF69B4", // ํํฌ์ ํ
๋๋ฆฌ / Pink border
padding: 10, // ํจ๋ฉ ์กฐ์ / padding adjustment
}}
titleStyle={{
color: "#FF69B4", // ํํฌ์ ์ ๋ชฉ / Pink Color Title
fontSize: 25,
fontWeight: "normal",
}}
messageStyle={{
color: "#8B008B", // ๋ณด๋ผ์ ๋ฉ์์ง / Pupple Color Message
fontStyle: "italic",
}}
>
<FlmText>
์ฌ๊ธฐ์ ์ถ๊ฐ์ ์ธ ์ปค์คํ
๋ด์ฉ์ด ๋ค์ด๊ฐ ์ ์์ต๋๋ค!/Additional
custom content can be added here!
</FlmText>
</FlmModal>
{/* --- 4. ๋ค์ํ ์คํ์ผ ์๊ธฐ / Mix different styles --- */}
<View style={{ marginTop: 20 }}>
<FlmButton
title="๋ค์ํ ์คํ์ผ ์๊ธฐ/Mix different styles"
onPress={() => setModal4Visible(true)}
/>
</View>
<FlmModal
isVisible={isModal4Visible}
onClose={() => setModal4Visible(false)}
title="MIXED STYLE!"
message="๋ฐฐ๊ฒฝ, ์ปจํ
์ธ , ํ
์คํธ ์คํ์ผ์ด ๋ชจ๋ ์ปค์คํ
๋์์ต๋๋ค.
/Background, content, and text styles are all customized."
animationDirection="slideDown"
animationDuration={500} // ์ ๋๋ฉ์ด์
์๊ฐ๋ ์กฐ์ / Adjust animation time
// ์ฃผํฉ์ ๋ฐํฌ๋ช
๋ฐฐ๊ฒฝ / Orange translucent background
backdropColor="rgba(255,165,0,0.4)"
modalContentStyle={{
backgroundColor: "#E0FFFF", // ์ฐํ ํ๋์ / light sky blue
borderRadius: 30, // ๋ ๋ฅ๊ทผ ๋ชจ์๋ฆฌ / more rounded corners
shadowColor: "#000",
shadowOffset: { width: 0, height: 4 },
shadowOpacity: 0.3,
shadowRadius: 5,
elevation: 8,
}}
titleStyle={{
color: "#4682B4", // ์คํธ๋ธ๋ฃจ ์ ๋ชฉ / steel blue title
textDecorationLine: "underline",
}}
messageStyle={{
// ์ด๋์ด ์ฌ๋ ์ดํธ ๊ทธ๋ ์ด ๋ฉ์์ง / Dark slate grey message
color: "#2F4F4F",
lineHeight: 24,
}}
/>
</View>
</ScrollView>
</SafeAreaView>
);
}
const appStyles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: "#f0f2f5",
},
scrollViewContent: {
padding: 20,
},
header: {
// ์ญ์ ์์
fontSize: 24,
fontWeight: "bold",
marginBottom: 30,
color: "#333",
textAlign: "center",
},
section: {
marginBottom: 30,
padding: 15,
backgroundColor: "#fff",
borderRadius: 10,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 3,
elevation: 5,
},
customChildrenText: {
//์ญ์ ์์
fontSize: 14,
color: "#333",
marginTop: 10,
marginBottom: 15,
textAlign: "center",
fontStyle: "italic",
},
});
3.ScreenShot