mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 20:15:11 +00:00
a54d449e94
Summary: Currently it is not trivial for people to get started with React Native. `react-native init MyApp` just creates a simple app with a single screen. People have to spend time figuring out how to add more screens, or how to accomplish very basic tasks such as rendering a list of data or handling text input. Let's add an option: `react-native init --template navigation` - this creates a "starter" app which can be easily tweaked into the actual app the person wants to build. **Test plan (required)** - Checked that 'react-native init MyApp' still works as before: <img width="487" alt="screenshot 2017-02-02 16 56 28" src="https://cloud.githubusercontent.com/assets/346214/22559344/b2348ebe-e968-11e6-9032-d1c33216f490.png"> <img width="603" alt="screenshot 2017-02-02 16 58 04" src="https://cloud.githubusercontent.com/assets/346214/22559370/c96a2ca6-e968-11e6-91f7-7afb967920fc.png"> - Ran 'react-native init MyNavApp --template'. This prints the available templates: ``` $ react-native init MyNavApp Closes https://github.com/facebook/react-native/pull/12170 Differential Revision: D4516241 Pulled By: mkonicek fbshipit-source-id: 8ac081157919872e92947ed64ea64fb48078614d
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: 'Friends',
|
|
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,
|
|
},
|
|
});
|