Skip to content

Commit db0c67a

Browse files
committed
update DrawerScreen
1 parent 95aa2c3 commit db0c67a

File tree

7 files changed

+101
-74
lines changed

7 files changed

+101
-74
lines changed

demo/src/assets/icons/refresh.png

345 Bytes
Loading
499 Bytes
Loading
578 Bytes
Loading
834 Bytes
Loading
1.1 KB
Loading

demo/src/demoApp.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import * as Animatable from 'react-native-animatable';
44
import {AnimatableManager, ThemeManager, Constants, Assets, Colors, Typography} from 'react-native-ui-lib'; // eslint-disable-line
55
import {registerScreens} from './screens';
66

7+
8+
Assets.loadAssetsGroup('icons.demo', {
9+
refresh: require('./assets/icons/refresh.png')
10+
});
11+
712
/** Examples - uncomment when needed */
813
// Typography.loadTypographies({
914
// h1: {fontSize: 58, fontWeight: '300', lineHeight: 80},
@@ -36,9 +41,6 @@ import {registerScreens} from './screens';
3641
// }
3742
// });
3843

39-
// Assets.loadAssetsGroup('icons.general', {
40-
// camera: require('./assets/icons/cameraSelected.png'),
41-
// });
4244

4345
// AnimatableManager.loadAnimationPresets({
4446
// preset1: {

demo/src/screens/componentScreens/DrawerScreen.js

Lines changed: 96 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,41 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
33
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
514
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
615
import conversations from '../../data/conversations';
716

8-
import {renderBooleanOption, renderSliderOption, renderColorOption} from '../ExampleScreenPresenter';
17+
import {
18+
renderBooleanOption,
19+
renderSliderOption,
20+
renderColorOption,
21+
} from '../ExampleScreenPresenter';
922

1023
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+
},
1439
};
1540

1641
class DrawerScreen extends Component {
@@ -22,53 +47,30 @@ class DrawerScreen extends Component {
2247
showRightItems: true,
2348
fullSwipeRight: true,
2449
showLeftItem: true,
25-
fullSwipeLeft: true
50+
fullSwipeLeft: true,
2651
};
2752
}
2853

2954
componentDidUpdate(prevProps, prevState) {
3055
if (this.state.hideItem && prevState.hideItem) {
31-
this.setState({
32-
hideItem: false
33-
});
56+
this.showItem();
3457
}
3558
}
3659

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 = () => {
5961
// TODO: consider including this functionality as part of the drawer component
6062
setTimeout(() => {
6163
LayoutAnimation.configureNext({
6264
update: {
6365
type: LayoutAnimation.Types.easeInEaseOut,
64-
property: LayoutAnimation.Properties.scaleY
66+
property: LayoutAnimation.Properties.scaleY,
6567
},
6668
delete: {
6769
type: LayoutAnimation.Types.easeInEaseOut,
6870
property: LayoutAnimation.Properties.scaleY,
69-
duration: 2000
71+
duration: 2000,
7072
},
71-
duration: 120
73+
duration: 120,
7274
});
7375
this.setState({hideItem: true});
7476
}, 200);
@@ -106,8 +108,8 @@ class DrawerScreen extends Component {
106108

107109
renderActions() {
108110
return (
109-
<View center>
110-
<Text style={{fontSize: 20}}>Actions</Text>
111+
<View center marginB-s4>
112+
<Text text70>Actions</Text>
111113
<View row>
112114
<Button
113115
onPress={this.openLeftDrawer}
@@ -148,8 +150,15 @@ class DrawerScreen extends Component {
148150

149151
renderListItem() {
150152
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}} />
153162
<View marginL-20>
154163
<Text text70R>{conversations[0].name}</Text>
155164
<Text text80 marginT-2>
@@ -169,7 +178,7 @@ class DrawerScreen extends Component {
169178
itemsTintColor,
170179
bounciness,
171180
itemsIconSize,
172-
hideItem
181+
hideItem,
173182
} = this.state;
174183

175184
const drawerProps = {
@@ -178,9 +187,9 @@ class DrawerScreen extends Component {
178187
bounciness,
179188
ref: (component) => (this.ref = component),
180189
fullSwipeRight,
181-
onFullSwipeRight: this.onFullSwipeRight,
190+
onFullSwipeRight: this.onFullSwipe,
182191
fullSwipeLeft,
183-
onWillFullSwipeLeft: this.onWillFullSwipeLeft
192+
onWillFullSwipeLeft: this.onFullSwipe,
184193
};
185194
if (showRightItems) {
186195
drawerProps.rightItems = [ITEMS.read, ITEMS.archive];
@@ -192,39 +201,55 @@ class DrawerScreen extends Component {
192201

193202
return (
194203
<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+
/>
199215
</View>
200216
{!hideItem && (
201217
<>
202218
<Drawer key={Date.now()} {...drawerProps}>
203219
{this.renderListItem()}
204220
</Drawer>
205-
{this.renderActions()}
206221
</>
207222
)}
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-
)}
218223

219-
<ScrollView style={styles.container} contentContainerStyle={styles.contentContainer}>
224+
<ScrollView
225+
style={styles.container}
226+
contentContainerStyle={styles.contentContainer}
227+
>
220228
<View padding-20>
229+
{this.renderActions()}
221230
{renderBooleanOption.call(this, 'rightItems', 'showRightItems')}
222-
{showRightItems && renderBooleanOption.call(this, 'fullSwipeRight', 'fullSwipeRight')}
231+
{showRightItems &&
232+
renderBooleanOption.call(
233+
this,
234+
'fullSwipeRight',
235+
'fullSwipeRight'
236+
)}
223237
{renderBooleanOption.call(this, 'leftItem', 'showLeftItem')}
224-
{showLeftItem && renderBooleanOption.call(this, 'fullSwipeLeft', 'fullSwipeLeft')}
238+
{showLeftItem &&
239+
renderBooleanOption.call(this, 'fullSwipeLeft', 'fullSwipeLeft')}
225240
{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+
})}
228253
</View>
229254
</ScrollView>
230255
</View>
@@ -234,43 +259,43 @@ class DrawerScreen extends Component {
234259

235260
const styles = StyleSheet.create({
236261
container: {
237-
backgroundColor: Colors.white
262+
backgroundColor: Colors.white,
238263
},
239264
contentContainer: {
240-
paddingBottom: 50
265+
paddingBottom: 50,
241266
},
242267
drawer: {
243-
marginTop: 20
268+
marginTop: 20,
244269
},
245270
listContent: {
246-
backgroundColor: Colors.dark80
271+
backgroundColor: Colors.dark80,
247272
},
248273
rowContent: {
249274
flexDirection: 'row',
250275
alignItems: 'center',
251-
backgroundColor: Colors.dark80
276+
backgroundColor: Colors.dark80,
252277
},
253278
rowIcon: {
254279
width: 38,
255280
height: 38,
256281
borderRadius: 19,
257282
backgroundColor: Colors.violet40,
258-
margin: 20
283+
margin: 20,
259284
},
260285
rowTitle: {
261286
...Typography.text70,
262287
fontWeight: 'bold',
263-
color: Colors.dark20
288+
color: Colors.dark20,
264289
},
265290
rowSubtitle: {
266291
...Typography.text80,
267-
color: Colors.dark30
292+
color: Colors.dark30,
268293
},
269294
rowButtonContainer: {
270295
flex: 1,
271296
alignItems: 'flex-end',
272-
padding: 10
273-
}
297+
padding: 10,
298+
},
274299
});
275300

276301
export default gestureHandlerRootHOC(DrawerScreen);

0 commit comments

Comments
 (0)