mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 20:15:11 +00:00
3ee3d2b4b2
Summary: Basic template using 'react-navigation' to make it easy to get started. Not duplicating all the files in `android` and `ios` folders. These will be taken from the `HelloWorld` template. Let's not duplicate all of these files (it's a lot and they are large, especially the Xcode projects). **Test plan (required)** The app works locally. This PR is just a preparation for a next PR that will add support for 'react-native init --template Navigation'. Will have a proper test plan there. Closes https://github.com/facebook/react-native/pull/12153 Differential Revision: D4494776 Pulled By: mkonicek fbshipit-source-id: b43eafd7a1424477f9493a3eb4083ba4dd3d3846
69 lines
1.4 KiB
JavaScript
69 lines
1.4 KiB
JavaScript
import React, { Component } from 'react';
|
|
import {
|
|
Image,
|
|
ListView,
|
|
Platform,
|
|
StyleSheet,
|
|
} from 'react-native';
|
|
import ListItem from '../../components/ListItem';
|
|
|
|
export default class ChatListScreen extends Component {
|
|
|
|
static navigationOptions = {
|
|
title: 'Chats',
|
|
header: {
|
|
visible: Platform.OS === 'ios',
|
|
},
|
|
tabBar: {
|
|
icon: ({ tintColor }) => (
|
|
<Image
|
|
// Using react-native-vector-icons works here too
|
|
source={require('./chat-icon.png')}
|
|
style={[styles.icon, {tintColor: tintColor}]}
|
|
/>
|
|
),
|
|
},
|
|
}
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
|
|
this.state = {
|
|
dataSource: ds.cloneWithRows([
|
|
'Claire', 'John'
|
|
])
|
|
};
|
|
}
|
|
|
|
// Binding the function so it can be passed to ListView below
|
|
// and 'this' works properly inside _renderRow
|
|
_renderRow = (name) => {
|
|
return (
|
|
<ListItem
|
|
label={name}
|
|
onPress={() => this.props.navigation.navigate('Chat', {name: name})}
|
|
/>
|
|
)
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<ListView
|
|
dataSource={this.state.dataSource}
|
|
renderRow={this._renderRow}
|
|
style={styles.listView}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
listView: {
|
|
backgroundColor: 'white',
|
|
},
|
|
icon: {
|
|
width: 30,
|
|
height: 26,
|
|
},
|
|
});
|