88 lines
1.8 KiB
TypeScript
88 lines
1.8 KiB
TypeScript
import React from "react";
|
|
import {
|
|
View,
|
|
Text,
|
|
StyleSheet,
|
|
Modal,
|
|
Pressable,
|
|
StyleProp,
|
|
ViewStyle,
|
|
} from "react-native";
|
|
import { StatusBar } from "expo-status-bar";
|
|
import CloseIcon from "../../assets/icons/close.svg";
|
|
|
|
type Props = {
|
|
visible: boolean;
|
|
onClose: () => void;
|
|
heading: string;
|
|
children: React.ReactNode;
|
|
containerStyle?: StyleProp<ViewStyle>;
|
|
};
|
|
|
|
const BottomSheetModal: React.FC<Props> = ({
|
|
visible,
|
|
onClose,
|
|
heading,
|
|
children,
|
|
containerStyle,
|
|
}) => {
|
|
return (
|
|
<Modal visible={visible} animationType="fade" transparent>
|
|
<StatusBar style="dark" />
|
|
<View style={styles.overlay}>
|
|
<View style={[styles.modalContainer, containerStyle]}>
|
|
<View style={styles.header}>
|
|
<Text style={styles.headerText}>{heading}</Text>
|
|
<Pressable onPress={onClose} style={styles.iconButton}>
|
|
<CloseIcon />
|
|
</Pressable>
|
|
</View>
|
|
<View style={styles.content}>{children}</View>
|
|
</View>
|
|
</View>
|
|
</Modal>
|
|
);
|
|
};
|
|
|
|
export default BottomSheetModal;
|
|
|
|
const styles = StyleSheet.create({
|
|
overlay: {
|
|
flex: 1,
|
|
justifyContent: "flex-end",
|
|
backgroundColor: "rgba(0,0,0,0.5)",
|
|
},
|
|
modalContainer: {
|
|
backgroundColor: "#fff",
|
|
borderTopLeftRadius: 12,
|
|
borderTopRightRadius: 12,
|
|
paddingHorizontal: 16,
|
|
paddingVertical: 16,
|
|
},
|
|
header: {
|
|
borderBottomWidth: 1,
|
|
borderBottomColor: "#E5E9F0",
|
|
paddingHorizontal: 16,
|
|
paddingVertical: 8,
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
justifyContent: "space-between",
|
|
},
|
|
headerText: {
|
|
fontSize: 14,
|
|
fontWeight: "600",
|
|
color: "#252A34",
|
|
},
|
|
iconButton: {
|
|
width: 40,
|
|
height: 40,
|
|
padding: 10,
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
},
|
|
content: {
|
|
paddingVertical: 16,
|
|
gap: 16,
|
|
},
|
|
});
|