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
}
}
+17 -13
View File
@@ -11,6 +11,8 @@ 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;
@@ -21,19 +23,19 @@ export default class Navbar extends Component<Props> {
return (
<View style={styles.container}>
<View style={styles.iconCont}>
<Image
style={styles.menuIcon}
source={require('../../assets/images/menuIcon.png')}
<Icon
name='menu'
style={styles.menuIcon}
/>
</View>
<View style={styles.headerTxt}>
<Text style={styles.head}>Main Chat</Text>
<Text style={styles.head}>Chat</Text>
<Text style={styles.status}>online</Text>
</View>
<View style={styles.iconCont}>
<Image
style={styles.inboxIcon}
source={require('../../assets/images/inboxIcon.jpg')}
<Icon
name='inbox'
style={styles.inboxIcon}
/>
</View>
</View>
@@ -54,8 +56,8 @@ const styles = {
justifyContent: 'center'
},
menuIcon: {
height: 50,
width: 50
fontSize: 30,
color: 'white'
},
headerTxt: {
flex: 7,
@@ -64,14 +66,16 @@ const styles = {
},
head: {
fontSize: 20,
color: 'white'
color: 'white',
fontFamily: Fonts.Sunflower
},
status: {
fontSize: 13,
color: 'white'
color: 'white',
fontFamily: Fonts.Sunflower
},
inboxIcon: {
height: 40,
width: 40
fontSize: 25,
color: 'white'
}
}