unicorn-demo-app 6.6.2 → 6.7.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 +1 -1
- package/src/screens/MenuStructure.js +1 -0
- package/src/screens/componentScreens/RadioButtonScreen.js +21 -25
- package/src/screens/incubatorScreens/IncubatorDialogScreen.tsx +14 -25
- package/src/screens/incubatorScreens/IncubatorTextFieldScreen.tsx +5 -0
- package/src/screens/incubatorScreens/IncubatorToastScreen.tsx +190 -0
- package/src/screens/incubatorScreens/index.js +1 -0
package/package.json
CHANGED
|
@@ -157,6 +157,7 @@ export const navigationData = {
|
|
|
157
157
|
{title: 'Native TouchableOpacity', tags: 'touchable native', screen: 'unicorn.incubator.TouchableOpacityScreen'},
|
|
158
158
|
{title: '(New) Dialog', tags: 'dialog modal popup alert', screen: 'unicorn.incubator.IncubatorDialogScreen'},
|
|
159
159
|
{title: '(New) TextField', tags: 'text field input', screen: 'unicorn.components.IncubatorTextFieldScreen'},
|
|
160
|
+
{title: '(New) Toast', tags: 'toast', screen: 'unicorn.components.IncubatorToastScreen'},
|
|
160
161
|
{title: 'ExpandableOverlay', tags: 'text field expandable input picker', screen: 'unicorn.components.IncubatorExpandableOverlayScreen'},
|
|
161
162
|
{title: 'WheelPicker (Incubator)', tags: 'wheel picker spinner experimental', screen: 'unicorn.incubator.WheelPickerScreen'},
|
|
162
163
|
{title: 'Pan View', tags: 'pan swipe drag', screen: 'unicorn.incubator.PanViewScreen'},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
|
-
import {TouchableOpacity, ScrollView
|
|
2
|
+
import {TouchableOpacity, ScrollView} from 'react-native';
|
|
3
3
|
import {Assets, RadioButton, Colors, Shadows, RadioGroup, View, Text} from 'react-native-ui-lib'; //eslint-disable-line
|
|
4
4
|
const starIcon = require('../../assets/icons/star.png');
|
|
5
5
|
|
|
@@ -39,7 +39,14 @@ export default class RadioButtonScreen extends Component {
|
|
|
39
39
|
renderRadioButtonWithImage(value, icon, style) {
|
|
40
40
|
return (
|
|
41
41
|
<View row centerV marginR-15>
|
|
42
|
-
<RadioButton
|
|
42
|
+
<RadioButton
|
|
43
|
+
value={value}
|
|
44
|
+
size={15}
|
|
45
|
+
color={Colors.green30}
|
|
46
|
+
borderRadius={0}
|
|
47
|
+
iconSource={icon}
|
|
48
|
+
iconStyle={style}
|
|
49
|
+
/>
|
|
43
50
|
</View>
|
|
44
51
|
);
|
|
45
52
|
}
|
|
@@ -55,8 +62,12 @@ export default class RadioButtonScreen extends Component {
|
|
|
55
62
|
render() {
|
|
56
63
|
return (
|
|
57
64
|
<View flex useSafeArea bg-grey80>
|
|
58
|
-
<
|
|
59
|
-
<
|
|
65
|
+
<ScrollView>
|
|
66
|
+
<View padding-page>
|
|
67
|
+
<Text h1 marginB-s5>
|
|
68
|
+
Radio Buttons
|
|
69
|
+
</Text>
|
|
70
|
+
|
|
60
71
|
<RadioGroup initialValue={this.state.color || null} onValueChange={value => this.setState({color: value})}>
|
|
61
72
|
<Text marginB-20 text60 grey10>
|
|
62
73
|
Select a color{'\n'}
|
|
@@ -69,7 +80,11 @@ export default class RadioButtonScreen extends Component {
|
|
|
69
80
|
<Text marginT-10>You chose: {this.state.color ? this.state.color : 'Default'}</Text>
|
|
70
81
|
</RadioGroup>
|
|
71
82
|
|
|
72
|
-
<RadioGroup
|
|
83
|
+
<RadioGroup
|
|
84
|
+
marginT-30
|
|
85
|
+
initialValue={this.state.textSide}
|
|
86
|
+
onValueChange={value => this.setState({textSide: value})}
|
|
87
|
+
>
|
|
73
88
|
<Text marginB-20 text60 grey10>
|
|
74
89
|
Alignments
|
|
75
90
|
</Text>
|
|
@@ -129,28 +144,9 @@ export default class RadioButtonScreen extends Component {
|
|
|
129
144
|
</View>
|
|
130
145
|
|
|
131
146
|
<View style={{height: 30}}/>
|
|
132
|
-
</ScrollView>
|
|
133
|
-
|
|
134
|
-
<View paddingH-20 paddingV-10 style={[styles.shadow, {backgroundColor: Colors.grey80}]}>
|
|
135
|
-
<Text text40 grey10>
|
|
136
|
-
Radio Buttons
|
|
137
|
-
</Text>
|
|
138
147
|
</View>
|
|
139
|
-
</
|
|
148
|
+
</ScrollView>
|
|
140
149
|
</View>
|
|
141
150
|
);
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
|
-
|
|
145
|
-
const styles = StyleSheet.create({
|
|
146
|
-
shadow: {
|
|
147
|
-
...Platform.select({
|
|
148
|
-
ios: {
|
|
149
|
-
...Shadows.grey20.bottom
|
|
150
|
-
},
|
|
151
|
-
android: {
|
|
152
|
-
elevation: 3
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {StyleSheet, ModalProps} from 'react-native';
|
|
3
3
|
import {FlatList} from 'react-native-gesture-handler';
|
|
4
|
-
import {View, Text, Card, Button, Incubator, Colors,
|
|
4
|
+
import {View, Text, Card, Button, Incubator, Colors, Spacings} from 'react-native-ui-lib';
|
|
5
5
|
|
|
6
6
|
interface Item {
|
|
7
7
|
value: string;
|
|
@@ -34,10 +34,11 @@ const colors: Item[] = [
|
|
|
34
34
|
export default class IncubatorDialogScreen extends Component {
|
|
35
35
|
state = {visible: false};
|
|
36
36
|
modalProps: ModalProps = {supportedOrientations: ['portrait', 'landscape']};
|
|
37
|
+
headerProps: Incubator.DialogHeaderProps = {text: {title: 'Title (swipe here)'}};
|
|
37
38
|
|
|
38
39
|
renderVerticalItem = ({item}: {item: Item}) => {
|
|
39
40
|
return (
|
|
40
|
-
<Text text50
|
|
41
|
+
<Text text50 marginH-s5 marginV-s2 color={item.value} onPress={this.closeDialog}>
|
|
41
42
|
{item.label}
|
|
42
43
|
</Text>
|
|
43
44
|
);
|
|
@@ -63,12 +64,12 @@ export default class IncubatorDialogScreen extends Component {
|
|
|
63
64
|
const {visible} = this.state;
|
|
64
65
|
|
|
65
66
|
return (
|
|
66
|
-
<View bg-
|
|
67
|
+
<View bg-grey80 flex padding-20>
|
|
67
68
|
<Card height={100} center padding-20>
|
|
68
69
|
<Text text50>IncubatorDialogScreen</Text>
|
|
69
70
|
</Card>
|
|
70
71
|
<View flex center>
|
|
71
|
-
<Button marginV-
|
|
72
|
+
<Button marginV-s5 label="Open Dialog" onPress={this.openDialog}/>
|
|
72
73
|
</View>
|
|
73
74
|
<Incubator.Dialog
|
|
74
75
|
useSafeArea
|
|
@@ -77,20 +78,15 @@ export default class IncubatorDialogScreen extends Component {
|
|
|
77
78
|
bottom
|
|
78
79
|
centerH
|
|
79
80
|
modalProps={this.modalProps}
|
|
81
|
+
headerProps={this.headerProps}
|
|
80
82
|
>
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
style={styles.verticalScroll}
|
|
89
|
-
data={colors}
|
|
90
|
-
renderItem={this.renderVerticalItem}
|
|
91
|
-
keyExtractor={this.keyExtractor}
|
|
92
|
-
/>
|
|
93
|
-
</View>
|
|
83
|
+
<FlatList
|
|
84
|
+
showsVerticalScrollIndicator={false}
|
|
85
|
+
contentContainerStyle={styles.verticalScroll}
|
|
86
|
+
data={colors}
|
|
87
|
+
renderItem={this.renderVerticalItem}
|
|
88
|
+
keyExtractor={this.keyExtractor}
|
|
89
|
+
/>
|
|
94
90
|
</Incubator.Dialog>
|
|
95
91
|
</View>
|
|
96
92
|
);
|
|
@@ -98,14 +94,7 @@ export default class IncubatorDialogScreen extends Component {
|
|
|
98
94
|
}
|
|
99
95
|
|
|
100
96
|
const styles = StyleSheet.create({
|
|
101
|
-
dialog: {
|
|
102
|
-
marginBottom: 20,
|
|
103
|
-
backgroundColor: Colors.white,
|
|
104
|
-
maxHeight: Constants.screenHeight * 0.8,
|
|
105
|
-
width: 300,
|
|
106
|
-
borderRadius: BorderRadiuses.br20
|
|
107
|
-
},
|
|
108
97
|
verticalScroll: {
|
|
109
|
-
|
|
98
|
+
paddingVertical: Spacings.s2
|
|
110
99
|
}
|
|
111
100
|
});
|
|
@@ -228,6 +228,11 @@ export default class TextFieldScreen extends Component {
|
|
|
228
228
|
placeholder="Enter text..."
|
|
229
229
|
multiline
|
|
230
230
|
showCharCounter
|
|
231
|
+
bottomAccessory={
|
|
232
|
+
<Text text100>
|
|
233
|
+
{Assets.emojis.grapes} {Assets.emojis.melon} {Assets.emojis.banana}
|
|
234
|
+
</Text>
|
|
235
|
+
}
|
|
231
236
|
charCounterStyle={{color: Colors.blue30}}
|
|
232
237
|
maxLength={20}
|
|
233
238
|
fieldStyle={styles.withFrame}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import React, {Component} from 'react';
|
|
2
|
+
import {ScrollView, StyleSheet} from 'react-native';
|
|
3
|
+
import {Assets, Colors, View, Button, Text, Incubator} from 'react-native-ui-lib';
|
|
4
|
+
import {renderMultipleSegmentOptions, renderBooleanOption, renderRadioGroup} from '../ExampleScreenPresenter';
|
|
5
|
+
|
|
6
|
+
const {Toast} = Incubator;
|
|
7
|
+
|
|
8
|
+
const TOAST_ACTIONS = {
|
|
9
|
+
label: {label: 'Undo', onPress: () => console.warn('undo')},
|
|
10
|
+
icon: {iconSource: Assets.icons.demo.plus, onPress: () => console.warn('add')}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const TOAST_MESSAGES = {
|
|
14
|
+
general: 'La formule Pass VIP illimité 5 mois est masquée',
|
|
15
|
+
success: 'The action completed successfully.',
|
|
16
|
+
failure: 'The action could not be completed.',
|
|
17
|
+
offline: 'Check Your Internet Connection'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default class ToastsScreen extends Component {
|
|
21
|
+
showToast = false; // keep this state in class instance for immediate response
|
|
22
|
+
state = {
|
|
23
|
+
visible: false,
|
|
24
|
+
toastPosition: 'bottom' as Incubator.ToastProps['position'],
|
|
25
|
+
isCustomContent: false,
|
|
26
|
+
showLoader: false,
|
|
27
|
+
selectedAction: '',
|
|
28
|
+
hasAttachment: false,
|
|
29
|
+
selectedPreset: '' as Incubator.ToastProps['preset'],
|
|
30
|
+
isSwipeable: true
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
toggleVisibility = () => {
|
|
34
|
+
// Im using this for storing toast visible since setState is async and takes time to response
|
|
35
|
+
this.showToast = !this.showToast;
|
|
36
|
+
this.setState({
|
|
37
|
+
visible: this.showToast
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
renderCustomContent = () => {
|
|
42
|
+
return (
|
|
43
|
+
<View flex padding-10 bg-white>
|
|
44
|
+
<Text text60>This is a custom content</Text>
|
|
45
|
+
<Text>
|
|
46
|
+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry
|
|
47
|
+
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to
|
|
48
|
+
make a type specimen book.
|
|
49
|
+
</Text>
|
|
50
|
+
</View>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
renderAboveToast = () => {
|
|
55
|
+
return (
|
|
56
|
+
<View flex bottom right paddingB-50 paddingR-20 pointerEvents={'box-none'}>
|
|
57
|
+
<Button iconSource={Assets.icons.demo.dashboard} color={Colors.white} style={{height: 50, width: 50}}/>
|
|
58
|
+
</View>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
renderBelowToast = () => {
|
|
63
|
+
return <Text>Attachment below toast</Text>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
renderAttachment = () => {
|
|
67
|
+
const {toastPosition, hasAttachment} = this.state;
|
|
68
|
+
if (hasAttachment) {
|
|
69
|
+
if (toastPosition === 'bottom') {
|
|
70
|
+
return this.renderAboveToast();
|
|
71
|
+
} else {
|
|
72
|
+
return this.renderBelowToast();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
getAction = () => {
|
|
78
|
+
const {selectedAction} = this.state;
|
|
79
|
+
return TOAST_ACTIONS[selectedAction];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
getMessage = () => {
|
|
83
|
+
const {selectedPreset} = this.state;
|
|
84
|
+
|
|
85
|
+
return TOAST_MESSAGES[selectedPreset] || TOAST_MESSAGES.general;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
renderToast = () => {
|
|
89
|
+
const {visible, toastPosition, showLoader, isCustomContent, hasAttachment, selectedPreset, isSwipeable} =
|
|
90
|
+
this.state;
|
|
91
|
+
const action = this.getAction();
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Toast
|
|
95
|
+
key={`${toastPosition}-${isCustomContent}-${hasAttachment}`}
|
|
96
|
+
visible={visible}
|
|
97
|
+
position={toastPosition}
|
|
98
|
+
message={this.getMessage()}
|
|
99
|
+
showLoader={showLoader}
|
|
100
|
+
renderAttachment={this.renderAttachment}
|
|
101
|
+
action={action}
|
|
102
|
+
preset={selectedPreset}
|
|
103
|
+
swipeable={isSwipeable}
|
|
104
|
+
onDismiss={this.toggleVisibility}
|
|
105
|
+
autoDismiss={3500}
|
|
106
|
+
// backgroundColor={Colors.green70}
|
|
107
|
+
// icon={Assets.icons.demo.add}
|
|
108
|
+
// iconColor={Colors.green20}
|
|
109
|
+
// style={{borderWidth: 1, borderColor: Colors.grey30}}
|
|
110
|
+
// messageStyle={Typography.text80BO}
|
|
111
|
+
>
|
|
112
|
+
{isCustomContent ? this.renderCustomContent() : undefined}
|
|
113
|
+
</Toast>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
renderToggleButton = () => {
|
|
118
|
+
return (
|
|
119
|
+
<View centerH marginT-s5>
|
|
120
|
+
<Button
|
|
121
|
+
testID={`uilib.showToast`}
|
|
122
|
+
marginT-10
|
|
123
|
+
marginB-10
|
|
124
|
+
label={'Toggle toast'}
|
|
125
|
+
onPress={this.toggleVisibility}
|
|
126
|
+
/>
|
|
127
|
+
</View>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
render() {
|
|
132
|
+
return (
|
|
133
|
+
<View flex padding-page>
|
|
134
|
+
<Text h1 marginB-s4>
|
|
135
|
+
Toast
|
|
136
|
+
</Text>
|
|
137
|
+
|
|
138
|
+
<View flex style={styles.scrollViewContainer}>
|
|
139
|
+
<ScrollView contentContainerStyle={styles.scrollView}>
|
|
140
|
+
{renderMultipleSegmentOptions.call(this, 'Toast Position', 'toastPosition', [
|
|
141
|
+
{label: 'Bottom', value: 'bottom'},
|
|
142
|
+
{label: 'Top', value: 'top'}
|
|
143
|
+
])}
|
|
144
|
+
|
|
145
|
+
{renderBooleanOption.call(this, 'Show Loader', 'showLoader')}
|
|
146
|
+
{renderBooleanOption.call(this, 'Use custom content', 'isCustomContent')}
|
|
147
|
+
{renderBooleanOption.call(this, 'With an attachment', 'hasAttachment')}
|
|
148
|
+
{renderBooleanOption.call(this, 'Swipeable', 'isSwipeable')}
|
|
149
|
+
|
|
150
|
+
{renderRadioGroup.call(this,
|
|
151
|
+
'Action',
|
|
152
|
+
'selectedAction',
|
|
153
|
+
{None: '', Label: 'label', Icon: 'icon'},
|
|
154
|
+
{isRow: true})}
|
|
155
|
+
|
|
156
|
+
<Text h3 marginV-s2>
|
|
157
|
+
Presets
|
|
158
|
+
</Text>
|
|
159
|
+
|
|
160
|
+
{renderMultipleSegmentOptions.call(this, '', 'selectedPreset', [
|
|
161
|
+
{label: 'None', value: ''},
|
|
162
|
+
{label: 'General', value: 'general'},
|
|
163
|
+
{label: 'Success', value: 'success'},
|
|
164
|
+
{label: 'Failure', value: 'failure'},
|
|
165
|
+
{label: 'Offline', value: 'offline'}
|
|
166
|
+
])}
|
|
167
|
+
|
|
168
|
+
{this.renderToggleButton()}
|
|
169
|
+
</ScrollView>
|
|
170
|
+
</View>
|
|
171
|
+
{this.renderToast()}
|
|
172
|
+
</View>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const styles = StyleSheet.create({
|
|
178
|
+
scrollView: {
|
|
179
|
+
paddingBottom: 80
|
|
180
|
+
},
|
|
181
|
+
color: {
|
|
182
|
+
width: 30,
|
|
183
|
+
height: 30,
|
|
184
|
+
borderRadius: 15
|
|
185
|
+
},
|
|
186
|
+
selected: {
|
|
187
|
+
borderWidth: 2,
|
|
188
|
+
borderColor: Colors.grey10
|
|
189
|
+
}
|
|
190
|
+
});
|
|
@@ -7,6 +7,7 @@ export function registerScreens(registrar) {
|
|
|
7
7
|
registrar('unicorn.incubator.IncubatorDialogScreen', () => require('./IncubatorDialogScreen').default);
|
|
8
8
|
registrar('unicorn.components.IncubatorExpandableOverlayScreen', () => require('./IncubatorExpandableOverlayScreen').default);
|
|
9
9
|
registrar('unicorn.components.IncubatorTextFieldScreen', () => require('./IncubatorTextFieldScreen').default);
|
|
10
|
+
registrar('unicorn.components.IncubatorToastScreen', () => require('./IncubatorToastScreen').default);
|
|
10
11
|
registrar('unicorn.incubator.PanViewScreen', () => require('./PanViewScreen').default);
|
|
11
12
|
registrar('unicorn.incubator.TransitionViewScreen', () => require('./TransitionViewScreen').default);
|
|
12
13
|
registrar('unicorn.incubator.WheelPickerScreen', () => gestureHandlerRootHOC(require('./WheelPickerScreen').default));
|