Skip to content

Commit acade66

Browse files
committed
Merge branch 'master' into release
2 parents 06404dc + 783dab8 commit acade66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+507
-452
lines changed

demo/src/assets/icons/archive.png

476 Bytes
Loading
719 Bytes
Loading
682 Bytes
Loading
1.17 KB
Loading
1.38 KB
Loading

demo/src/assets/icons/delete.png

176 Bytes
Loading
263 Bytes
Loading
241 Bytes
Loading
331 Bytes
Loading
384 Bytes
Loading

demo/src/assets/icons/mail.png

362 Bytes
Loading
598 Bytes
Loading
749 Bytes
Loading
1.16 KB
Loading
1.78 KB
Loading

demo/src/screens/ExampleScreenPresenter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'lodash';
22
import React from 'react';
33
import {StyleSheet} from 'react-native';
4-
import {Checkbox, ColorPalette, Colors, RadioButton, RadioGroup, Slider, Text, View} from 'react-native-ui-lib';
4+
import {Checkbox, Switch, ColorPalette, Colors, RadioButton, RadioGroup, Slider, Text, View} from 'react-native-ui-lib';
55

66
export function renderHeader(title, others) {
77
return (
@@ -18,7 +18,7 @@ export function renderBooleanOption(title, key) {
1818
<Text text70 style={{flex: 1}}>
1919
{title}
2020
</Text>
21-
<Checkbox
21+
<Switch
2222
useCustomTheme
2323
key={key}
2424
textID={key}

demo/src/screens/MainScreen.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class MainScreen extends Component {
243243

244244
{showCarousel && (
245245
<TabController asCarousel>
246-
<TabController.TabBar items={_.map(data, section => ({label: section.title}))}/>
246+
<TabController.TabBar testID={'mainScreenTabBar'} items={_.map(data, section => ({label: section.title, testID: `section.${section.title}`}))}/>
247247
{this.renderPages(data)}
248248
</TabController>
249249
)}

demo/src/screens/SettingsScreen.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ class SettingsScreen extends Component {
6161
};
6262

6363
render() {
64-
const {defaultScreen, showRefreshMessage, isRTL} = this.state;
64+
const {defaultScreen, showRefreshMessage, isRTL, screens} = this.state;
65+
const filteredScreens = _.filter(screens, screen => !_.isUndefined(screen.value));
6566

6667
return (
6768
<View flex padding-25 bg-grey80>
@@ -77,7 +78,7 @@ class SettingsScreen extends Component {
7778
value={defaultScreen}
7879
onChange={this.setDefaultScreen}
7980
>
80-
{_.map(this.state.screens, screen => (
81+
{_.map(filteredScreens, screen => (
8182
<Picker.Item key={screen.value} value={screen}/>
8283
))}
8384
</Picker>

demo/src/screens/componentScreens/DrawerScreen.js

+90-167
Original file line numberDiff line numberDiff line change
@@ -1,199 +1,122 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
3-
import {StyleSheet, Alert, ScrollView} from 'react-native';
3+
import {StyleSheet, ScrollView, LayoutAnimation} from 'react-native';
44
import {Colors, Typography, View, Drawer, Text, Button, ListItem, Avatar, AvatarHelper} from 'react-native-ui-lib'; //eslint-disable-line
55
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
66
import conversations from '../../data/conversations';
77

8+
import {renderBooleanOption, renderSliderOption, renderColorOption} from '../ExampleScreenPresenter';
89

9-
const collectionsIcon = require('../../assets/icons/collections.png');
10-
const starIcon = require('../../assets/icons/star.png');
11-
const shareIcon = require('../../assets/icons/share.png');
12-
const videoIcon = require('../../assets/icons/video.png');
13-
const tagsIcon = require('../../assets/icons/tags.png');
10+
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}
14+
};
1415

1516
class DrawerScreen extends Component {
1617
constructor(props) {
1718
super(props);
1819

1920
this.state = {
20-
itemsTintColor: undefined,
21-
leftItem: {icon: collectionsIcon, text: 'Archive', onPress: this.onLeftItemPressed},
22-
rightItems: [
23-
{icon: starIcon, text: 'Accessories', onPress: this.onItemPress, background: Colors.violet10},
24-
{icon: shareIcon, text: 'Share', onPress: this.onItemPress, background: Colors.violet30},
25-
{icon: videoIcon, text: 'Video', onPress: this.onItemPress, background: Colors.violet40},
26-
// {icon: tagsIcon, text: 'Video', background: Colors.red30},
27-
],
21+
hideItem: false,
22+
showRightItems: true,
23+
showLeftItem: true,
24+
fullSwipeLeft: true
2825
};
2926
}
3027

31-
onItemPress = () => {
32-
Alert.alert('Right drawer item pressed');
33-
34-
this.toggleDynamicItem();
35-
this.firstDrawer.closeDrawer();
36-
};
37-
onItemPress2 = () => {
38-
const {itemsTintColor} = this.state;
39-
const color = itemsTintColor === undefined ? Colors.blue30 : undefined;
40-
41-
this.setState({itemsTintColor: color});
42-
};
43-
onLeftItemPressed = () => {
44-
Alert.alert('Left drawer item pressed');
45-
};
46-
onContentPress(id) {
47-
Alert.alert(`List item #${id + 1} pressed`);
48-
}
49-
onButtonPress(id) {
50-
Alert.alert(`Button '${id}' pressed`);
51-
}
52-
53-
async setItemWidth(item) {
54-
if (item && !item.width && !_.isEmpty(item.text)) {
55-
const horizontalPadding = 12;
56-
const typography = Typography.text70;
57-
const width = await Typography.measureWidth(item.text, typography);
58-
const itemCopy = item;
59-
itemCopy.width = width + horizontalPadding * 2;
60-
return itemCopy;
28+
componentDidUpdate(prevProps, prevState) {
29+
if (this.state.hideItem && prevState.hideItem) {
30+
this.setState({
31+
hideItem: false
32+
});
6133
}
6234
}
6335

64-
toggleDynamicItem() {
65-
const {rightItems} = this.state;
66-
let newItem;
67-
if (rightItems[0].text === 'Accessories') {
68-
newItem = {icon: starIcon, text: 'More', onPress: this.onItemPress, background: Colors.violet10};
69-
} else {
70-
newItem = {
71-
icon: starIcon,
72-
text: 'Accessories',
73-
onPress: this.onItemPress,
74-
background: Colors.violet10
75-
};
76-
}
77-
rightItems[0] = newItem;
78-
this.setState({rightItems});
79-
}
36+
onWillFullSwipeLeft = () => {
37+
38+
// TODO: consider including this functionality as part of the drawer component
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+
};
8055

81-
renderContent(id, row) {
82-
const initials = AvatarHelper.getInitials(row.name);
56+
renderListItem() {
8357
return (
84-
<ListItem key={id} onPress={() => this.onContentPress(id)} style={styles.listContent}>
85-
<ListItem.Part left>
86-
<Avatar
87-
source={row.thumbnail ? {uri: row.thumbnail} : null}
88-
label={initials}
89-
badgeProps={{backgroundColor: Number(id) % 3 === 0 ? Colors.green30 : undefined}}
90-
containerStyle={{marginHorizontal: 18}}
91-
backgroundColor={Colors.white}
92-
/>
93-
</ListItem.Part>
94-
<ListItem.Part middle containerStyle={styles.border}>
95-
<Text text70>{row.name}</Text>
96-
</ListItem.Part>
97-
</ListItem>
58+
<View bg-grey80 paddingH-20 paddingV-10 row centerV style={{borderBottomWidth: 1, borderColor: Colors.grey60}}>
59+
<Avatar source={{uri: conversations[0].thumbnail}}/>
60+
<View marginL-20>
61+
<Text text70R>{conversations[0].name}</Text>
62+
<Text text80 marginT-2>
63+
{conversations[0].text}
64+
</Text>
65+
</View>
66+
</View>
9867
);
9968
}
10069

10170
render() {
102-
const {leftItem, rightItems} = this.state;
103-
104-
return (
105-
<ScrollView style={styles.container} contentContainerStyle={styles.contentContainer}>
106-
<Drawer
107-
leftItem={leftItem}
108-
rightItems={rightItems}
109-
style={styles.drawer}
110-
itemsIconSize={20}
111-
ref={r => this.firstDrawer = r}
112-
>
113-
{this.renderContent('0', conversations[0])}
114-
</Drawer>
115-
116-
<Drawer
117-
leftItem={leftItem}
118-
rightItems={[
119-
{icon: shareIcon, text: 'Share', onPress: this.onItemPress},
120-
{icon: videoIcon, text: 'Video', onPress: this.onItemPress, background: Colors.blue10},
121-
]}
122-
style={styles.drawer}
123-
>
124-
{this.renderContent('1', conversations[1])}
125-
</Drawer>
126-
127-
{/* <Drawer
128-
// leftItem={leftItem}
129-
rightItems={rightItems}
130-
style={styles.drawer}
131-
equalWidths
132-
>
133-
{this.renderContent('1', conversations[1])}
134-
</Drawer> */}
71+
const {
72+
showRightItems,
73+
showLeftItem,
74+
fullSwipeLeft,
75+
itemsTintColor,
76+
bounciness,
77+
itemsIconSize,
78+
hideItem
79+
} = this.state;
80+
81+
const drawerProps = {
82+
itemsTintColor,
83+
itemsIconSize,
84+
bounciness,
85+
fullSwipeLeft,
86+
onWillFullSwipeLeft: this.onWillFullSwipeLeft
87+
};
88+
if (showRightItems) {
89+
drawerProps.rightItems = [ITEMS.read, ITEMS.archive];
90+
}
13591

136-
<Drawer
137-
leftItem={{text: 'Archive', background: Colors.blue10, width: 100, onPress: this.onLeftItemPressed}}
138-
// rightItems={rightItems}
139-
style={styles.drawer}
140-
itemsTextStyle={{fontSize: 18, fontWeight: 'bold'}}
141-
>
142-
{this.renderContent('2', conversations[2])}
143-
</Drawer>
92+
if (showLeftItem) {
93+
drawerProps.leftItem = ITEMS.delete;
94+
}
14495

145-
<View style={{paddingHorizontal: 50}}>
146-
<Drawer
147-
leftItem={leftItem}
148-
rightItems={[rightItems[1], rightItems[2]]}
149-
itemsIconSize={24}
150-
style={{marginTop: 20}}
151-
onPress={this.onPress}
152-
>
153-
{this.renderContent('2', conversations[2])}
154-
</Drawer>
96+
return (
97+
<View flex>
98+
<View padding-20 paddingB-0>
99+
<Text text40 marginB-20>
100+
Drawer
101+
</Text>
155102
</View>
156-
157-
<Drawer
158-
leftItem={{icon: collectionsIcon, background: Colors.blue10, width: 100}}
159-
rightItems={[
160-
{icon: starIcon, background: Colors.dark60},
161-
{icon: shareIcon, background: Colors.yellow20},
162-
{icon: videoIcon, background: Colors.red30, onPress: this.onItemPress2},
163-
{icon: tagsIcon, background: Colors.green30},
164-
]}
165-
style={styles.drawer}
166-
itemsIconSize={30}
167-
itemsTintColor={this.state.itemsTintColor}
168-
>
169-
{this.renderContent('4', conversations[4])}
170-
</Drawer>
171-
172-
<Drawer
173-
leftItem={leftItem}
174-
rightItems={rightItems}
175-
style={styles.drawer}
176-
itemsTextStyle={{fontSize: 12}}
177-
>
178-
<View style={styles.rowContent}>
179-
<View style={styles.rowIcon}/>
180-
<View>
181-
<Text style={styles.rowTitle}>Row Title</Text>
182-
<Text style={styles.rowSubtitle}>Drag the row left and right</Text>
183-
</View>
184-
<View style={styles.rowButtonContainer}>
185-
<Button
186-
label={'1'}
187-
size={'small'}
188-
round
189-
backgroundColor={Colors.yellow30}
190-
white
191-
onPress={() => this.onButtonPress('1')}
192-
/>
193-
</View>
103+
{!hideItem && (
104+
<Drawer key={Date.now()} {...drawerProps}>
105+
{this.renderListItem()}
106+
</Drawer>
107+
)}
108+
109+
<ScrollView style={styles.container} contentContainerStyle={styles.contentContainer}>
110+
<View padding-20>
111+
{renderBooleanOption.call(this, 'rightItems', 'showRightItems')}
112+
{renderBooleanOption.call(this, 'leftItem', 'showLeftItem')}
113+
{showLeftItem && renderBooleanOption.call(this, 'fullSwipeLeft', 'fullSwipeLeft')}
114+
{renderColorOption.call(this, 'icon+text color', 'itemsTintColor')}
115+
{renderSliderOption.call(this, 'bounciness', 'bounciness', {min: 5, max: 15, step: 1, initial: 5})}
116+
{renderSliderOption.call(this, 'iconSize', 'itemsIconSize', {min: 15, max: 25, step: 1, initial: 20})}
194117
</View>
195-
</Drawer>
196-
</ScrollView>
118+
</ScrollView>
119+
</View>
197120
);
198121
}
199122
}

demo/src/screens/componentScreens/FloatingButtonScreen.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ export default class FloatingButtonScreen extends Component {
2626

2727
notNow = () => {
2828
Alert.alert('Not Now!');
29-
this._hideButton();
29+
this.hideButton();
3030
}
3131

3232
close = () => {
3333
Alert.alert('Closed.');
34-
this._hideButton();
34+
this.hideButton();
3535
}
3636

3737
render() {

0 commit comments

Comments
 (0)