import React, {useState} from 'react';
import {View, Text, TouchableOpacity} from 'react-native';
import {CometChatUserPresence} from '../cometchat-pro-react-native-ui-kit';
export default function CometChatUserPresenceView({user}) {
const [status, setStatus] = useState(user.status);
return (
<View style={{flex: 1, justifyContent: 'center'}}>
<View
style={{
margin: '10%',
elevation: 5,
backgroundColor: '#fff',
padding: '5%',
alignItems: 'center',
borderRadius: 5,
}}>
<Text style={{fontWeight: 'bold', fontSize: 26, marginBottom: '5%'}}>
CometChatUserPresence
</Text>
<View
style={{
flexDirection: 'row',
justifyContent: 'space-evenly',
width: '100%',
}}>
<TouchableOpacity
onPress={() => setStatus('online')}
style={{
justifyContent: 'center',
alignItems: 'center',
padding: 10,
backgroundColor: 'lightgreen',
}}>
<Text>Online</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => setStatus('')}
style={{
justifyContent: 'center',
alignItems: 'center',
padding: 10,
backgroundColor: '#707070',
}}>
<Text>Offline</Text>
</TouchableOpacity>
</View>
<View style={{position: 'relative'}}>
<CometChatUserPresence
status={status}
borderWidth={0.5}
borderColor={'red'}
cornerRadius={0}
/>
</View>
<Text style={{marginTop: '15%', textAlign: 'center'}}>
This view will be used to show the user status if the user is online
or offline. This view will take user status and display the color
accordingly
</Text>
</View>
</View>
);
}