import React, { useEffect, useState } from 'react';
import { View, StyleSheet, TextInput, Text, ScrollView, FlatList, Pressable } from 'react-native';
import BootstrapModal from '@/components/BootstrapModal';
import { Appbar, Menu, Avatar, useTheme, Button } from 'react-native-paper';
import Icon from 'react-native-vector-icons/MaterialIcons';
import dpuser from "@/assets/images/userdp.png";
/** Some Temp Bullshits */
const dummyUserDataName = [
{
id: 1,
name: "AzmanHadi@PSK",
user_img: "https://t4.ftcdn.net/jpg/03/64/21/11/360_F_364211147_1qgLVxv1Tcq0Ohz3FawUfrtONzz8nq3e.jpg"
},
{
id: 2,
name: "NorMelati@PSK",
user_img: "https://www.shutterstock.com/image-photo/head-shot-portrait-millennial-beautiful-260nw-1893951241.jpg"
},
{
id: 3,
name: "RazuanKhan@PSK",
user_img: "https://plus.unsplash.com/premium_photo-1689568126014-06fea9d5d341?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8cHJvZmlsZXxlbnwwfHwwfHx8MA%3D%3D"
}
]
const Notification = () => {
const { colors, fonts } = useTheme();
const [menuVisible, setMenuVisible] = useState(false);
const [inputContent, setInputContent] = useState("");
const [pickedUser, setPickedUser] = useState(null);
const [userNameSearch, setUserNameSearch] = useState('');
const [visible, setVisible] = useState(true);
const [nameSuggestion, setNameSuggestion] = useState([])
const preTextClick = (pretext) => {
setInputContent(pretext)
}
const handleOnSearchUser = (e) => {
const value = e.target.value;
setUserNameSearch(value)
}
useEffect(() => {
if (userNameSearch.length > 0) {
let filteredData = dummyUserDataName.filter(
({ name }) => name.toLowerCase().includes(userNameSearch?.toLowerCase())
)
setNameSuggestion(filteredData);
} else {
setNameSuggestion([]);
}
}, [userNameSearch])
const renderUser = ({ item }) => (
{
setPickedUser(item);
setNameSuggestion([]);
setUserNameSearch("");
}}>
{item.name}
);
const renderUserBadge = (pickedUser) => {
return (
{pickedUser?.name}
{setPickedUser(null)}}>
)
}
return (
{/* Menu Component */}
To :
{pickedUser ? renderUserBadge(pickedUser) :
{
handleOnSearchUser(e)
}}
style={styles.userSearchInput}
/>
{(nameSuggestion.length > 0) &&
`${item?.id}`}
contentContainerStyle={styles.listContent}
/>
}
}
Select Pretext
{[
"Request to Work From Home",
"Request for late Check In",
"Request for early Check Out",
"Notify for Annual Leave",
"Notify for Emergency Leave"
].map(text => { preTextClick(text) }} style={[fonts.titleMedium, { marginBottom: 20, fontWeight: "bold", color: colors.secondary }]} >{text})}
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 20,
width: '100%',
},
textArea: {
height: 220,
borderColor: "#ccc",
borderWidth: 1,
padding: 10,
borderRadius: 8,
textAlignVertical: "top", // Makes text start from the top-left
backgroundColor: "#fff",
marginBottom: 20
},
badge: {
backgroundColor: "#BB5C3F",
color: "#FFF",
borderRadius: 100,
paddingVertical: 4,
paddingHorizontal: 6,
fontSize: 10,
fontWeight: "400",
verticalAlign: "middle",
marginStart: 5
},
userSearchInput: {
flex: 1,
paddingHorizontal: 20,
borderBottomColor: "rgba(0,0,0,0.2)",
borderBottomWidth: 1,
marginEnd: 20
},
nameListContainer: {
position: "absolute",
top: 25,
left: 0,
backgroundColor: "#FFF",
width: "100%",
paddingHorizontal: 10,
borderWidth: 2,
borderColor: "#CFCFCF"
},
listContent: {
paddingBottom: 10,
},
nameItem: {
paddingVertical: 6,
flex: 1,
flexDirection: "row"
},
nameText: {
marginLeft: 10,
fontSize: 16,
color: '#555',
},
titleContainer: {
flex: 1,
alignItems: 'center',
},
title: {
fontWeight: 'bold',
},
icon: {
padding: 10,
position: "absolute",
right: 10,
color: "#D9D9D9"
}
});
export default Notification;