Added many things:

- properly importing fonts with assets folders
- properly getting material icons with react-native-vector-icons
- figuring out how messages with display
- fixing keyboard bringing up other Views
- function for getting user input into TextInput
This commit is contained in:
Arjun Patel
2018-05-26 17:02:15 -07:00
parent 327911a8d5
commit 59a3bc7e7d
35 changed files with 292 additions and 36 deletions
+63 -7
View File
@@ -12,16 +12,58 @@ import {
import {
Actions
} from 'react-native-router-flux';
import Icon from 'react-native-vector-icons/MaterialIcons';
import { Fonts } from '../../utils/Fonts.js';
const windowWidth = Dimensions.get('window').width;
const windowHeight = Dimensions.get('window').height;
type Props = {};
export default class Chat extends Component<Props> {
constructor(props) {
super(props);
var exMessages = [
{
id: 1,
text: "hey anyone wanna study 61A"
},
{
id: 2,
text: "Yea im down"
}
];
this.state = {
messageToSend : '',
messagesDOM: exMessages.map(
(msg) => <View key={msg.id}><Text>{msg.text}</Text></View>
)
};
}
messageInput = (text) => {
console.log('changing state of messageToSend');
this.setState({
messageToSend : text
});
console.log(this.state.messageToSend);
}
render() {
console.log(this.state.messagesDOM);
return (
<View style={styles.container}>
<View style={styles.chatField}>
<View style={this.state.messagesDOM.length == 0 ?
styles.chatField : styles.chatFieldEmpty}>
{this.state.messagesDOM.length == 0 ?
(<View style={styles.emptyMsg}>
<Text>No one's talkin around you! Start it up!</Text>
</View>)
:
(<View>
{this.state.messagesDOM}
</View>)
}
</View>
<View style={styles.inputMsgField}>
@@ -30,13 +72,15 @@ export default class Chat extends Component<Props> {
</View>
<View style={styles.inputCont}>
<TextInput
placeholder="Type message..."
style={styles.inputField}
placeholder="Type a message..."
onChangeText={this.messageInput}
/>
</View>
<View style={styles.iconCont}>
<Image
<Icon
name='send'
style={styles.sendIcon}
source={require('../../assets/images/sendIcon.png')}
/>
</View>
</View>
@@ -53,8 +97,17 @@ const styles = {
backgroundColor: '#e8ebef'
},
chatField: {
flex: 8
flex: 8,
flexDirection: 'column',
justifyContent: 'flex-end',
alignItems: 'center'
},
chatFieldEmpty: {
flex: 8,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center'
},
inputMsgField: {
flex: 1,
flexDirection: 'row',
@@ -72,8 +125,11 @@ const styles = {
flex: 6,
alignSelf: 'flex-end'
},
inputField : {
fontSize: 18,
fontFamily: Fonts.SunflowerLight
},
sendIcon: {
height: 30,
width: 30
fontSize: 25
}
}