Deskripsi: - modal crash - input keyboard over lap - detail pengumuman text color - Scroll view tinggi 100 persen - image user nb : blm selesai semua
72 lines
2.8 KiB
TypeScript
72 lines
2.8 KiB
TypeScript
import Styles from "@/constants/Styles";
|
|
import { MaterialIcons } from "@expo/vector-icons";
|
|
import { Dimensions, KeyboardAvoidingView, Platform, Pressable, View } from "react-native";
|
|
import Modal from 'react-native-modal';
|
|
import Text from "./Text";
|
|
|
|
type Props = {
|
|
isVisible: boolean
|
|
setVisible: (value: boolean) => void
|
|
title?: string
|
|
children: React.ReactNode
|
|
animation?: 'slide' | 'none' | 'fade'
|
|
height?: number
|
|
backdropPressable?: boolean
|
|
keyboard?: boolean
|
|
}
|
|
|
|
export default function DrawerBottom({ isVisible, setVisible, title, children, animation, height, backdropPressable = true, keyboard = false }: Props) {
|
|
const tinggiScreen = Dimensions.get("window").height;
|
|
const tinggiInput = height != undefined ? height : 25
|
|
const tinggiFix = tinggiScreen * tinggiInput / 100;
|
|
|
|
return (
|
|
<Modal
|
|
animationIn={"slideInUp"}
|
|
animationOut={"slideOutDown"}
|
|
isVisible={isVisible}
|
|
onSwipeComplete={() => setVisible(false)}
|
|
swipeDirection="down"
|
|
hideModalContentWhileAnimating={true}
|
|
onBackdropPress={() => { setVisible(!backdropPressable) }}
|
|
style={[{ justifyContent: 'flex-end', margin: 0 }]}
|
|
animationOutTiming={500}
|
|
animationInTiming={500}
|
|
backdropTransitionInTiming={500}
|
|
backdropTransitionOutTiming={500}
|
|
useNativeDriverForBackdrop={true}
|
|
>
|
|
{
|
|
keyboard ?
|
|
<KeyboardAvoidingView
|
|
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
|
keyboardVerticalOffset={0}
|
|
>
|
|
<View style={[Styles.modalContentNew, { height: tinggiFix }]}>
|
|
<View style={[Styles.titleContainerNew]}>
|
|
<Text style={Styles.textDefault}>{title}</Text>
|
|
<Pressable onPress={() => setVisible(false)}>
|
|
<MaterialIcons name="close" color="black" size={22} />
|
|
</Pressable>
|
|
</View>
|
|
<View style={Styles.contentContainer}>
|
|
{children}
|
|
</View>
|
|
</View>
|
|
</KeyboardAvoidingView>
|
|
:
|
|
<View style={[Styles.modalContentNew, { height: tinggiFix }]}>
|
|
<View style={[Styles.titleContainerNew]}>
|
|
<Text style={Styles.textDefault}>{title}</Text>
|
|
<Pressable onPress={() => setVisible(false)}>
|
|
<MaterialIcons name="close" color="black" size={22} />
|
|
</Pressable>
|
|
</View>
|
|
<View style={Styles.contentContainer}>
|
|
{children}
|
|
</View>
|
|
</View>
|
|
}
|
|
</Modal>
|
|
)
|
|
} |