Skip to content

Commit

Permalink
Updated example app
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo mathieu committed Mar 25, 2016
1 parent 1b5d839 commit afdc729
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 8 deletions.
85 changes: 85 additions & 0 deletions example/mobile/app/Routes/FullTodos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
'use strict';

console.disableYellowBox = true;


import React, {
Component,
StyleSheet,
Text,
View,
TouchableOpacity
} from 'react-native';

import Meteor, { connectMeteor, MeteorListView } from 'react-native-meteor';
import Button from 'react-native-button';
import Icon from 'react-native-vector-icons/MaterialIcons';

@connectMeteor
export default class FullTodos extends Component {
constructor(props) {
super(props);

this.state = {
done: false
};
}
startMeteorSubscriptions() {
Meteor.subscribe('todos');
}
changeDone() {
this.setState({done: !this.state.done});
}
renderItem(todo) {
return (
<View key={todo._id} style={styles.item}>
<Text style={{flex: 1}}>{todo.title}</Text>
</View>
)
}
render() {
const { done } = this.state;

return (
<View style={styles.container}>
<View style={styles.buttonsContainer}>
<Button containerStyle={styles.button} style={styles.buttonText} onPress={this.changeDone.bind(this)} >
{done && 'Done'}
{!done && 'Undone'}
</Button>
</View>
<MeteorListView
collection="todos"
selector={{done: done}}
renderRow={this.renderItem.bind(this)}
/>
</View>
);
}
}


const styles = StyleSheet.create({
container: {
flex: 1
},
item: {
flex: 1,
flexDirection: 'row'
},
buttonsContainer: {
marginTop: 25,
marginHorizontal: 10
},
button: {
paddingVertical: 8,
height:40,
overflow:'hidden',
borderRadius:4,
backgroundColor: '#00BC8C',
marginBottom: 5
},
buttonText: {
fontSize: 18, color: 'white'
}
});
6 changes: 0 additions & 6 deletions example/mobile/app/Routes/Todos.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ class Todos extends Component {
done: false
};
}
getMeteorData() {
return {
todos: Meteor.collection('todos').find()
};
}
startMeteorSubscriptions() {
Meteor.subscribe('todos', this.state.done);
}
Expand Down Expand Up @@ -73,7 +68,6 @@ class Todos extends Component {
)
}
render() {
const { todos } = this.data;
const { done } = this.state;

return (
Expand Down
10 changes: 9 additions & 1 deletion example/mobile/app/Tabs.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import React, {
import Icon from 'react-native-vector-icons/MaterialIcons';

import Todos from './Routes/Todos';
import FullTodos from './Routes/FullTodos';
import CollectionFS from './Routes/CollectionFS';
import Status from './Routes/Status';
import Settings from './Routes/Settings';
Expand All @@ -19,7 +20,7 @@ export default class Tabs extends Component {
constructor(props) {
super(props);
this.state = {
selectedTab: 1
selectedTab: 4
};
}
selectTab(index) {
Expand Down Expand Up @@ -59,6 +60,13 @@ export default class Tabs extends Component {
onPress={this.selectTab.bind(this, 3)}>
<Settings />
</Icon.TabBarItem>
<Icon.TabBarItem
iconName="list"
title="Full Todos"
selected={selectedTab === 4}
onPress={this.selectTab.bind(this, 4)}>
<FullTodos />
</Icon.TabBarItem>
</TabBarIOS>
);
}
Expand Down
2 changes: 1 addition & 1 deletion example/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"react-native": "^0.21.0",
"react-native-android-tablayout": "^0.2.0",
"react-native-button": "^1.4.2",
"react-native-meteor": "^1.0.0-beta15",
"react-native-meteor": "^1.0.0-beta20",
"react-native-vector-icons": "^1.2.1"
},
"devDependencies": {
Expand Down

0 comments on commit afdc729

Please sign in to comment.