๋ฐฐ์ง€/FlmBadge

1.react-native-freelifemakers-ui NPM ๋ชจ๋“ˆ ์„ค์น˜ํ•˜๊ธฐ / react-native-freelifemakers-ui NPM Module Install

npm install react-native-freelifemakers-ui

2.์‚ฌ์šฉํ•˜๊ธฐ / Usage
1)๋ชจ๋“ˆ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ / import Module

import { FlmBadge, FlmText, FlmButton } from "react-native-freelifemakers-ui";

2)์‚ฌ์šฉํ•˜๊ธฐ / Usage
— ๊ธฐ๋ณธ / Default

 <FlmBadge children="5" />

— ์‚ฌ์šฉ์ž์ •์˜ / Custom

<FlmBadge
            children="99+"
            size={34}
            textStyle={{fontSize: 10}}
            backgroundColor="#10b981"
        />

3.์˜ˆ์ œ์ฝ”๋“œ / Example code

import React from 'react';
import {StyleSheet, View, Text} from 'react-native';
import {FlmBadge, FlmText, FlmButton} from 'react-native-freelifemakers-ui';

// FlmBadge ์ปดํฌ๋„ŒํŠธ ์‚ฌ์šฉ ์˜ˆ์‹œ
// This is an example of how to use the FlmBadge component.
const FlmBadgeApp = () => {
  return (
    <View style={styles.container}>
      <FlmText category="subtitle" style={{marginBottom: 10}}>
        FlmBadge ์ปดํฌ๋„ŒํŠธ ์‚ฌ์šฉ ์˜ˆ์ œ / Example of using the FlmBadge component
      </FlmText>
      <FlmText category="subtitle" style={{marginBottom: 10}}>
        ๋‹ค์–‘ํ•œ ํฌ๊ธฐ์™€ ์ƒ‰์ƒ์˜ ๋ฐฐ์ง€๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. / Shows how to
        display badges of different sizes and colors.
      </FlmText>

      {/* 1. ๊ธฐ๋ณธ ์‚ฌ์šฉ ์˜ˆ์‹œ / Basic usage example */}
      <View style={styles.section}>
        <Text style={styles.sectionTitle}>๋‹จ๋… ๋ฐฐ์ง€ / sole badge</Text>
        <View style={styles.exampleRow}>
          <FlmBadge children="5" />
          <FlmBadge
            children="99+"
            size={34}
            textStyle={{fontSize: 10}}
            backgroundColor="#10b981"
          />
          <FlmBadge
            children="New"
            size={38}
            textStyle={{fontSize: 10}}
            backgroundColor="#f97316"
          />
        </View>
      </View>

      {/* 2. ์•„์ด์ฝ˜ ์˜†์— ๋ฐฐ์น˜ํ•˜์—ฌ ์•Œ๋ฆผ ํ‘œ์‹œํ•˜๋Š” ์˜ˆ์‹œ */}
      {/* 2. Example of displaying notifications by placing them next to the icon */}
      <View style={styles.section}>
        <Text style={styles.sectionTitle}>์•Œ๋ฆผ ์•„์ด์ฝ˜ / Notification icon</Text>
        <View style={styles.exampleRow}>
          {/* ์•Œ๋ฆผ ์•„์ด์ฝ˜ ์—ญํ• ์„ ํ•˜๋Š” View */}
          {/* View that acts as a notification icon */}
          <View style={styles.iconWrapper}>
            <Text style={styles.iconText}>๐Ÿ””</Text>
            {/* ๋ฐฐ์ง€๋ฅผ ์ ˆ๋Œ€ ์œ„์น˜๋กœ ์•„์ด์ฝ˜์˜ ์˜ค๋ฅธ์ชฝ ์ƒ๋‹จ์— ๋ฐฐ์น˜ํ•ฉ๋‹ˆ๋‹ค. */}
            {/* Position the badge absolutely on the top-right of the icon. */}
            <FlmBadge children="1" style={styles.badgeAbsolute} />
          </View>
          <View style={styles.iconWrapper}>
            <FlmText style={styles.iconText}>๐Ÿ“ง</FlmText>
            <FlmBadge
              children="12"
              size={24}
              textStyle={{fontSize: 10}}
              style={styles.badgeAbsolute}
            />
          </View>
        </View>
      </View>

      {/* 3. `visible` prop์„ ์‚ฌ์šฉํ•œ ํ‘œ์‹œ/์ˆจ๊น€ ์˜ˆ์‹œ */}
      {/* 3. Example of showing/hiding using the `visible` prop */}
      <View style={styles.section}>
        <FlmText style={styles.sectionTitle}>ํ‘œ์‹œ/์ˆจ๊น€ - Show/Hide</FlmText>
        <View style={styles.exampleRow}>
          <FlmBadge children="2" visible={true} />
          <FlmBadge children="1" visible={false} />
          <FlmText style={styles.smallText}>- ๋ณด์ด์ง€ ์•Š์Œ / invisible</FlmText>
        </View>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
    backgroundColor: '#fff',
  },
  section: {
    marginBottom: 30,
  },
  sectionTitle: {
    fontSize: 20,
    fontWeight: 'bold',
    marginBottom: 10,
  },
  exampleRow: {
    flexDirection: 'row',
    alignItems: 'center',
    gap: 20, // ํ•ญ๋ชฉ ๊ฐ„์˜ ๊ฐ„๊ฒฉ
  },
  iconWrapper: {
    position: 'relative',
    padding: 10,
  },
  iconText: {
    fontSize: 30,
  },
  badgeAbsolute: {
    position: 'absolute',
    top: -5,
    right: -5,
  },
  smallText: {
    fontSize: 14,
    color: '#6b7280',
  },
});

export default FlmBadgeApp;

Leave a Reply