-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
222 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React, { useEffect } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import { Text, View, TextInput, TouchableOpacity } from 'react-native'; | ||
import styles from './localStyles/mainStyles'; | ||
|
||
const ChatComponent = ({chatInfo: { selectedUser }, friendsInfo: { users }}) => { | ||
useEffect(() => { | ||
//console.log(chatInfo) | ||
}, []) | ||
return ( | ||
<View style={styles.chatContainer}> | ||
<View style={styles.userInfo}> | ||
<Text style={styles.userName}> | ||
{ users.map(user => { | ||
if (user.uid === selectedUser ) return user.dname | ||
})} | ||
</Text> | ||
</View> | ||
<View style={styles.messages}> | ||
<Text></Text> | ||
</View> | ||
<View style={styles.inputContainer}> | ||
<TextInput | ||
style={styles.input} | ||
placeholder="type message..." | ||
/> | ||
<TouchableOpacity style={styles.button} > | ||
<Text style={styles.buttonText}>Send</Text> | ||
</TouchableOpacity> | ||
</View> | ||
</View> | ||
) | ||
} | ||
|
||
ChatComponent.propTypes = { | ||
genInfo: PropTypes.object.isRequired, | ||
chatInfo: PropTypes.object.isRequired, | ||
friendsInfo: PropTypes.object.isRequired | ||
} | ||
|
||
const mapStateToProps = state => { | ||
return { | ||
genInfo: state.genInfo, | ||
loginInfo: state.loginInfo, | ||
friendsInfo: state.friendsInfo, | ||
chatInfo: state.chatInfo | ||
} | ||
} | ||
|
||
const mapDispatchToProps = dispatch => { | ||
return { | ||
getUsers: () => { | ||
dispatch(fetchUsers()); | ||
}, | ||
getFriends: info => { | ||
dispatch(fetchFriends(info)); | ||
}, | ||
logingStatusConfirmation: (confirmLoggedIn, loginInfo) => { | ||
dispatch(checkLoginStatus(confirmLoggedIn, loginInfo)); | ||
}, | ||
openSocket: props => { | ||
dispatch(connectToChatServer(props)); | ||
}, | ||
confirmLoggedIn: () => { | ||
dispatch(loginConfirmed()); | ||
}, | ||
signOut: genInfo => { | ||
dispatch(logout(genInfo)); | ||
}, | ||
updateGenInfo: genInfo => { | ||
dispatch(dispatchedGenInfo(genInfo)); | ||
} | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(ChatComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { StyleSheet } from 'react-native'; | ||
|
||
const styles = StyleSheet.create({ | ||
chatContainer: { | ||
height: '100%', | ||
display: 'flex', | ||
flexDirection: 'column' | ||
}, | ||
input: { | ||
display: 'block', | ||
flex: 8, | ||
padding: 3, | ||
borderWidth: 1.5, | ||
borderColor: '#D4D4D4', | ||
borderRadius: 3, | ||
height: 50, | ||
}, | ||
userInfo: { | ||
flex: 1 | ||
}, | ||
userName: { | ||
textTransform: 'capitalize' | ||
}, | ||
messages: { | ||
flex: 2, | ||
minHeight: 50 | ||
}, | ||
inputContainer: { | ||
display: 'flex', | ||
flex: 1, | ||
flexDirection: 'row' | ||
}, | ||
button: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
borderRadius: 3, | ||
marginLeft: 10, | ||
backgroundColor: '#16B5F2' | ||
}, | ||
buttonText: { | ||
alignText: 'center', | ||
color: '#fff' | ||
} | ||
}); | ||
|
||
export default styles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import { | ||
FETCH_ONLINE_USERS_PENDING, | ||
FETCH_ONLINE_USERS_FULFILLED, | ||
FETCH_ONLINE_USERS_ERROR, | ||
FETCH_MESSAGES_PENDING, | ||
FETCH_MESSAGES_FULFILLED, | ||
FETCH_MESSAGES_ERROR | ||
SET_USER_TO_CHAT | ||
} from '../types'; | ||
|
||
export const fetchedUsersOnline = users => { | ||
return { | ||
type: FETCH_ONLINE_USERS_FULFILLED, | ||
payload: users | ||
} | ||
} | ||
export const setUserToChat = userId => { | ||
return { | ||
type: SET_USER_TO_CHAT, | ||
payload: userId | ||
} | ||
} |
Oops, something went wrong.