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;