๐ Available for use with both React Native Expo and ReactNativeCLI.
1.react-native-freelifemakers-ui NPM Module Install
npm install react-native-freelifemakers-ui
2.Usage
โ๏ธModule import
import { FlmButton } from "react-native-freelifemakers-ui";
โ๏ธExample Code
{/* default */}
<FlmButton
title="Click!"
onPress={handlePress}
/>
{/* ์คํ์ผ ์ถ๊ฐ๋ฒํผ / Add style button */}
<FlmButton
title="Green Button"
onPress={goToApp}
style={{ backgroundColor: '#28a745', marginTop: 20 }}
textStyle={{ fontSize: 18 }}
/>
{/* ๋นํ์ฑํ๋ ๋ฒํผ / Disable Button*/}
<FlmButton
title="Disable Button"
onPress={handlePress}
disabled={true}
style={{ marginTop: 20 }}
/>
3.Full code
import { Alert, Text, View, ScrollView, SafeAreaView } from "react-native";
import { FlmButton } from "react-native-freelifemakers-ui"; // ์ฌ์ฉ๋ฒ / Usage
//import { FlmRadioGroup } from "./FlmRadioGroups";
import { Ionicons } from "@expo/vector-icons";
// useRouter ํ
์ํฌํธ / Import the useRouter hook
import { useRouter } from "expo-router";
const handlePress = () => {
Alert.alert("๋ฒํผ์ด ๋๋ ธ์ต๋๋ค!!/The button was pressed!!.");
};
export default function Index() {
// useRouter ํ
์ ์ปดํฌ๋ํธ์ ์ต์์ ๋ ๋ฒจ์์ ํธ์ถํฉ๋๋ค.
// Call the useRouter hook at the top level of the component.
const router = useRouter();
const handleIconButtonPress = () => {
// ์ด์ router ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ์ฌ ํ๋ฉด ์ด๋์ ์ฒ๋ฆฌํฉ๋๋ค.
// '/flmText' ๊ฒฝ๋ก๋ก ์ด๋ํ๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
// ์ด ๊ฒฝ๋ก์ ํด๋นํ๋ ํ์ผ (์: app/flmText.tsx ๋๋ app/flmText.js)์ด ์์ด์ผ ํฉ๋๋ค.
// Now, we'll use the router object to handle screen navigation.
// Assuming we're navigating to the '/flmText' route.
// There should be a file corresponding to that route,
// such as app/flmText.tsx or app/flmText.js.
router.push("/flmText");
};
// ํจ์ ์ ์ ์ ํ๋ผ๋ฉํฐ๋ฅผ ๋ฐ๋๋ก ๋ณ๊ฒฝ
// Changed the function definition to accept parameters
const navigateToScreen = (screenName) => {
console.log(`Navigating to: /${screenName}`);
router.push(`/${screenName}`);
};
return (
<SafeAreaView style={{ flex: 1, backgroundColor: "#f9f9f9" }}>
<ScrollView contentContainerStyle={{ padding: 20, alignItems: "center" }}>
<Text style={{ marginBottom: 20 }}>FlmButton Style</Text>
{/* ๊ธฐ๋ณธ๋ฒํผ / default button */}
<FlmButton title="Default Button" onPress={handlePress} />
{/* ์ฐ๋์ ๋ฒํผ / Green Color Button*/}
<FlmButton
title="Green Button"
onPress={handlePress}
style={{ backgroundColor: "#28a745", marginTop: 20 }}
textStyle={{ fontSize: 18 }}
/>
{/* ์์ด์ฝ์ ๋ฒํผ / icon button */}
<FlmButton
title="Icon Button!"
icon={<Ionicons name="heart-outline" size={20} color="white" />}
onPress={handleIconButtonPress} // ์์ ๋ ํธ๋ค๋ฌ ์ฐ๊ฒฐ
style={{ backgroundColor: "#FFA500", marginTop: 20 }}
/>
{/* ๋นํ์ฑํ๋ ๋ฒํผ / Disable Button*/}
<FlmButton
title="Disable Button"
onPress={handlePress}
disabled={true}
style={{ marginTop: 20 }}
/>
{/* ์์ด์ฝ์ ๋ฒํผ2 / icon button */}
<FlmButton
title="move to FlmTextInput"
icon={<Ionicons name="heart-outline" size={20} color="white" />}
onPress={() => navigateToScreen("flmTextInput")} //
style={{ backgroundColor: "#FFA500", marginTop: 20 }}
/>
{/* ๊ธฐ๋ณธ๋ฒํผ2 / default button2 */}
<FlmButton
title="move to FlmRadio"
onPress={() => navigateToScreen("flmRadio")}
style={{ marginTop: 20 }}
/>
{/* ๊ธฐ๋ณธ๋ฒํผ3 / default button3 / FlmCheckBox */}
<FlmButton
title="move to FlmCheckBox"
onPress={() => navigateToScreen("flmCheckBox")}
style={{ marginTop: 20 }}
/>
{/* ๊ธฐ๋ณธ๋ฒํผ3 / default button3 / FlmModal */}
<FlmButton
title="move to FlmModal"
onPress={() => navigateToScreen("flmModal")}
style={{ marginTop: 20 }}
/>
{/* ๊ธฐ๋ณธ๋ฒํผ4 / default button4 / FlmBottomSheet */}
<FlmButton
title="move to FlmBottomSheet"
onPress={() => navigateToScreen("flmBottomSheet")}
style={{ marginTop: 20 }}
/>
{/* ๊ธฐ๋ณธ๋ฒํผ5 / default button5 / FlmSnackBar - Using Context API */}
<FlmButton
title="move to FlmSnackBar"
onPress={() => navigateToScreen("flmSnackBar")}
style={{ marginTop: 20 }}
/>
{/* ๊ธฐ๋ณธ๋ฒํผ6 / default button6 / FlmSnackBar - Custom */}
<FlmButton
title="move to FlmSnackBar Custom"
onPress={() => navigateToScreen("flmSnackBarCustom")}
style={{ marginTop: 20 }}
/>
{/* ๊ธฐ๋ณธ๋ฒํผ7 / default button7 / FlmSearchBar #007bff #9370DB*/}
<FlmButton
title="move to FlmSearchBar Custom"
onPress={() => navigateToScreen("flmSearchBar")}
style={{ backgroundColor: "#F44336", marginTop: 20 }}
/>
</ScrollView>
</SafeAreaView>
);
}
4.ScreenShot
