리액트 네이티브 자바 스크립트 채팅방 다수 친구 초대 기능

리액트 네이티브 자바 스크립트 채팅방 다수 친구 초대 기능

작성일 2023.04.21댓글 0건
    게시물 수정 , 삭제는 로그인 필요

리액트 네이티브 
친구 목록에서 체크 박스를 만들어 체크한 친구들을 채팅 방에 초대할 수 있는 기능의 코드를 알려주세요
체크한 유저들을 채팅 초대 버튼을 눌렀을 때 연결되는 코드가 필요한 것 같습니다.
다음은 현재까지 구현한 코드와 화면 입니다.
수정해야하는 부분이 있으면 알려주세요

import React, { useState, useEffect, useContext, use } from 'react';
import { View, Text, FlatList, StyleSheet, TouchableOpacity, Pressable, Button } from 'react-native';
import firestore from '@react-native-firebase/firestore';
import { friendIdSearch } from '../lib/friends';
import { fromIdtoUser, getUserId } from '../lib/user';
import { useUserContext } from '../../context/UserContext';
import Avatar from '../../components/Avatar';
import {useNavigation, useNavigationState} from '@react-navigation/native'
import InviteButton from './InviteButton';
import BouncyCheckbox from "react-native-bouncy-checkbox";
import RNBounceable from "@freakycoder/react-native-bounceable";

const InviteFriends = () => {
  console.log('InviteFriends');
  const {user, setUser} = useUserContext();
  const [friendArray, setFriendArray] = useState([]);
  const [ isLoading, setIsLoading ] = useState(false);
  const [idDoc, setIddoc] = useState([]);
  let data = [];
  const navigation = useNavigation();
  let bouncyCheckboxRef = null;
  const [checkboxState, setCheckboxState] = React.useState(false);
  useEffect(() => {
   
    if(!isLoading){
      // 프렌즈 컬렉션 : 내 id => id 배열 값 가져오기
     firestore().collection('friends').get().then(function (querySnapshot){
      querySnapshot.forEach(function (doc) {
          if (doc.id == user.id){
              //console.log(doc.id, '=>', doc.data().id);
              setFriendArray(doc.data().id);
          }      
      });
    });
  }
  if(friendArray !== [])
    userData().then(() => {

   
    });

  }, [user, friendArray, setIsLoading, setIddoc]);

  const userData = async() => {
   
     friendArray.forEach( async (id) => {
 
      firestore().collection('user').doc(id).get()
      .then((snapshot) => {
        data.push(snapshot.data())
        //setIddoc(data)
        if(data.length === friendArray.length){
          setIddoc(data)
          setIsLoading(true);
        }        
      });
    })

  }
  const renderItem = ({item}) =>{
 
    return (
        <Pressable style ={styles.item}
        onPress={()=>  navigation.navigate('UserProfile', {
          userInfo: item,
        })}>
          <Avatar style={styles.PhotoImage} source={item.photoURL && {uri: item.photoURL}} />
          <Text style = {styles.title}>{item.displayName}</Text>
          <View style={styles.container}>
      <BouncyCheckbox
          style={{ marginTop: 10 }}
          justifyContent='flex-end'
          isChecked={checkboxState}
          size={25}
          fillColor="#2E9AFE"
         onPress={() => setCheckboxState(!checkboxState)}        
      />  
    </View>
        </Pressable>
    )
  }

  if(isLoading){
    return (
      <View>
        <Text style={styles.displayName}>친구</Text>
        <FlatList
          data ={idDoc}
          renderItem= {renderItem}
          keyExtractor ={(item) => item.id}
          />
          <RNBounceable
        style={{
          marginTop: 16,
          height: 50,
          width: "100%",
          backgroundColor: "#2E9AFE",
          borderRadius: 12,
          alignItems: "center",
          justifyContent: "center",
        }}
        onPress={() => bouncyCheckboxRef?.onPress(InviteButton)}
      >
        <Text style={{ color: "#fff" }}>채팅 초대</Text>
      </RNBounceable>
      </View>
    );
  };
}

const styles = StyleSheet.create({
  block: {flex: 1},
  separator: {
      backgroundColor: "#e0e0e0",
      height: 1,
      width: "100%",
  },
  container: {
    flex: 1,
  },
  item: {
    backgroundColor: '#e0e0e0',
    padding: 15,
    marginVertical: 3,
    marginHorizontal: 16,
    flexDirection: 'row',
    alignItems: 'center',
  },
  PhotoImage: {
    marginRight: 10,
  },
  displayName: {
    padding: 10,
    lineHeight: 16,
    fontSize: 18,
    marginLeft: 8,
    fontWeight: 'bold',
  },
});
export default InviteFriends;




#리액트 네이티브 #리액트 네이티브 지원 중단 #리액트 네이티브 vs 플러터 #리액트 네이티브 앱 만들기 #리액트 네이티브 설치 #리액트 네이티브 전망 #리액트 네이티브 웹뷰 #리액트 네이티브 강의 #리액트 네이티브 시작하기 #리액트 네이티브 플러터

카카오톡 이용자보호조치 관련 문제

... 다수채팅방을 생성할 수 없거나 다수친구초대할 수 없습니다. 잠시 후 다시... 위한 기능이라고 생각하시면 좋습니다 카톡 어플리케이션상의 오류같은이유로...

카카오톡 다수의 숨김친구를 한꺼번에...

... 있는 기능은 아쉽지만, 없습니다. 게임초대의 경우는 친구만 받기가 가능하지만... 또하나의 방법은 카카오톡을 탈퇴 후 재가입하게 되면, 단순히 채팅방으로 친구로 등록된...

카카오톡의 문제점

... 자동 친구 등록 기능 때문에 굳이 친한 사이가 아닌 경우... 세 번째로 카카오톡 감옥은 카톡의 그룹 채팅 기능을 이용해 100명 이상의 불특정다수를 한 채팅방초대해...

신입 프로그래머 수준

... 바닐라 자바스크립트, Jquery, Node.js(npm), yarn, JSP, React.js... 하지만 아직 모르는 라이브러리나 기능이 너무 많네요.... 그래도 리액트 네이티브를 이용해 하이브리드 모바일...

학교폭력 상대방의 지속적인 갈굼과...

... 자기 친구들 있는 카카오톡 단톡채팅방초대해서 욕을... 현재 학교에 자녀를 보내는 부모나 학생들 대다수가... 사회적 기능에 큰 지장 을 초래하기도 합니다. 때문에...

카카오톡 단점에대한 근거

... 읽었는데 답장은 안해 친구관계 하락 3.공부에 방해가됨 등등.... 세 번째로 카카오톡 감옥은 카톡의 그룹 채팅 기능을 이용해 100명 이상의 불특정다수를 한 채팅방초대해...

디아블로3

... 친구들이나 클랜 분, 최근 같이 했던 플레이어들끼리는 비공개방에서도 파티초대, 참가 기능을 통해서 같이... ㅋㅋ 불특정다수가 모인 채팅방은 더더욱 그렇죠.