unicorn-demo-app 6.8.1 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -8,45 +8,45 @@ const cardImage = require('../../assets/images/card-example.jpg');
|
|
|
8
8
|
const chevronDown = require('../../assets/icons/chevronDown.png');
|
|
9
9
|
const chevronUp = require('../../assets/icons/chevronUp.png');
|
|
10
10
|
|
|
11
|
-
const elements = [
|
|
12
|
-
<Card style={{marginBottom: 10}} onPress={() => {}}>
|
|
13
|
-
<Card.Section
|
|
14
|
-
content={[
|
|
15
|
-
{text: 'Card #1', text70: true, grey10: true},
|
|
16
|
-
{text: 'card description', text90: true, grey50: true}
|
|
17
|
-
]}
|
|
18
|
-
style={{padding: 20}}
|
|
19
|
-
/>
|
|
20
|
-
<Card.Section source={cardImage2} imageStyle={{height: 120}} />
|
|
21
|
-
</Card>,
|
|
22
|
-
<Card style={{marginBottom: 10}} onPress={() => {}}>
|
|
23
|
-
<Card.Section
|
|
24
|
-
content={[
|
|
25
|
-
{text: 'Card #2', text70: true, grey10: true},
|
|
26
|
-
{text: 'card description', text90: true, grey50: true}
|
|
27
|
-
]}
|
|
28
|
-
style={{padding: 20}}
|
|
29
|
-
/>
|
|
30
|
-
<Card.Section source={cardImage} imageStyle={{height: 120}} />
|
|
31
|
-
</Card>,
|
|
32
|
-
<Card style={{marginBottom: 10}} onPress={() => {}}>
|
|
33
|
-
<Card.Section
|
|
34
|
-
content={[
|
|
35
|
-
{text: 'Card #3', text70: true, grey10: true},
|
|
36
|
-
{text: 'card description', text90: true, grey50: true}
|
|
37
|
-
]}
|
|
38
|
-
style={{padding: 20}}
|
|
39
|
-
/>
|
|
40
|
-
<Card.Section source={cardImage2} imageStyle={{height: 120}} />
|
|
41
|
-
</Card>
|
|
42
|
-
];
|
|
43
|
-
|
|
44
11
|
class ExpandableSectionScreen extends PureComponent {
|
|
45
12
|
state = {
|
|
46
13
|
expanded: false,
|
|
47
14
|
top: false
|
|
48
15
|
};
|
|
49
16
|
|
|
17
|
+
elements = [
|
|
18
|
+
<Card key={0} style={{marginBottom: 10}} onPress={() => this.onExpand()}>
|
|
19
|
+
<Card.Section
|
|
20
|
+
content={[
|
|
21
|
+
{text: 'Card #1', text70: true, grey10: true},
|
|
22
|
+
{text: 'card description', text90: true, grey50: true}
|
|
23
|
+
]}
|
|
24
|
+
style={{padding: 20}}
|
|
25
|
+
/>
|
|
26
|
+
<Card.Section imageSource={cardImage2} imageStyle={{height: 120}}/>
|
|
27
|
+
</Card>,
|
|
28
|
+
<Card key={1} style={{marginBottom: 10}} onPress={() => this.onExpand()}>
|
|
29
|
+
<Card.Section
|
|
30
|
+
content={[
|
|
31
|
+
{text: 'Card #2', text70: true, grey10: true},
|
|
32
|
+
{text: 'card description', text90: true, grey50: true}
|
|
33
|
+
]}
|
|
34
|
+
style={{padding: 20}}
|
|
35
|
+
/>
|
|
36
|
+
<Card.Section imageSource={cardImage} imageStyle={{height: 120}}/>
|
|
37
|
+
</Card>,
|
|
38
|
+
<Card key={2} style={{marginBottom: 10}} onPress={() => this.onExpand()}>
|
|
39
|
+
<Card.Section
|
|
40
|
+
content={[
|
|
41
|
+
{text: 'Card #3', text70: true, grey10: true},
|
|
42
|
+
{text: 'card description', text90: true, grey50: true}
|
|
43
|
+
]}
|
|
44
|
+
style={{padding: 20}}
|
|
45
|
+
/>
|
|
46
|
+
<Card.Section imageSource={cardImage2} imageStyle={{height: 120}}/>
|
|
47
|
+
</Card>
|
|
48
|
+
];
|
|
49
|
+
|
|
50
50
|
onExpand() {
|
|
51
51
|
this.setState({
|
|
52
52
|
expanded: !this.state.expanded
|
|
@@ -74,7 +74,7 @@ class ExpandableSectionScreen extends PureComponent {
|
|
|
74
74
|
getBodyElement() {
|
|
75
75
|
return (
|
|
76
76
|
<Carousel pageWidth={350} itemSpacings={Spacings.s2}>
|
|
77
|
-
{_.map(elements, (element, key) => {
|
|
77
|
+
{_.map(this.elements, (element, key) => {
|
|
78
78
|
return (
|
|
79
79
|
<View key={key} margin-12>
|
|
80
80
|
{element}
|
|
@@ -99,7 +99,7 @@ class ExpandableSectionScreen extends PureComponent {
|
|
|
99
99
|
onValueChange={() => {
|
|
100
100
|
this.setState({top: !this.state.top});
|
|
101
101
|
}}
|
|
102
|
-
|
|
102
|
+
/>
|
|
103
103
|
</View>
|
|
104
104
|
<ExpandableSection
|
|
105
105
|
top={top}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import React, {Component} from 'react';
|
|
3
3
|
import {ScrollView} from 'react-native';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
View,
|
|
6
|
+
Colors,
|
|
7
|
+
Icon,
|
|
8
|
+
Dialog,
|
|
9
|
+
Text,
|
|
10
|
+
Picker,
|
|
11
|
+
Avatar,
|
|
12
|
+
Assets,
|
|
13
|
+
PanningProvider,
|
|
14
|
+
Typography
|
|
15
|
+
} from 'react-native-ui-lib'; //eslint-disable-line
|
|
5
16
|
import contactsData from '../../data/conversations';
|
|
6
17
|
import tagIcon from '../../assets/icons/tags.png';
|
|
7
18
|
import dropdown from '../../assets/icons/chevronDown.png';
|
|
@@ -239,7 +250,8 @@ export default class PickerScreen extends Component {
|
|
|
239
250
|
|
|
240
251
|
<Picker
|
|
241
252
|
migrate
|
|
242
|
-
|
|
253
|
+
migrateTextField
|
|
254
|
+
label="Language"
|
|
243
255
|
placeholder="Favorite Language"
|
|
244
256
|
value={this.state.language2}
|
|
245
257
|
onChange={value => this.setState({language2: value})}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
import React, {useCallback, useState} from 'react';
|
|
2
3
|
import {View, Text, Incubator, Colors, Typography, Button, Dialog} from 'react-native-ui-lib';
|
|
3
|
-
import _ from 'lodash';
|
|
4
|
-
|
|
5
|
-
type WheelPickerValue = Incubator.WheelPickerProps['initialValue'];
|
|
6
4
|
|
|
7
5
|
const monthItems = _.map([
|
|
8
6
|
'January',
|
|
@@ -18,18 +16,25 @@ const monthItems = _.map([
|
|
|
18
16
|
'November',
|
|
19
17
|
'December'
|
|
20
18
|
],
|
|
21
|
-
item => ({label: item, value: item}));
|
|
19
|
+
item => ({label: item, value: item, align: Incubator.WheelPickerAlign.RIGHT}));
|
|
22
20
|
|
|
23
|
-
const yearItems = _.times(
|
|
21
|
+
const yearItems = _.times(2050, i => i)
|
|
24
22
|
.reverse()
|
|
25
23
|
.map(item => ({label: `${item}`, value: item}));
|
|
26
24
|
const dayItems = _.times(31, i => i + 1).map(day => ({label: `${day}`, value: day}));
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
const [selectedMonth, setMonth] = useState<WheelPickerValue>(initialMonth);
|
|
30
|
-
const [, setYear] = useState<WheelPickerValue>(initialYear);
|
|
31
|
-
const [selectedDays, setDays] = useState<WheelPickerValue>(initialDays);
|
|
26
|
+
export default () => {
|
|
32
27
|
const [showDialog, setShowDialog] = useState(false);
|
|
28
|
+
const [yearsValue, setYearsValue] = useState(2022);
|
|
29
|
+
|
|
30
|
+
const updateYearsInitialValue = useCallback((increaseYears: boolean) => {
|
|
31
|
+
increaseYears ? setYearsValue(Math.min(yearsValue + 1, 2049)) : setYearsValue(Math.max(yearsValue - 1, 0));
|
|
32
|
+
},
|
|
33
|
+
[yearsValue]);
|
|
34
|
+
|
|
35
|
+
const onChange = useCallback((value) => {
|
|
36
|
+
setYearsValue(value);
|
|
37
|
+
}, []);
|
|
33
38
|
|
|
34
39
|
const onPickDaysPress = useCallback(() => {
|
|
35
40
|
setShowDialog(true);
|
|
@@ -39,75 +44,52 @@ const useData = (initialMonth?: string, initialYear?: string, initialDays?: numb
|
|
|
39
44
|
setShowDialog(false);
|
|
40
45
|
}, []);
|
|
41
46
|
|
|
42
|
-
const onMonthChange = useCallback((item: WheelPickerValue, _: number) => {
|
|
43
|
-
setMonth(item);
|
|
44
|
-
}, []);
|
|
45
|
-
|
|
46
|
-
const onYearChange = useCallback((item: WheelPickerValue, _: number) => {
|
|
47
|
-
setYear(item);
|
|
48
|
-
}, []);
|
|
49
|
-
|
|
50
|
-
const onDaysChange = useCallback((item: WheelPickerValue, _: number) => {
|
|
51
|
-
setDays(item);
|
|
52
|
-
}, []);
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
onMonthChange,
|
|
56
|
-
onYearChange,
|
|
57
|
-
onDaysChange,
|
|
58
|
-
selectedMonth,
|
|
59
|
-
selectedDays,
|
|
60
|
-
onPickDaysPress,
|
|
61
|
-
onDialogDismissed,
|
|
62
|
-
showDialog
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export default () => {
|
|
67
|
-
const {
|
|
68
|
-
selectedMonth,
|
|
69
|
-
onMonthChange,
|
|
70
|
-
onYearChange,
|
|
71
|
-
selectedDays,
|
|
72
|
-
onDaysChange,
|
|
73
|
-
onPickDaysPress,
|
|
74
|
-
onDialogDismissed,
|
|
75
|
-
showDialog
|
|
76
|
-
} = useData('February', undefined, 5);
|
|
77
|
-
|
|
78
47
|
return (
|
|
79
48
|
<View flex padding-page>
|
|
80
49
|
<Text h1>Wheel Picker</Text>
|
|
81
50
|
|
|
82
|
-
<View marginT-
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
51
|
+
<View row center marginT-30>
|
|
52
|
+
<View center>
|
|
53
|
+
<Text h3>Months</Text>
|
|
54
|
+
<Incubator.WheelPicker
|
|
55
|
+
initialValue={'February'}
|
|
56
|
+
activeTextColor={Colors.primary}
|
|
57
|
+
inactiveTextColor={Colors.grey20}
|
|
58
|
+
items={monthItems}
|
|
59
|
+
textStyle={Typography.text60R}
|
|
60
|
+
numberOfVisibleRows={3}
|
|
61
|
+
/>
|
|
62
|
+
</View>
|
|
92
63
|
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
(Uncontrolled, initialValue passed)
|
|
96
|
-
</Text>
|
|
97
|
-
<View width={'100%'} marginT-s3>
|
|
64
|
+
<View center>
|
|
65
|
+
<Text h3>Years</Text>
|
|
98
66
|
<Incubator.WheelPicker
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
initialValue={2021}
|
|
67
|
+
numberOfVisibleRows={3}
|
|
68
|
+
initialValue={yearsValue}
|
|
102
69
|
items={yearItems}
|
|
70
|
+
onChange={onChange}
|
|
103
71
|
/>
|
|
104
72
|
</View>
|
|
105
73
|
</View>
|
|
106
74
|
|
|
107
|
-
<View
|
|
108
|
-
<
|
|
75
|
+
<View center marginT-30>
|
|
76
|
+
<Text body>
|
|
77
|
+
Move the wheel programmatically
|
|
78
|
+
</Text>
|
|
79
|
+
<Text bodySmall grey30>
|
|
80
|
+
(by updating the initialValue prop)
|
|
81
|
+
</Text>
|
|
82
|
+
<View marginT-10 row>
|
|
83
|
+
<Button size="medium" label={'Previous'} marginR-20 onPress={() => updateYearsInitialValue(false)}/>
|
|
84
|
+
<Button size="medium" label={'Next'} onPress={() => updateYearsInitialValue(true)}/>
|
|
85
|
+
</View>
|
|
86
|
+
</View>
|
|
87
|
+
|
|
88
|
+
<View center marginT-40>
|
|
89
|
+
<Text h3 marginB-20>Days</Text>
|
|
90
|
+
<Button size="small" label={'Pick Days'} onPress={onPickDaysPress}/>
|
|
109
91
|
<Dialog width={'90%'} height={260} bottom visible={showDialog} onDismiss={onDialogDismissed}>
|
|
110
|
-
<Incubator.WheelPicker
|
|
92
|
+
<Incubator.WheelPicker initialValue={5} label={'Days'} items={dayItems}/>
|
|
111
93
|
</Dialog>
|
|
112
94
|
</View>
|
|
113
95
|
</View>
|