1
1
import _ from 'lodash' ;
2
2
import React , { Component } from 'react' ;
3
3
import { StyleSheet , ScrollView , LayoutAnimation } from 'react-native' ;
4
- import { Colors , Typography , View , Drawer , Text , Button , ListItem , Avatar , AvatarHelper } from 'react-native-ui-lib' ; //eslint-disable-line
4
+ import {
5
+ Assets ,
6
+ Colors ,
7
+ Typography ,
8
+ View ,
9
+ Drawer ,
10
+ Text ,
11
+ Button ,
12
+ Avatar ,
13
+ } from 'react-native-ui-lib' ; //eslint-disable-line
5
14
import { gestureHandlerRootHOC } from 'react-native-gesture-handler' ;
6
15
import conversations from '../../data/conversations' ;
7
16
8
- import { renderBooleanOption , renderSliderOption , renderColorOption } from '../ExampleScreenPresenter' ;
17
+ import {
18
+ renderBooleanOption ,
19
+ renderSliderOption ,
20
+ renderColorOption ,
21
+ } from '../ExampleScreenPresenter' ;
9
22
10
23
const ITEMS = {
11
- read : { icon : require ( '../../assets/icons/mail.png' ) , text : 'Read' , background : Colors . green30 } ,
12
- archive : { icon : require ( '../../assets/icons/archive.png' ) , text : 'Archive' , background : Colors . blue30 } ,
13
- delete : { icon : require ( '../../assets/icons/delete.png' ) , text : 'Delete' , background : Colors . red30 }
24
+ read : {
25
+ icon : require ( '../../assets/icons/mail.png' ) ,
26
+ text : 'Read' ,
27
+ background : Colors . green30 ,
28
+ } ,
29
+ archive : {
30
+ icon : require ( '../../assets/icons/archive.png' ) ,
31
+ text : 'Archive' ,
32
+ background : Colors . blue30 ,
33
+ } ,
34
+ delete : {
35
+ icon : require ( '../../assets/icons/delete.png' ) ,
36
+ text : 'Delete' ,
37
+ background : Colors . red30 ,
38
+ } ,
14
39
} ;
15
40
16
41
class DrawerScreen extends Component {
@@ -22,53 +47,30 @@ class DrawerScreen extends Component {
22
47
showRightItems : true ,
23
48
fullSwipeRight : true ,
24
49
showLeftItem : true ,
25
- fullSwipeLeft : true
50
+ fullSwipeLeft : true ,
26
51
} ;
27
52
}
28
53
29
54
componentDidUpdate ( prevProps , prevState ) {
30
55
if ( this . state . hideItem && prevState . hideItem ) {
31
- this . setState ( {
32
- hideItem : false
33
- } ) ;
56
+ this . showItem ( ) ;
34
57
}
35
58
}
36
59
37
- onFullSwipeRight = ( ) => {
38
-
39
- setTimeout ( ( ) => {
40
- LayoutAnimation . configureNext ( {
41
- update : {
42
- type : LayoutAnimation . Types . easeInEaseOut ,
43
- property : LayoutAnimation . Properties . scaleY
44
- } ,
45
- delete : {
46
- type : LayoutAnimation . Types . easeInEaseOut ,
47
- property : LayoutAnimation . Properties . scaleY ,
48
- duration : 2000
49
- } ,
50
- duration : 120
51
- } ) ;
52
- this . setState ( { hideItem : true } ) ;
53
- } , 200 ) ;
54
- } ;
55
-
56
-
57
- onWillFullSwipeLeft = ( ) => {
58
-
60
+ onFullSwipe = ( ) => {
59
61
// TODO: consider including this functionality as part of the drawer component
60
62
setTimeout ( ( ) => {
61
63
LayoutAnimation . configureNext ( {
62
64
update : {
63
65
type : LayoutAnimation . Types . easeInEaseOut ,
64
- property : LayoutAnimation . Properties . scaleY
66
+ property : LayoutAnimation . Properties . scaleY ,
65
67
} ,
66
68
delete : {
67
69
type : LayoutAnimation . Types . easeInEaseOut ,
68
70
property : LayoutAnimation . Properties . scaleY ,
69
- duration : 2000
71
+ duration : 2000 ,
70
72
} ,
71
- duration : 120
73
+ duration : 120 ,
72
74
} ) ;
73
75
this . setState ( { hideItem : true } ) ;
74
76
} , 200 ) ;
@@ -106,8 +108,8 @@ class DrawerScreen extends Component {
106
108
107
109
renderActions ( ) {
108
110
return (
109
- < View center >
110
- < Text style = { { fontSize : 20 } } > Actions</ Text >
111
+ < View center marginB-s4 >
112
+ < Text text70 > Actions</ Text >
111
113
< View row >
112
114
< Button
113
115
onPress = { this . openLeftDrawer }
@@ -148,8 +150,15 @@ class DrawerScreen extends Component {
148
150
149
151
renderListItem ( ) {
150
152
return (
151
- < View bg-grey80 paddingH-20 paddingV-10 row centerV style = { { borderBottomWidth : 1 , borderColor : Colors . grey60 } } >
152
- < Avatar source = { { uri : conversations [ 0 ] . thumbnail } } />
153
+ < View
154
+ bg-grey80
155
+ paddingH-20
156
+ paddingV-10
157
+ row
158
+ centerV
159
+ style = { { borderBottomWidth : 1 , borderColor : Colors . grey60 } }
160
+ >
161
+ < Avatar source = { { uri : conversations [ 0 ] . thumbnail } } />
153
162
< View marginL-20 >
154
163
< Text text70R > { conversations [ 0 ] . name } </ Text >
155
164
< Text text80 marginT-2 >
@@ -169,7 +178,7 @@ class DrawerScreen extends Component {
169
178
itemsTintColor,
170
179
bounciness,
171
180
itemsIconSize,
172
- hideItem
181
+ hideItem,
173
182
} = this . state ;
174
183
175
184
const drawerProps = {
@@ -178,9 +187,9 @@ class DrawerScreen extends Component {
178
187
bounciness,
179
188
ref : ( component ) => ( this . ref = component ) ,
180
189
fullSwipeRight,
181
- onFullSwipeRight : this . onFullSwipeRight ,
190
+ onFullSwipeRight : this . onFullSwipe ,
182
191
fullSwipeLeft,
183
- onWillFullSwipeLeft : this . onWillFullSwipeLeft
192
+ onWillFullSwipeLeft : this . onFullSwipe ,
184
193
} ;
185
194
if ( showRightItems ) {
186
195
drawerProps . rightItems = [ ITEMS . read , ITEMS . archive ] ;
@@ -192,39 +201,55 @@ class DrawerScreen extends Component {
192
201
193
202
return (
194
203
< View flex >
195
- < View padding-20 paddingB-0 >
196
- < Text text40 marginB-20 >
197
- Drawer
198
- </ Text >
204
+ < View row padding-20 paddingB-0 marginB-20 centerV >
205
+ < Text text40 > Drawer</ Text >
206
+ < Button
207
+ link
208
+ grey10
209
+ marginL-s1
210
+ marginT-2
211
+ iconSource = { Assets . icons . demo . refresh }
212
+ onPress = { this . showItem }
213
+ disabled = { ! hideItem }
214
+ />
199
215
</ View >
200
216
{ ! hideItem && (
201
217
< >
202
218
< Drawer key = { Date . now ( ) } { ...drawerProps } >
203
219
{ this . renderListItem ( ) }
204
220
</ Drawer >
205
- { this . renderActions ( ) }
206
221
</ >
207
222
) }
208
- { hideItem && (
209
- < View center >
210
- < Button
211
- round
212
- onPress = { this . showItem }
213
- backgroundColor = "#eeeeee"
214
- iconSource = { require ( '../../assets/icons/plus.png' ) }
215
- />
216
- </ View >
217
- ) }
218
223
219
- < ScrollView style = { styles . container } contentContainerStyle = { styles . contentContainer } >
224
+ < ScrollView
225
+ style = { styles . container }
226
+ contentContainerStyle = { styles . contentContainer }
227
+ >
220
228
< View padding-20 >
229
+ { this . renderActions ( ) }
221
230
{ renderBooleanOption . call ( this , 'rightItems' , 'showRightItems' ) }
222
- { showRightItems && renderBooleanOption . call ( this , 'fullSwipeRight' , 'fullSwipeRight' ) }
231
+ { showRightItems &&
232
+ renderBooleanOption . call (
233
+ this ,
234
+ 'fullSwipeRight' ,
235
+ 'fullSwipeRight'
236
+ ) }
223
237
{ renderBooleanOption . call ( this , 'leftItem' , 'showLeftItem' ) }
224
- { showLeftItem && renderBooleanOption . call ( this , 'fullSwipeLeft' , 'fullSwipeLeft' ) }
238
+ { showLeftItem &&
239
+ renderBooleanOption . call ( this , 'fullSwipeLeft' , 'fullSwipeLeft' ) }
225
240
{ renderColorOption . call ( this , 'icon+text color' , 'itemsTintColor' ) }
226
- { renderSliderOption . call ( this , 'bounciness' , 'bounciness' , { min : 5 , max : 15 , step : 1 , initial : 5 } ) }
227
- { renderSliderOption . call ( this , 'iconSize' , 'itemsIconSize' , { min : 15 , max : 25 , step : 1 , initial : 20 } ) }
241
+ { renderSliderOption . call ( this , 'bounciness' , 'bounciness' , {
242
+ min : 5 ,
243
+ max : 15 ,
244
+ step : 1 ,
245
+ initial : 5 ,
246
+ } ) }
247
+ { renderSliderOption . call ( this , 'iconSize' , 'itemsIconSize' , {
248
+ min : 15 ,
249
+ max : 25 ,
250
+ step : 1 ,
251
+ initial : 20 ,
252
+ } ) }
228
253
</ View >
229
254
</ ScrollView >
230
255
</ View >
@@ -234,43 +259,43 @@ class DrawerScreen extends Component {
234
259
235
260
const styles = StyleSheet . create ( {
236
261
container : {
237
- backgroundColor : Colors . white
262
+ backgroundColor : Colors . white ,
238
263
} ,
239
264
contentContainer : {
240
- paddingBottom : 50
265
+ paddingBottom : 50 ,
241
266
} ,
242
267
drawer : {
243
- marginTop : 20
268
+ marginTop : 20 ,
244
269
} ,
245
270
listContent : {
246
- backgroundColor : Colors . dark80
271
+ backgroundColor : Colors . dark80 ,
247
272
} ,
248
273
rowContent : {
249
274
flexDirection : 'row' ,
250
275
alignItems : 'center' ,
251
- backgroundColor : Colors . dark80
276
+ backgroundColor : Colors . dark80 ,
252
277
} ,
253
278
rowIcon : {
254
279
width : 38 ,
255
280
height : 38 ,
256
281
borderRadius : 19 ,
257
282
backgroundColor : Colors . violet40 ,
258
- margin : 20
283
+ margin : 20 ,
259
284
} ,
260
285
rowTitle : {
261
286
...Typography . text70 ,
262
287
fontWeight : 'bold' ,
263
- color : Colors . dark20
288
+ color : Colors . dark20 ,
264
289
} ,
265
290
rowSubtitle : {
266
291
...Typography . text80 ,
267
- color : Colors . dark30
292
+ color : Colors . dark30 ,
268
293
} ,
269
294
rowButtonContainer : {
270
295
flex : 1 ,
271
296
alignItems : 'flex-end' ,
272
- padding : 10
273
- }
297
+ padding : 10 ,
298
+ } ,
274
299
} ) ;
275
300
276
301
export default gestureHandlerRootHOC ( DrawerScreen ) ;
0 commit comments