Skip to content

Commit d3e240f

Browse files
committed
Merge branch 'master' into release
2 parents 3ccfba9 + 21d7997 commit d3e240f

Some content is hidden

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

73 files changed

+6002
-961
lines changed

demo/src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ module.exports = {
9494
get RadioButtonScreen() {
9595
return require('./screens/componentScreens/RadioButtonScreen').default;
9696
},
97+
get SectionsWheelPickerScreen() {
98+
return require('./screens/componentScreens/SectionsWheelPickerScreen').default;
99+
},
97100
get SegmentedControlScreen() {
98101
return require('./screens/componentScreens/SegmentedControlScreen').default;
99102
},

demo/src/screens/MainScreen.js

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ import PropTypes from 'prop-types';
55
import {StyleSheet, FlatList, ViewPropTypes} from 'react-native';
66
import {Navigation} from 'react-native-navigation';
77
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
8-
import {Assets, Colors, View, Text, TouchableOpacity, TextField, Image, TabController} from 'react-native-ui-lib'; //eslint-disable-line
8+
import {
9+
Assets,
10+
Colors,
11+
View,
12+
Text,
13+
TouchableOpacity,
14+
TextField,
15+
Image,
16+
Button,
17+
TabController
18+
} from 'react-native-ui-lib'; //eslint-disable-line
919
import {navigationData} from './MenuStructure';
1020

1121
const settingsIcon = require('../assets/icons/settings.png');
@@ -15,7 +25,7 @@ class MainScreen extends Component {
1525
static propTypes = {
1626
containerStyle: ViewPropTypes.style,
1727
renderItem: PropTypes.func,
18-
pageStyle: ViewPropTypes.style
28+
pageStyle: ViewPropTypes.style
1929
};
2030

2131
settingsScreenName = 'unicorn.Settings';
@@ -52,7 +62,6 @@ class MainScreen extends Component {
5262

5363
onSearchBoxBlur = () => {
5464
this.closeSearchBox();
55-
// this.filterExplorerScreens('');
5665
};
5766

5867
getMenuData = () => {
@@ -67,8 +76,8 @@ class MainScreen extends Component {
6776
this.pushScreen({
6877
name: this.settingsScreenName,
6978
passProps: {
70-
navigationData: data,
71-
playground: this.props.playground,
79+
navigationData: data,
80+
playground: this.props.playground,
7281
extraSettingsUI: this.props.extraSettingsUI
7382
}
7483
});
@@ -105,12 +114,22 @@ class MainScreen extends Component {
105114
this.closeSearchBox();
106115

107116
setTimeout(() => {
108-
// this.filterExplorerScreens('');
109117
this.pushScreen(row);
110118
}, 0);
111119
};
112120

113-
filterExplorerScreens = filterText => {
121+
updateSearch = filterText => {
122+
this.setState({filterText}, () => {
123+
this.filterExplorerScreens();
124+
});
125+
};
126+
127+
clearSearch = () => {
128+
this.updateSearch('');
129+
};
130+
131+
filterExplorerScreens = () => {
132+
const {filterText} = this.state;
114133
let filteredNavigationData = {};
115134
const data = this.getMenuData();
116135

@@ -134,32 +153,35 @@ class MainScreen extends Component {
134153
}
135154

136155
this.setState({
137-
filterText,
138156
filteredNavigationData
139157
});
140158
};
141159

142160
/** Renders */
143161
renderSearch = () => {
162+
const {filterText} = this.state;
144163
return (
145164
<TextField
165+
migrate
146166
ref={r => (this.input = r)}
147-
value={this.state.filterText}
167+
value={filterText}
148168
testID="uilib.search_for_component"
149169
placeholder="Search for your component..."
150-
onChangeText={this.filterExplorerScreens}
170+
onChangeText={this.updateSearch}
151171
onBlur={this.onSearchBoxBlur}
152-
containerStyle={{padding: 16, paddingBottom: 0}}
153-
style={{
154-
padding: 12,
155-
backgroundColor: Colors.dark80,
156-
borderRadius: 8
157-
}}
172+
containerStyle={styles.searchContainer}
173+
fieldStyle={styles.searchField}
158174
enableErrors={false}
159175
hideUnderline
160176
floatingPlaceholder={false}
161177
text70
162-
rightButtonProps={{iconSource: Assets.icons.search, style: {marginRight: 12, alignSelf: 'center'}}}
178+
trailingAccessory={
179+
filterText ? (
180+
<Button link iconSource={Assets.icons.demo.close} grey10 onPress={this.clearSearch}/>
181+
) : (
182+
<Image source={Assets.icons.demo.search}/>
183+
)
184+
}
163185
/>
164186
);
165187
};
@@ -251,7 +273,10 @@ class MainScreen extends Component {
251273
{showResults && this.renderSearchResults(filteredNavigationData)}
252274

253275
{showCarousel && (
254-
<TabController asCarousel items={_.map(data, section => ({label: section.title, testID: `section.${section.title}`}))}>
276+
<TabController
277+
asCarousel
278+
items={_.map(data, section => ({label: section.title, testID: `section.${section.title}`}))}
279+
>
255280
<TabController.TabBar testID={'mainScreenTabBar'}/>
256281
{this.renderPages(data)}
257282
</TabController>
@@ -271,6 +296,15 @@ class MainScreen extends Component {
271296
const styles = StyleSheet.create({
272297
entryTextDeprecated: {
273298
textDecorationLine: 'line-through'
299+
},
300+
searchContainer: {
301+
padding: 16,
302+
paddingBottom: 0
303+
},
304+
searchField: {
305+
padding: 12,
306+
backgroundColor: Colors.dark80,
307+
borderRadius: 8
274308
}
275309
});
276310

demo/src/screens/MenuStructure.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const navigationData = {
5656
{title: 'Picker', tags: 'picker form', screen: 'unicorn.components.PickerScreen'},
5757
{title: 'DateTimePicker', tags: 'date time picker form', screen: 'unicorn.components.DateTimePickerScreen'},
5858
{title: 'RadioButton', tags: 'radio button group controls', screen: 'unicorn.components.RadioButtonScreen'},
59+
{title: 'SectionsWheelPicker', tags: 'sections wheel picker form', screen: 'unicorn.components.SectionsWheelPickerScreen'},
5960
{title: 'SegmentedControl', tags: 'segmented control switch toggle', screen: 'unicorn.components.SegmentedControlScreen'},
6061
{title: 'Stepper', tags: 'stepper form', screen: 'unicorn.components.StepperScreen'},
6162
{title: 'Slider', tags: 'slider', screen: 'unicorn.components.SliderScreen'},

demo/src/screens/componentScreens/CarouselVerticalScreen.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const BACKGROUND_COLORS = [
2222
Colors.purple60
2323
];
2424

25-
const pageHeight = Constants.windowHeight / 2;
25+
const pageHeight = Constants.windowHeight / 3;
2626

2727
class CarouselVerticalScreen extends Component<{}, State> {
2828
carousel = React.createRef<typeof Carousel>();
@@ -101,6 +101,17 @@ class CarouselVerticalScreen extends Component<{}, State> {
101101
</Carousel>
102102
{this.renderAnimatedCounter()}
103103
</View>
104+
105+
<View centerH flex marginT-s3>
106+
<Text h3 marginB-s2>
107+
iOS Widgets Carousel
108+
</Text>
109+
<Carousel horizontal={false} containerStyle={styles.widgetsCarousel}>
110+
<View flex bg-blue30/>
111+
<View flex bg-orange30/>
112+
<View flex bg-green30/>
113+
</Carousel>
114+
</View>
104115
</View>
105116
);
106117
}
@@ -130,6 +141,13 @@ const styles = StyleSheet.create({
130141
position: 'absolute',
131142
top: 20,
132143
left: 20
144+
},
145+
widgetsCarousel: {
146+
height: 150,
147+
width: 300,
148+
backgroundColor: Colors.grey60,
149+
borderRadius: 24,
150+
overflow: 'hidden'
133151
}
134152
});
135153

demo/src/screens/componentScreens/ColorPickerScreen.js renamed to demo/src/screens/componentScreens/ColorPickerScreen.tsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ import {StyleSheet, ScrollView} from 'react-native';
44
import {Colors, View, Text, ColorPicker, ColorPalette, ColorName} from 'react-native-ui-lib';
55

66

7+
interface Props {}
8+
interface State {
9+
color: string,
10+
textColor: string,
11+
customColors: string[],
12+
paletteChange: boolean
13+
}
14+
715
const INITIAL_COLOR = Colors.blue30;
816
const colors = [
917
'#20303C', '#43515C', '#66737C', '#858F96', '#A3ABB0', '#C2C7CB', '#E0E3E5', '#F2F4F5',
@@ -17,34 +25,30 @@ const colors = [
1725
];
1826

1927

20-
export default class ColorPickerScreen extends Component {
21-
constructor(props) {
22-
super(props);
23-
24-
this.state = {
25-
color: INITIAL_COLOR,
26-
textColor: Colors.white,
27-
customColors: [],
28-
paletteChange: false
29-
};
30-
}
28+
export default class ColorPickerScreen extends Component<Props, State> {
29+
state: State = {
30+
color: INITIAL_COLOR,
31+
textColor: Colors.white,
32+
customColors: [],
33+
paletteChange: false
34+
};
3135

3236
onDismiss = () => {
3337
console.log(`screen onDismiss`);
3438
}
3539

36-
onSubmit = (color, textColor) => {
40+
onSubmit = (color: string, textColor: string) => {
3741
const {customColors} = this.state;
3842
customColors.push(color);
3943
this.setState({color, textColor, customColors: _.clone(customColors), paletteChange: false});
4044
}
4145

42-
onValueChange = (value, options) => {
43-
this.setState({color: value, textColor: options ? options.tintColor : undefined, paletteChange: false});
46+
onValueChange = (value: string, options: object) => {
47+
this.setState({color: value, textColor: options ? _.get(options, 'tintColor') : undefined, paletteChange: false});
4448
}
4549

46-
onPaletteValueChange = (value, options) => {
47-
this.setState({color: value, textColor: options ? options.tintColor : undefined, paletteChange: true});
50+
onPaletteValueChange = (value: string, options: object) => {
51+
this.setState({color: value, textColor: options ? _.get(options, 'tintColor') : undefined, paletteChange: true});
4852
}
4953

5054
render() {
@@ -74,7 +78,7 @@ export default class ColorPickerScreen extends Component {
7478
Theme Color
7579
</Text>
7680
<Text marginL-20>Choose a color for your place’s theme.</Text>
77-
<ColorPalette value={paletteValue} onValueChange={this.onPaletteValueChange} colors={colors} />
81+
<ColorPalette value={paletteValue} onValueChange={this.onPaletteValueChange} colors={colors}/>
7882
<Text marginL-20 marginT-16>
7983
Custom Colors
8084
</Text>

demo/src/screens/componentScreens/ColorSwatchScreen.js renamed to demo/src/screens/componentScreens/ColorSwatchScreen.tsx

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,34 @@ import {Constants, Colors, View, Text, ColorSwatch, ColorPalette} from 'react-na
55

66

77
export default class ColorSwatchScreen extends Component {
8-
constructor(props) {
9-
super(props);
10-
11-
this.colors = ['transparent', Colors.green30, Colors.yellow30, Colors.red30];
12-
this.mainColors = ['#66737C', '#459FED', '#1D5382', '#3CC7C5', '#65C888', '#FAAD4D', '#F27052', '#F2564D', '#B13DAC', '#733CA6', '#79838A', '#5847FF', '#00BBF2', '#00CD8B', '#FF563D', '#ffb600'];
13-
this.allColors = _.filter(Object.values(Colors), _.isString);
8+
colors = ['transparent', Colors.green30, Colors.yellow30, Colors.red30];
9+
mainColors = ['#66737C', '#459FED', '#1D5382', '#3CC7C5', '#65C888', '#FAAD4D', '#F27052', '#F2564D', '#B13DAC', '#733CA6', '#79838A', '#5847FF', '#00BBF2', '#00CD8B', '#FF563D', '#ffb600'];
10+
allColors = _.filter(Object.values(Colors), _.isString);
1411

15-
this.state = {
16-
color: this.colors[0],
17-
color1: this.mainColors[this.mainColors.length - 1],
18-
color2: this.allColors[20],
19-
selected: false
20-
};
21-
}
12+
state = {
13+
color: this.colors[0],
14+
color1: this.mainColors[this.mainColors.length - 1],
15+
color2: this.allColors[20],
16+
selected: false
17+
};
2218

2319
onPress = () => {
2420
this.setState({selected: !this.state.selected});
2521
}
2622

27-
onValueChange = (value) => {
23+
onValueChange = (value: string) => {
2824
this.setState({color: value});
2925
}
30-
onValueChange1 = (value) => {
26+
onValueChange1 = (value: string) => {
3127
this.setState({color1: value});
3228
}
33-
onValueChange2 = (value) => {
29+
onValueChange2 = (value: string) => {
3430
this.setState({color2: value});
3531
}
3632

3733
render() {
3834
const {color, color1, color2, selected} = this.state;
39-
35+
4036
return (
4137
<ScrollView style={{backgroundColor: Colors.dark80}}>
4238
<View flex center useSafeArea>
@@ -48,16 +44,29 @@ export default class ColorSwatchScreen extends Component {
4844
<Text>Disabled</Text>
4945
</View>
5046
</View>
51-
47+
5248
<Text marginT-20 text60 dark10>ColorPalette</Text>
5349
<Text marginB-10 text70 style={{color}}>Selected Color: {color}</Text>
54-
<ColorPalette value={color} onValueChange={this.onValueChange} colors={this.colors}/>
50+
<ColorPalette
51+
value={color}
52+
onValueChange={this.onValueChange}
53+
colors={this.colors}
54+
/>
5555

5656
<Text margin-10 text60 dark10>Scrollable</Text>
57-
<ColorPalette value={color1} onValueChange={this.onValueChange1} colors={this.mainColors}/>
58-
57+
<ColorPalette
58+
value={color1}
59+
onValueChange={this.onValueChange1}
60+
colors={this.mainColors}
61+
/>
62+
5963
<Text margin-10 text60 dark10>Pagination</Text>
60-
<ColorPalette numberOfRows={!Constants.isTablet ? 4 : undefined} value={color2} onValueChange={this.onValueChange2} colors={this.allColors}/>
64+
<ColorPalette
65+
numberOfRows={!Constants.isTablet ? 4 : undefined}
66+
value={color2}
67+
onValueChange={this.onValueChange2}
68+
colors={this.allColors}
69+
/>
6170
</View>
6271
</ScrollView>
6372
);

demo/src/screens/componentScreens/HapticScreen.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
33
import {ScrollView} from 'react-native';
4-
import {View, Text, Button, HapticService} from 'react-native-ui-lib';
4+
import {View, Text, Button, HapticService, HapticType} from 'react-native-ui-lib';
55

66
export default class HapticScreen extends Component {
7-
onPress = ({method}: {method: string}) => {
8-
HapticService.triggerHaptic(method, 'HapticScreen');
7+
onPress = ({hapticType}: {hapticType: HapticType}) => {
8+
HapticService.triggerHaptic(hapticType, 'HapticScreen');
99
};
1010

1111
render() {
@@ -16,8 +16,8 @@ export default class HapticScreen extends Component {
1616
Haptic Screen
1717
</Text>
1818

19-
{_.map(HapticService.HapticMethods, method => {
20-
return <Button marginV-8 marginH-60 label={method} key={method} onPress={() => this.onPress({method})}/>;
19+
{_.map(HapticService.HapticType, hapticType => {
20+
return <Button marginV-8 marginH-60 label={hapticType} key={hapticType} onPress={() => this.onPress({hapticType})}/>;
2121
})}
2222
</View>
2323
</ScrollView>

0 commit comments

Comments
 (0)