๋ชจ๋‹ฌ/FlmModal

๋ชจ๋‹ฌ์€ ํ™”๋ฉด ์œ„์— ์˜ค๋ฒ„๋ ˆ์ด๋˜์–ด ์‚ฌ์šฉ์ž ์ƒํ˜ธ์ž‘์šฉ์„ ์ฐจ๋‹จํ•˜๊ณ , ํ•˜๋‚˜์˜ ์ž‘์—… ๋˜๋Š” ์ •๋ณด์— ์ง‘์ค‘ํ•˜๋„๋ก ๋งŒ๋“œ๋Š” UI์ปจํ…Œ์ด๋„ˆ๋กœ์„œ
์‚ฌ์šฉ์ž๋กœ๊ทธ์ธ,๋น„๋ฐ€๋ฒˆํ˜ธ์ž…๋ ฅ,์ด๋ฏธ์ง€ํ™•๋Œ€๋ณด๊ธฐ๋“ฑ์— ๋งŽ์ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

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 ๋ชจ๋“ˆ ์„ค์น˜ํ•˜๊ธฐ / react-native-freelifemakers-ui NPM Module Instal

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"
          />

— ์˜ˆ์ œ ์ฝ”๋“œ / Example 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);
  const [isModal3Visible, setModal3Visible] = useState(false); // ์ปค์Šคํ…€ ์Šคํƒ€์ผ ์ ์šฉ / Apply custom style
  const [isModal4Visible, setModal4Visible] = useState(false); // ๋‹ค๋ฅธ ์ปค์Šคํ…€ ์Šคํƒ€์ผ / Apply another custom style

  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"
            backdropColor="rgba(0,0,255,0.3)" // ํŒŒ๋ž€์ƒ‰ ๋ฐ˜ํˆฌ๋ช… ๋ฐฐ๊ฒฝ / Blue translucent background
          />

          {/* --- 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
            backdropColor="rgba(255,165,0,0.4)" // ์ฃผํ™ฉ์ƒ‰ ๋ฐ˜ํˆฌ๋ช… ๋ฐฐ๊ฒฝ / Orange translucent background
            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={{
              color: '#2F4F4F', // ์–ด๋‘์šด ์Šฌ๋ ˆ์ดํŠธ ๊ทธ๋ ˆ์ด ๋ฉ”์‹œ์ง€ / Dark slate grey message
              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.์Šคํฌ๋ฆฐ์ƒท/Screen Shot

Leave a Reply