-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Théo mathieu
committed
Mar 25, 2016
1 parent
1b5d839
commit afdc729
Showing
4 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters