1
1
import React from 'react' ;
2
- import { View , Text , StyleSheet , FlatList } from 'react-native' ;
3
- import { gray , black } from '../utils/colors' ;
2
+ import { View , Text , StyleSheet , FlatList , TouchableOpacity } from 'react-native' ;
3
+ import { gray , black , white } from '../utils/colors' ;
4
4
import { getAllDecks } from '../api' ;
5
5
6
6
export default class DecksList extends React . Component {
@@ -9,8 +9,12 @@ export default class DecksList extends React.Component {
9
9
this . state = { decks : [ ] } ;
10
10
}
11
11
12
+ componentDidMount ( ) {
13
+ this . loadDecks ( ) ;
14
+ }
15
+
12
16
componentWillReceiveProps ( nextProps ) {
13
- if ( nextProps . screenProps . currentScreen === 'Decks ' ) {
17
+ if ( nextProps . screenProps . currentScreen === 'DecksList ' ) {
14
18
this . loadDecks ( ) ;
15
19
}
16
20
}
@@ -23,17 +27,20 @@ export default class DecksList extends React.Component {
23
27
style = { styles . container }
24
28
data = { this . state . decks }
25
29
keyExtractor = { ( item , index ) => index }
26
- renderItem = { ( { item } ) => < Deck key = { item . title } { ...item } /> }
30
+ renderItem = { ( { item } ) => < Deck key = { item . title } { ...item } screenProps = { { ... this . props } } /> }
27
31
/>
28
32
) ;
29
33
}
30
34
}
31
35
32
36
const Deck = props => (
33
- < View style = { styles . deck } >
37
+ < TouchableOpacity
38
+ style = { styles . deck }
39
+ onPress = { ( ) => props . screenProps . navigation . navigate ( 'DeckDetail' , { deckId : props . title } ) }
40
+ >
34
41
< Text style = { styles . deckTitle } > { props . title } </ Text >
35
42
< Text style = { styles . deckCards } > { props . questions . length } Cards</ Text >
36
- </ View >
43
+ </ TouchableOpacity >
37
44
) ;
38
45
39
46
const styles = StyleSheet . create ( {
@@ -44,8 +51,9 @@ const styles = StyleSheet.create({
44
51
height : 100 ,
45
52
justifyContent : 'center' ,
46
53
alignItems : 'center' ,
47
- borderBottomWidth : 2 ,
48
- borderBottomColor : black
54
+ borderBottomWidth : 1 ,
55
+ borderBottomColor : gray ,
56
+ backgroundColor : white
49
57
} ,
50
58
deckTitle : {
51
59
fontSize : 20
0 commit comments