import React, { useEffect, useState } from 'react'; import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { addParticipants } from '../../store/bubbles/bubblesSlice'; import { ParticipantsListView } from '../common/ParticipantsListView'; import { Strings } from '../../resources/localization/Strings'; import { Header } from '../common/Header'; import { AddParticipantsNavigationProp, AddParticipantsRouteProp } from '../../RootStackParamList'; import { useAppDispatch, useAppSelector } from '../../store/hooks'; import { IPeer } from '../../store/peer/types'; interface IProps { navigation: AddParticipantsNavigationProp; route: AddParticipantsRouteProp } export const AddParticipant: React.FunctionComponent = ({ route, navigation }) => { const bubbleId = route.params.bubbleId; const dispatch = useAppDispatch(); const bubblesMembers = useAppSelector((state) => state.bubbles.bubblesMembers); const contacts = useAppSelector((state) => state.contacts.contacts); const [selectedContacts, setSelectedContacts] = useState([]); const [contactsToAdd, setContactsToAdd] = useState([]); const updateContacts = (selectedContactsID: string[]) => { setSelectedContacts(selectedContactsID); }; useEffect(() => { const filterResult = contacts.filter((item: IPeer) => { return !bubblesMembers.find((element: IPeer) => { return element.jId === item.jId; }); }); setContactsToAdd(filterResult ); }, [bubblesMembers, contacts]); const close = () => { navigation.pop() } const add = () => { if (selectedContacts.length > 0) { dispatch(addParticipants({bubbleId, contactsJid: selectedContacts})) close(); } } const renderLeftHeader = () => { return ( {Strings.cancel} ) } const renderCenterHeader = () => { return {Strings.Attendees} ; } const renderRightHeader = () => { return ( 0 ? styles.headerComponentStyle : styles.inActiveIcon}>{Strings.Add} ) } return (
); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#ffffff', height: 'auto', }, Thumbnail: { width: 30, height: 30, }, headerBgColor: { backgroundColor: '#0086CF', }, editBubbleView: { display: 'flex', flexDirection: 'row', justifyContent: 'space-around', }, inActiveIcon: { color: '#a9c0ef', fontSize: 17 }, headerComponentStyle: { color: 'white', fontSize: 17, alignSelf: 'center', }, fontStyle:{ color: 'white', fontSize: 16, } });