Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. export default class List extends React.Component {
  2.  
  3. constructor(props) {
  4.  
  5. super(props)
  6. this.state = {
  7. counter: 1,
  8. fontLoaded: false,
  9. isFav : false,
  10. };
  11. AsyncStorage.getItem('kobitaDB').then((data) => {
  12. newData = JSON.parse(data)
  13. console.log("Favourite dataaa:",newData.length)
  14. if (0 < newData.length) {
  15.  
  16. this.setState({dataSource: ds.cloneWithRows(newData),isFav:true})
  17.  
  18. }
  19.  
  20. });
  21. }
  22.  
  23.  
  24.  
  25. async componentWillMount() {
  26.  
  27.  
  28.  
  29. await Font.loadAsync({
  30. 'CharukolaUltraLight': require('../assets/fonts/CharukolaUltraLight.ttf'),
  31. });
  32.  
  33.  
  34.  
  35. this.setState({ fontLoaded: true });
  36. }
  37.  
  38.  
  39.  
  40.  
  41. render() {
  42.  
  43.  
  44. return (
  45.  
  46. <View style={styles.container}>
  47. <View style={{ alignItems: 'center', backgroundColor: "#12CC7B", padding: 10 }}>
  48. {
  49. this.state.fontLoaded ? (
  50. <Text style={{ fontSize: 20, color: '#fff', fontFamily: 'CharukolaUltraLight' }}> প্রিয় কবিতা </Text>
  51. ) : null
  52.  
  53. }
  54. </View>
  55. {
  56. this.state.isFav ? (
  57. <ListView
  58. dataSource={this.state.dataSource}
  59. renderRow={(rowData) => this._renderScene(rowData)}
  60. />
  61. ) : (<Text> No Favourite Items Found! </Text>)
  62.  
  63. }
  64. </View>
  65. );
  66. }
  67.  
  68. _renderScene(rowData) {
  69. return (
  70. <TouchableWithoutFeedback onPress={() => this.props.navigation.navigate('singleFav', {fontLoaded: this.state.fontLoaded, title: rowData.title, body: rowData.body })}>
  71. <View style={{ alignItems: 'center', paddingTop: 20, paddingBottom: 20, flexDirection: 'row', borderBottomWidth: 1, borderColor: '#f7f7f7' }}>
  72. {
  73. this.state.fontLoaded ? (
  74. <Text style={{ marginLeft: 15,fontFamily:'CharukolaUltraLight',fontSize:20 }}>{this.state.counter++} { rowData.title}</Text>
  75. ) : null
  76. }
  77. </View>
  78. </TouchableWithoutFeedback>)
  79. }
  80.  
  81. }
  82.  
  83. const styles = StyleSheet.create({
  84. container: {
  85. flex: 1,
  86. backgroundColor: '#fff',
  87. },
  88. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement