unicorn-demo-app 7.35.1 → 7.36.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
package/src/index.js
CHANGED
|
@@ -267,6 +267,9 @@ module.exports = {
|
|
|
267
267
|
get Pinterest() {
|
|
268
268
|
return require('./screens/realExamples/Pinterest').default;
|
|
269
269
|
},
|
|
270
|
+
get PieChartScreen() {
|
|
271
|
+
return require('./screens/componentScreens/PieChartScreen.tsx').default;
|
|
272
|
+
},
|
|
270
273
|
get ListActionsScreen() {
|
|
271
274
|
return require('./screens/realExamples/ListActions/ListActionsScreen').default;
|
|
272
275
|
},
|
|
@@ -104,6 +104,12 @@ export const navigationData = {
|
|
|
104
104
|
{title: 'SortableGridList', tags: 'sort grid list drag', screen: 'unicorn.components.SortableGridListScreen'}
|
|
105
105
|
]
|
|
106
106
|
},
|
|
107
|
+
Charts: {
|
|
108
|
+
title: 'Charts',
|
|
109
|
+
screens: [
|
|
110
|
+
{title: 'PieChart', tags: 'pie chart data', screen: 'unicorn.components.PieChartScreen'}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
107
113
|
LayoutsAndTemplates: {
|
|
108
114
|
title: 'Layouts & Templates',
|
|
109
115
|
screens: [
|
|
@@ -83,6 +83,15 @@ const dialogOptions = [
|
|
|
83
83
|
{label: 'Option 8', value: 6}
|
|
84
84
|
];
|
|
85
85
|
|
|
86
|
+
const statusOptions = [
|
|
87
|
+
{label: 'Overview', value: 'overview'},
|
|
88
|
+
{label: 'In Progress', value: 'inProgress'},
|
|
89
|
+
{label: 'Completed', value: 'completed'},
|
|
90
|
+
{label: 'Pending Review', value: 'pendingReview'},
|
|
91
|
+
{label: 'Approved', value: 'approved'},
|
|
92
|
+
{label: 'Rejected', value: 'rejected'}
|
|
93
|
+
];
|
|
94
|
+
|
|
86
95
|
export default class PickerScreen extends Component {
|
|
87
96
|
picker = React.createRef<PickerMethods>();
|
|
88
97
|
state = {
|
|
@@ -96,6 +105,7 @@ export default class PickerScreen extends Component {
|
|
|
96
105
|
dialogPickerValue: 'java',
|
|
97
106
|
customModalValues: [],
|
|
98
107
|
filter: undefined,
|
|
108
|
+
statOption: [],
|
|
99
109
|
scheme: undefined,
|
|
100
110
|
contact: 0
|
|
101
111
|
};
|
|
@@ -122,6 +132,15 @@ export default class PickerScreen extends Component {
|
|
|
122
132
|
);
|
|
123
133
|
};
|
|
124
134
|
|
|
135
|
+
onTopElementPress = (allOptionsSelected: boolean) => {
|
|
136
|
+
if (allOptionsSelected) {
|
|
137
|
+
this.setState({statOption: []});
|
|
138
|
+
} else {
|
|
139
|
+
const allValues = statusOptions.map(option => option.value);
|
|
140
|
+
this.setState({statOption: allValues});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
125
144
|
render() {
|
|
126
145
|
return (
|
|
127
146
|
<ScrollView keyboardShouldPersistTaps="always">
|
|
@@ -195,7 +214,32 @@ export default class PickerScreen extends Component {
|
|
|
195
214
|
searchPlaceholder={'Search a language'}
|
|
196
215
|
items={dialogOptions}
|
|
197
216
|
/>
|
|
198
|
-
|
|
217
|
+
|
|
218
|
+
<Text text70 $textDefault>
|
|
219
|
+
Custom Top Element:
|
|
220
|
+
</Text>
|
|
221
|
+
<Picker
|
|
222
|
+
placeholder="Status"
|
|
223
|
+
floatingPlaceholder
|
|
224
|
+
value={this.state.statOption}
|
|
225
|
+
onChange={items => this.setState({statOption: items})}
|
|
226
|
+
topBarProps={{title: 'Status'}}
|
|
227
|
+
mode={Picker.modes.MULTI}
|
|
228
|
+
items={statusOptions}
|
|
229
|
+
renderCustomTopElement={value => {
|
|
230
|
+
const allOptionsSelected = Array.isArray(value) && value.length === statusOptions.length;
|
|
231
|
+
return (
|
|
232
|
+
<View margin-s3>
|
|
233
|
+
<Button
|
|
234
|
+
label={allOptionsSelected ? 'Unselect All' : 'Select All'}
|
|
235
|
+
onPress={() => this.onTopElementPress(allOptionsSelected)}
|
|
236
|
+
size="small"
|
|
237
|
+
/>
|
|
238
|
+
</View>
|
|
239
|
+
);
|
|
240
|
+
}}
|
|
241
|
+
/>
|
|
242
|
+
|
|
199
243
|
<Text marginB-10 text70 $textDefault>
|
|
200
244
|
Custom Picker:
|
|
201
245
|
</Text>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {ScrollView} from 'react-native';
|
|
3
|
+
import {View, PieChart, Card, Text, Badge, PieChartSegmentProps, Colors} from 'react-native-ui-lib';
|
|
4
|
+
|
|
5
|
+
const SEGMENTS: PieChartSegmentProps[] = [
|
|
6
|
+
{
|
|
7
|
+
percentage: 40,
|
|
8
|
+
color: Colors.blue30
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
percentage: 30,
|
|
12
|
+
color: Colors.red30
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
percentage: 20,
|
|
16
|
+
color: Colors.green30
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
percentage: 10,
|
|
20
|
+
color: Colors.purple30
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const MONOCHROME_SEGMENTS: PieChartSegmentProps[] = [
|
|
25
|
+
{
|
|
26
|
+
percentage: 40,
|
|
27
|
+
color: Colors.blue70
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
percentage: 30,
|
|
31
|
+
color: Colors.blue50
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
percentage: 20,
|
|
35
|
+
color: Colors.blue30
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
percentage: 10,
|
|
39
|
+
color: Colors.blue10
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const NOT_FULL_PIECHART: PieChartSegmentProps[] = [
|
|
44
|
+
{
|
|
45
|
+
percentage: 30,
|
|
46
|
+
color: Colors.blue30
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
percentage: 40,
|
|
50
|
+
color: Colors.red30
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const PieChartScreen = () => {
|
|
55
|
+
const renderSegmentLabel = (segment: PieChartSegmentProps, text: string) => {
|
|
56
|
+
const {percentage, color} = segment;
|
|
57
|
+
return (
|
|
58
|
+
<View row gap-s1 marginB-s1 key={text}>
|
|
59
|
+
<Badge size={10} containerStyle={{justifyContent: 'center'}} backgroundColor={color}/>
|
|
60
|
+
<View>
|
|
61
|
+
<Text>{text}</Text>
|
|
62
|
+
<Text marginL-s1>{percentage}%</Text>
|
|
63
|
+
</View>
|
|
64
|
+
</View>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const renderPieChartCard = (segments: PieChartSegmentProps[]) => {
|
|
69
|
+
return (
|
|
70
|
+
<Card row spread paddingL-s2 paddingR-s10 paddingV-s2>
|
|
71
|
+
<View centerV>
|
|
72
|
+
<PieChart segments={segments} diameter={150}/>
|
|
73
|
+
</View>
|
|
74
|
+
<View height={'100%'} gap-s1>
|
|
75
|
+
{segments.map((segment, index) => renderSegmentLabel(segment, `Value ${index + 1}`))}
|
|
76
|
+
</View>
|
|
77
|
+
</Card>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<ScrollView>
|
|
83
|
+
<View padding-page gap-s2>
|
|
84
|
+
<Text text50L marginB-s2>
|
|
85
|
+
PieChart
|
|
86
|
+
</Text>
|
|
87
|
+
{renderPieChartCard(SEGMENTS)}
|
|
88
|
+
<Text text50L marginV-s2>
|
|
89
|
+
Monochrome colors
|
|
90
|
+
</Text>
|
|
91
|
+
{renderPieChartCard(MONOCHROME_SEGMENTS)}
|
|
92
|
+
<Text text50L marginV-s2>
|
|
93
|
+
Not Full PieChart
|
|
94
|
+
</Text>
|
|
95
|
+
{renderPieChartCard(NOT_FULL_PIECHART)}
|
|
96
|
+
</View>
|
|
97
|
+
</ScrollView>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default PieChartScreen;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export function registerScreens(registrar) {
|
|
2
2
|
registrar('unicorn.components.ActionSheetScreen', () => require('./ActionSheetScreen').default);
|
|
3
|
+
registrar('unicorn.components.PieChartScreen', () => require('./PieChartScreen').default);
|
|
3
4
|
registrar('unicorn.components.ActionBarScreen', () => require('./ActionBarScreen').default);
|
|
4
5
|
registrar('unicorn.components.AvatarsScreen', () => require('./AvatarsScreen').default);
|
|
5
6
|
registrar('unicorn.components.AnimatedImageScreen', () => require('./AnimatedImageScreen').default);
|