@@ -8,9 +8,10 @@ import {
8
8
Animated ,
9
9
Image
10
10
} from 'react-native' ;
11
+ import Modal from 'react-native-modal'
11
12
import { Text } from 'react-native-ui-kitten'
12
13
import { SafeAreaView } from 'react-navigation'
13
- import { FlatList , TouchableOpacity } from 'react-native-gesture-handler' ;
14
+ import { FlatList } from 'react-native-gesture-handler' ;
14
15
15
16
const WINDOW_WIDTH = Dimensions . get ( 'window' ) . width
16
17
const WINDOW_HEIGHT = Dimensions . get ( 'window' ) . height
@@ -32,7 +33,8 @@ class HomeScreen extends Component {
32
33
{ title : "Breaking Bad" , imageUrl : "https://www.thetvdb.com/banners/_cache/fanart/original/81189-1.jpg" } ,
33
34
] ,
34
35
activeImage : null ,
35
- showCloseIcon : false
36
+ showCloseIcon : false ,
37
+ isModalVisible : false
36
38
}
37
39
38
40
componentWillMount ( ) {
@@ -42,6 +44,48 @@ class HomeScreen extends Component {
42
44
this . dimensions = new Animated . ValueXY ( )
43
45
}
44
46
47
+ _renderEpisodeItem = ( { item, index } ) => {
48
+ const { title, imageUrl } = item
49
+
50
+ return (
51
+ < View style = { { flexDirection : 'row' , marginBottom : 10 } } >
52
+ < Image style = { { height : 100 , width : 100 , borderRadius : 12 } } source = { { uri : imageUrl } } />
53
+ < Text style = { { marginLeft : 20 , marginTop : 8 } } category = "h6" > { title } </ Text >
54
+
55
+ < Text
56
+ style = { { position : 'absolute' , right : 0 , marginTop : 12 } }
57
+ category = "h7" > $9.87</ Text >
58
+ </ View >
59
+ )
60
+ }
61
+
62
+ _showModal ( ) {
63
+ console . log ( "modal shown" , this . state . isModalVisible ) ;
64
+
65
+ return (
66
+ < View style = { { flex : 1 } } >
67
+ < Modal
68
+ style = { { margin : 0 , justifyContent : 'flex-end' } }
69
+ isVisible = { this . state . isModalVisible }
70
+ deviceHeight = { WINDOW_HEIGHT / 2 }
71
+ deviceWidth = { WINDOW_WIDTH }
72
+ >
73
+ < View style = { { height : WINDOW_HEIGHT / 1.8 , backgroundColor : 'white' } } >
74
+ < View style = { { marginLeft : 20 , marginRight : 20 , marginTop : 20 } } >
75
+ < Text style = { { marginBottom : 25 } } category = "h4" > Season 1 Episodes</ Text >
76
+ < FlatList
77
+ data = { this . state . images }
78
+ keyExtractor = { this . _keyExtractor }
79
+ renderItem = { this . _renderEpisodeItem }
80
+ />
81
+ { this . _showCloseIcon ( ) }
82
+ </ View >
83
+ </ View >
84
+ </ Modal >
85
+ </ View >
86
+ )
87
+ }
88
+
45
89
_openImage = ( index ) => {
46
90
const ref = this . allImagesRefs [ index ]
47
91
ref . measure ( ( x , y , width , height , pageX , pageY ) => {
@@ -84,6 +128,7 @@ class HomeScreen extends Component {
84
128
} )
85
129
] ) . start ( ( ) => {
86
130
this . setState ( { showCloseIcon : true } )
131
+ this . setState ( { isModalVisible : true } )
87
132
} )
88
133
} )
89
134
} )
@@ -118,6 +163,7 @@ class HomeScreen extends Component {
118
163
119
164
_closeImage = ( ) => {
120
165
this . setState ( { showCloseIcon : false } )
166
+ this . setState ( { isModalVisible : false } )
121
167
Animated . parallel ( [
122
168
Animated . timing ( this . position . x , {
123
169
toValue : this . oldPosition . x ,
@@ -182,9 +228,10 @@ class HomeScreen extends Component {
182
228
source = { { uri : this . state . activeImage ? this . state . activeImage . imageUrl : null } }
183
229
>
184
230
</ Animated . Image >
185
- { this . _showCloseIcon ( ) }
231
+
186
232
</ View >
187
233
</ View >
234
+ { this . _showModal ( ) }
188
235
</ SafeAreaView >
189
236
)
190
237
}
@@ -221,9 +268,9 @@ const styles = StyleSheet.create({
221
268
closeIcon : {
222
269
position : 'absolute' ,
223
270
right : 20 ,
224
- top : 40 ,
271
+ top : 20 ,
225
272
height : 32 ,
226
273
width : 32 ,
227
- tintColor : 'white '
274
+ tintColor : 'red '
228
275
}
229
276
} ) ;
0 commit comments