rn-custom-modal-components
v2.0.0
Published
<a href="https://nodei.co/npm/rn-custom-modal-components/"><img src="https://nodei.co/npm/rn-custom-modal-components.png?downloads=true&downloadRank=true&stars=true"></a>
Maintainers
Readme
React Native Custom Modal Component
React Native Swipe Button Component
Version
| Expo SDK | React Native | Version | | ------------------ | ------------------- | ------------------- | | <= 52 | <= 0.76.x | <= 1.0.3 | | >= 53 | <= 0.79.x | >= 2.0.0 |
EXPO SDK <= 52 and React Native <= 0.76.x, install with version 1.0.3
npm install [email protected]yarn add [email protected]EXPO SDK >= 53 and React Native <= 0.79.x, install with version 2.0.0
npm install [email protected]yarn add [email protected]Installation
npm i rn-custom-modal-components --save
# OR
yarn add rn-custom-modal-components
# OR
pnpm i rn-custom-modal-components
Usage
import { ReactNativeAlert } from "rn-custom-modal-components";
<ReactNativeAlert />import { StatusBar } from "expo-status-bar";
import { Pressable, StyleSheet, Text, View } from "react-native";
import { useState } from "react";
import { ReactNativeAlert } from "rn-custom-modal-components";
export default function App() {
const [visible, setVisible] = useState(false);
const onConfirm = () => {
setVisible(false);
};
return (
<View style={styles.container}>
<ReactNativeAlert
visible={visible}
onVisible={setVisible}
message={
<>
<Text>React Native Alert !</Text>
</>
}
onConfirm={onConfirm}
/>
<Pressable
onPress={() => setVisible(true)}
style={{
width: "80%",
height: 50,
padding: 8,
borderRadius: 10,
backgroundColor: "blue",
}}
>
<Text
style={{
color: "white",
textAlign: "center",
fontSize: 22,
}}
>
Open Modal
</Text>
</Pressable>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
import { StatusBar } from "expo-status-bar";
import { Pressable, StyleSheet, Text, View } from "react-native";
import { useState } from "react";
import { ReactNativeDialog } from "rn-custom-modal-components";
export default function App() {
const [visible, setVisible] = useState(false);
const onConfirm = () => {
setVisible(false);
};
return (
<View style={styles.container}>
<ReactNativeDialog
visible={visible}
onVisible={setVisible}
message={
<>
<Text>React Native Dialog !</Text>
</>
}
onConfirm={onConfirm}
/>
<Pressable
onPress={() => setVisible(true)}
style={{
width: "80%",
height: 50,
padding: 8,
borderRadius: 10,
backgroundColor: "blue",
}}
>
<Text
style={{
color: "white",
textAlign: "center",
fontSize: 22,
}}
>
Open Dialog Input
</Text>
</Pressable>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
import { StatusBar } from "expo-status-bar";
import { Pressable, StyleSheet, Text, TextInput, View } from "react-native";
import { useState } from "react";
import { ReactNativeDialogInput } from "rn-custom-modal-components";
export default function App() {
const [visible, setVisible] = useState(false);
const onConfirm = () => {
setVisible(false);
};
const CustomInput = () => {
return (
<View style={{ padding: 15, marginBottom: 10 }}>
<Text style={{ margin: 12, marginBottom: -18, color: "#000000" }}>
Comment
</Text>
<TextInput
placeholder="add your comment here..."
textAlignVertical="top"
multiline
style={{
height: 100,
margin: 12,
borderBottomWidth: 3,
borderBottomColor: "#000000",
color: "#FFFFFF",
fontSize: 22,
fontWeight: "700",
}}
/>
</View>
);
};
return (
<View style={styles.container}>
<ReactNativeDialogInput
visible={visible}
onVisible={setVisible}
isMessage
messagePosition="center"
messageFontSize={22}
message={
<>
<Text>React Native Dialog !</Text>
</>
}
onConfirm={onConfirm}
children={<CustomInput />}
backgroundColor="#FFF8E3"
/>
<Pressable
onPress={() => setVisible(true)}
style={{
width: "80%",
height: 50,
padding: 8,
borderRadius: 10,
backgroundColor: "blue",
}}
>
<Text
style={{
color: "white",
textAlign: "center",
fontSize: 22,
}}
>
Open Dialog Input
</Text>
</Pressable>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
