unicorn-demo-app 7.21.2 → 7.22.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/assets/Assets.ts +25 -0
- package/src/configurations.js +3 -26
- package/src/screens/componentScreens/DrawerScreen.tsx +2 -1
- package/src/screens/componentScreens/HintsScreen.tsx +2 -1
- package/src/screens/componentScreens/ImageScreen.tsx +7 -3
- package/src/screens/componentScreens/ModalScreen.tsx +2 -1
- package/src/screens/componentScreens/SortableGridListScreen.tsx +1 -0
- package/src/screens/componentScreens/SortableListScreen.tsx +2 -1
- package/src/screens/componentScreens/TabControllerScreen/index.tsx +1 -1
- package/src/screens/componentScreens/TextFieldScreen.tsx +335 -242
- package/src/screens/componentScreens/TimelineScreen.tsx +2 -2
- package/src/screens/incubatorScreens/IncubatorToastScreen.tsx +2 -2
- package/src/screens/incubatorScreens/PanViewScreen.tsx +1 -2
- package/src/screens/realExamples/Pinterest/index.tsx +2 -1
- package/src/screens/realExamples/ProductPage/index.tsx +2 -1
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {Assets} from 'react-native-ui-lib';
|
|
2
|
+
Assets.loadAssetsGroup('icons.demo', {
|
|
3
|
+
chevronDown: require('./icons/chevronDown.png'),
|
|
4
|
+
chevronRight: require('./icons/chevronRight.png'),
|
|
5
|
+
add: require('./icons/add.png'),
|
|
6
|
+
camera: require('./icons/cameraSelected.png'),
|
|
7
|
+
close: require('./icons/close.png'),
|
|
8
|
+
dashboard: require('./icons/dashboard.png'),
|
|
9
|
+
drag: require('./icons/drag.png'),
|
|
10
|
+
image: require('./icons/image.png'),
|
|
11
|
+
plus: require('./icons/plus.png'),
|
|
12
|
+
refresh: require('./icons/refresh.png'),
|
|
13
|
+
search: require('./icons/search.png'),
|
|
14
|
+
settings: require('./icons/settings.png'),
|
|
15
|
+
share: require('./icons/share.png')
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
Assets.loadAssetsGroup('images.demo', {
|
|
19
|
+
brokenImage: require('./images/placeholderMissingImage.png')
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
Assets.loadAssetsGroup('svgs.demo', {
|
|
23
|
+
logo: require('./svgs/headerLogo.svg').default
|
|
24
|
+
});
|
|
25
|
+
export default Assets as typeof Assets;
|
package/src/configurations.js
CHANGED
|
@@ -1,30 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Colors, Typography, Spacings, TextField} from 'react-native-ui-lib'; // eslint-disable-line
|
|
2
2
|
|
|
3
3
|
export const loadDemoConfigurations = () => {
|
|
4
|
-
|
|
5
|
-
chevronDown: require('./assets/icons/chevronDown.png'),
|
|
6
|
-
chevronRight: require('./assets/icons/chevronRight.png'),
|
|
7
|
-
add: require('./assets/icons/add.png'),
|
|
8
|
-
camera: require('./assets/icons/cameraSelected.png'),
|
|
9
|
-
close: require('./assets/icons/close.png'),
|
|
10
|
-
dashboard: require('./assets/icons/dashboard.png'),
|
|
11
|
-
drag: require('./assets/icons/drag.png'),
|
|
12
|
-
image: require('./assets/icons/image.png'),
|
|
13
|
-
plus: require('./assets/icons/plus.png'),
|
|
14
|
-
refresh: require('./assets/icons/refresh.png'),
|
|
15
|
-
search: require('./assets/icons/search.png'),
|
|
16
|
-
settings: require('./assets/icons/settings.png'),
|
|
17
|
-
share: require('./assets/icons/share.png')
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
Assets.loadAssetsGroup('images.demo', {
|
|
21
|
-
brokenImage: require('./assets/images/placeholderMissingImage.png')
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
Assets.loadAssetsGroup('svgs.demo', {
|
|
25
|
-
logo: require('./assets/svgs/headerLogo.svg').default
|
|
26
|
-
});
|
|
27
|
-
|
|
4
|
+
require('./assets/Assets');
|
|
28
5
|
Typography.loadTypographies({
|
|
29
6
|
h1: {...Typography.text40},
|
|
30
7
|
h2: {...Typography.text50},
|
|
@@ -56,5 +33,5 @@ export const loadDemoConfigurations = () => {
|
|
|
56
33
|
});
|
|
57
34
|
|
|
58
35
|
/* Components */
|
|
59
|
-
|
|
36
|
+
TextField.defaultProps = {...TextField.defaultProps, preset: TextField.presets.UNDERLINE};
|
|
60
37
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {StyleSheet, ScrollView, LayoutAnimation} from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import {Colors, Typography, View, Drawer, Text, Button, Avatar, Badge, DrawerProps} from 'react-native-ui-lib';
|
|
4
4
|
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
|
|
5
5
|
import conversations from '../../data/conversations';
|
|
6
|
+
import Assets from '../../assets/Assets';
|
|
6
7
|
|
|
7
8
|
import {renderBooleanOption, renderSliderOption, renderColorOption} from '../ExampleScreenPresenter';
|
|
8
9
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import React, {Component} from 'react';
|
|
3
3
|
import {Alert, ViewStyle} from 'react-native';
|
|
4
|
-
import {Colors, View, Text, Hint, Button,
|
|
4
|
+
import {Colors, View, Text, Hint, Button, Incubator} from 'react-native-ui-lib';
|
|
5
5
|
import {renderMultipleSegmentOptions, renderBooleanOption} from '../ExampleScreenPresenter';
|
|
6
|
+
import Assets from '../../assets/Assets';
|
|
6
7
|
|
|
7
8
|
const settingsIcon = require('../../assets/icons/settings.png');
|
|
8
9
|
const reactions = ['❤️', '😮', '😔', '😂', '😡'];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {ScrollView} from 'react-native';
|
|
3
|
-
import {View, Text, Icon, Image, Colors,
|
|
3
|
+
import {View, Text, Icon, Image, Colors, OverlayTypes} from 'react-native-ui-lib';
|
|
4
4
|
import {renderBooleanOption, renderRadioGroup, renderSliderOption} from '../ExampleScreenPresenter';
|
|
5
|
+
import Assets from '../../assets/Assets';
|
|
5
6
|
|
|
6
7
|
const IMAGE_URL =
|
|
7
8
|
'https://images.pexels.com/photos/748837/pexels-photo-748837.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260';
|
|
@@ -69,7 +70,8 @@ class ImageScreen extends Component<{}, State> {
|
|
|
69
70
|
showErrorImage: false,
|
|
70
71
|
showSvg: false,
|
|
71
72
|
svgType: SvgType.File,
|
|
72
|
-
sizeType: SizeType.None
|
|
73
|
+
sizeType: SizeType.None,
|
|
74
|
+
borderRadius: 0
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
getSvgSource() {
|
|
@@ -112,7 +114,7 @@ class ImageScreen extends Component<{}, State> {
|
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
renderImage() {
|
|
115
|
-
const {cover, overlayType, overlayIntensity, margin, showErrorImage} = this.state;
|
|
117
|
+
const {cover, overlayType, overlayIntensity, margin, showErrorImage, borderRadius} = this.state;
|
|
116
118
|
return (
|
|
117
119
|
<Image
|
|
118
120
|
key={`${overlayType}-${overlayIntensity}`}
|
|
@@ -126,6 +128,7 @@ class ImageScreen extends Component<{}, State> {
|
|
|
126
128
|
height={!cover ? DEFAULT_SIZE : undefined}
|
|
127
129
|
customOverlayContent={this.renderOverlayContent()}
|
|
128
130
|
{...{[`margin-${margin}`]: true}}
|
|
131
|
+
borderRadius={borderRadius}
|
|
129
132
|
/>
|
|
130
133
|
);
|
|
131
134
|
}
|
|
@@ -156,6 +159,7 @@ class ImageScreen extends Component<{}, State> {
|
|
|
156
159
|
{renderRadioGroup.call(this, 'Overlay Intensity', 'overlayIntensity', Image.overlayIntensityType)}
|
|
157
160
|
</View>
|
|
158
161
|
{renderSliderOption.call(this, 'Margin(margin-XX)', 'margin', {step: 4, min: 0, max: 40})}
|
|
162
|
+
{renderSliderOption.call(this, 'Border Radius', 'borderRadius', {step: 5, min: 0, max: 100})}
|
|
159
163
|
</>
|
|
160
164
|
);
|
|
161
165
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {Alert, StyleSheet} from 'react-native';
|
|
3
3
|
import {Navigation} from 'react-native-navigation';
|
|
4
|
-
import {Colors, Carousel, PageControl, Modal, View, Text
|
|
4
|
+
import {Colors, Carousel, PageControl, Modal, View, Text} from 'react-native-ui-lib'; // eslint-disable-line
|
|
5
|
+
import Assets from '../../assets/Assets';
|
|
5
6
|
|
|
6
7
|
const BUTTONS_HIT_SLOP = {right: 5, left: 5, top: 10, bottom: 10};
|
|
7
8
|
interface ModalScreenProps {
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
TouchableOpacity,
|
|
9
9
|
Text,
|
|
10
10
|
Icon,
|
|
11
|
-
Assets,
|
|
12
11
|
Colors,
|
|
13
12
|
Button
|
|
14
13
|
} from 'react-native-ui-lib';
|
|
14
|
+
import Assets from '../../assets/Assets';
|
|
15
15
|
import {renderHeader} from '../ExampleScreenPresenter';
|
|
16
16
|
|
|
17
17
|
interface Item extends SortableListItemProps {
|
|
@@ -112,6 +112,7 @@ const SortableListScreen = () => {
|
|
|
112
112
|
</View>
|
|
113
113
|
<View flex useSafeArea>
|
|
114
114
|
<SortableList
|
|
115
|
+
flexMigration
|
|
115
116
|
data={items}
|
|
116
117
|
renderItem={renderItem}
|
|
117
118
|
keyExtractor={keyExtractor}
|
|
@@ -2,7 +2,6 @@ import _ from 'lodash';
|
|
|
2
2
|
import React, {Component} from 'react';
|
|
3
3
|
import {ActivityIndicator, StyleSheet} from 'react-native';
|
|
4
4
|
import {
|
|
5
|
-
Assets,
|
|
6
5
|
TabController,
|
|
7
6
|
Colors,
|
|
8
7
|
View,
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
TabControllerImperativeMethods
|
|
13
12
|
} from 'react-native-ui-lib';
|
|
14
13
|
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
|
|
14
|
+
import Assets from '../../../assets/Assets';
|
|
15
15
|
|
|
16
16
|
import Tab1 from './tab1';
|
|
17
17
|
import Tab2 from './tab2';
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
1
|
import React, {Component} from 'react';
|
|
3
2
|
import {StyleSheet, ScrollView, ActivityIndicator} from 'react-native';
|
|
4
|
-
import {
|
|
3
|
+
import {Colors, Spacings, View, Text, Button, Keyboard, TextField, TextFieldRef, SegmentedControl} from 'react-native-ui-lib';
|
|
4
|
+
import Assets from '../../assets/Assets';
|
|
5
5
|
const {KeyboardAwareInsetsView} = Keyboard;
|
|
6
|
-
|
|
7
6
|
const priceFormatter = Intl.NumberFormat('en-US');
|
|
8
7
|
|
|
9
8
|
export default class TextFieldScreen extends Component {
|
|
10
9
|
input = React.createRef<TextFieldRef>();
|
|
11
10
|
input2 = React.createRef<TextFieldRef>();
|
|
11
|
+
input3 = React.createRef<TextFieldRef>();
|
|
12
12
|
inputWithValidation = React.createRef<TextFieldRef>();
|
|
13
|
+
|
|
13
14
|
state = {
|
|
14
|
-
errorPosition: TextField.validationMessagePositions.
|
|
15
|
-
|
|
15
|
+
errorPosition: TextField.validationMessagePositions.BOTTOM,
|
|
16
|
+
isDisabled: false,
|
|
16
17
|
isReadonly: false,
|
|
17
18
|
value: 'Initial Value',
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
isSearching: false,
|
|
20
|
+
customPreset: 'underline',
|
|
20
21
|
price: ''
|
|
21
22
|
};
|
|
22
23
|
|
|
@@ -28,9 +29,62 @@ export default class TextFieldScreen extends Component {
|
|
|
28
29
|
this.input2.current?.clear();
|
|
29
30
|
};
|
|
30
31
|
|
|
32
|
+
renderDefaultExample() {
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<Text h3 marginB-s1>
|
|
36
|
+
Default
|
|
37
|
+
</Text>
|
|
38
|
+
|
|
39
|
+
<TextField ref={this.input} placeholder="Enter full name" preset={null}/>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
renderPresetExample() {
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<Text h3 marginB-s1 marginT-s4>
|
|
48
|
+
Underline Preset
|
|
49
|
+
</Text>
|
|
50
|
+
|
|
51
|
+
<TextField ref={this.input} placeholder="Enter full name"/>
|
|
52
|
+
</>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
renderPlaceholdersExample() {
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<Text h3 marginB-s1 marginT-s4>
|
|
60
|
+
Static vs Floating Placeholder
|
|
61
|
+
</Text>
|
|
62
|
+
|
|
63
|
+
<View row bottom>
|
|
64
|
+
<TextField
|
|
65
|
+
placeholder="Floating placeholder"
|
|
66
|
+
floatingPlaceholder
|
|
67
|
+
floatingPlaceholderColor={{
|
|
68
|
+
focus: Colors.$textDefault,
|
|
69
|
+
default: Colors.$textNeutral
|
|
70
|
+
}}
|
|
71
|
+
// floatingPlaceholderStyle={Typography.text60}
|
|
72
|
+
// style={Typography.text60}
|
|
73
|
+
containerStyle={{flex: 1}}
|
|
74
|
+
/>
|
|
75
|
+
<TextField
|
|
76
|
+
placeholder="Placeholder"
|
|
77
|
+
containerStyle={{flex: 1, marginLeft: Spacings.s6}}
|
|
78
|
+
/>
|
|
79
|
+
</View>
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
31
84
|
renderTrailingAccessory() {
|
|
32
|
-
const {
|
|
33
|
-
|
|
85
|
+
const {isSearching} = this.state;
|
|
86
|
+
|
|
87
|
+
if (isSearching) {
|
|
34
88
|
return <ActivityIndicator color={Colors.$iconDefault}/>;
|
|
35
89
|
} else {
|
|
36
90
|
return (
|
|
@@ -40,9 +94,9 @@ export default class TextFieldScreen extends Component {
|
|
|
40
94
|
marginL-s2
|
|
41
95
|
$iconDefault
|
|
42
96
|
onPress={() => {
|
|
43
|
-
this.setState({
|
|
97
|
+
this.setState({isSearching: true});
|
|
44
98
|
setTimeout(() => {
|
|
45
|
-
this.setState({
|
|
99
|
+
this.setState({isSearching: false});
|
|
46
100
|
}, 1200);
|
|
47
101
|
}}
|
|
48
102
|
/>
|
|
@@ -50,253 +104,293 @@ export default class TextFieldScreen extends Component {
|
|
|
50
104
|
}
|
|
51
105
|
}
|
|
52
106
|
|
|
53
|
-
|
|
54
|
-
const {errorPosition, shouldDisable, isReadonly, price, preset} = this.state;
|
|
107
|
+
renderAccessoriesExample() {
|
|
55
108
|
return (
|
|
56
|
-
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
fieldStyle={styles.withUnderline}
|
|
78
|
-
/>
|
|
79
|
-
<TextField
|
|
80
|
-
placeholder="Placeholder"
|
|
81
|
-
containerStyle={{flex: 1, marginLeft: Spacings.s4}}
|
|
82
|
-
fieldStyle={styles.withUnderline}
|
|
83
|
-
/>
|
|
84
|
-
</View>
|
|
85
|
-
<Text h3 marginV-s4>
|
|
86
|
-
Accessories
|
|
87
|
-
</Text>
|
|
88
|
-
|
|
89
|
-
<TextField
|
|
90
|
-
ref={this.input2}
|
|
91
|
-
placeholder="Enter search term"
|
|
92
|
-
text70
|
|
93
|
-
trailingAccessory={this.renderTrailingAccessory()}
|
|
94
|
-
fieldStyle={styles.withUnderline}
|
|
95
|
-
marginB-s4
|
|
96
|
-
/>
|
|
97
|
-
|
|
98
|
-
<TextField
|
|
99
|
-
ref={this.input2}
|
|
100
|
-
placeholder="Enter URL"
|
|
101
|
-
floatingPlaceholder
|
|
102
|
-
text70
|
|
103
|
-
leadingAccessory={
|
|
104
|
-
<Text text70 blue30 marginR-2>
|
|
105
|
-
Https://
|
|
106
|
-
</Text>
|
|
107
|
-
}
|
|
108
|
-
fieldStyle={styles.withUnderline}
|
|
109
|
-
marginB-s4
|
|
110
|
-
/>
|
|
111
|
-
|
|
112
|
-
<TextField
|
|
113
|
-
ref={this.input2}
|
|
114
|
-
placeholder="Enter weight"
|
|
115
|
-
text70
|
|
116
|
-
trailingAccessory={
|
|
117
|
-
<Text text70 $textNeutral>
|
|
118
|
-
Kg.
|
|
119
|
-
</Text>
|
|
120
|
-
}
|
|
121
|
-
fieldStyle={styles.withUnderline}
|
|
122
|
-
keyboardType="numeric"
|
|
123
|
-
/>
|
|
109
|
+
<>
|
|
110
|
+
<Text h3 marginB-s3 marginT-s4>
|
|
111
|
+
Accessories
|
|
112
|
+
</Text>
|
|
113
|
+
|
|
114
|
+
<Text marginB-s2 $textPrimary>Trailing Accessory:</Text>
|
|
115
|
+
<TextField
|
|
116
|
+
ref={this.input2}
|
|
117
|
+
placeholder="Enter search term"
|
|
118
|
+
trailingAccessory={this.renderTrailingAccessory()}
|
|
119
|
+
/>
|
|
120
|
+
<TextField
|
|
121
|
+
ref={this.input2}
|
|
122
|
+
placeholder="Enter weight"
|
|
123
|
+
keyboardType="numeric"
|
|
124
|
+
trailingAccessory={
|
|
125
|
+
<Text text70 $textNeutral>
|
|
126
|
+
Kg.
|
|
127
|
+
</Text>
|
|
128
|
+
}
|
|
129
|
+
/>
|
|
124
130
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
<Text marginB-s2 $textPrimary>Leading Accessory:</Text>
|
|
132
|
+
<TextField
|
|
133
|
+
ref={this.input2}
|
|
134
|
+
placeholder="Enter URL"
|
|
135
|
+
leadingAccessory={
|
|
136
|
+
<Text text70 blue30 marginR-2>
|
|
137
|
+
Https://
|
|
128
138
|
</Text>
|
|
139
|
+
}
|
|
140
|
+
/>
|
|
141
|
+
</>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
129
144
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.setState({
|
|
135
|
-
errorPosition:
|
|
136
|
-
errorPosition === TextField.validationMessagePositions.TOP
|
|
137
|
-
? TextField.validationMessagePositions.BOTTOM
|
|
138
|
-
: TextField.validationMessagePositions.TOP
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
/>
|
|
142
|
-
</View>
|
|
145
|
+
onChangeIndexValidation = (index: number) => {
|
|
146
|
+
this.setState({errorPosition: index === 0 ?
|
|
147
|
+
TextField.validationMessagePositions.BOTTOM : TextField.validationMessagePositions.TOP});
|
|
148
|
+
};
|
|
143
149
|
|
|
150
|
+
renderValidationExample() {
|
|
151
|
+
const {errorPosition} = this.state;
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<>
|
|
155
|
+
<View>
|
|
156
|
+
<Text h3 marginB-s1>Validation</Text>
|
|
157
|
+
<View row centerV>
|
|
158
|
+
<Text marginR-s4 $textPrimary>Error Position:</Text>
|
|
159
|
+
<SegmentedControl segments={[{label: 'Bottom'}, {label: 'Top'}]} onChangeIndex={this.onChangeIndexValidation}/>
|
|
160
|
+
</View>
|
|
161
|
+
</View>
|
|
162
|
+
|
|
163
|
+
<TextField
|
|
164
|
+
value={this.state.value}
|
|
165
|
+
onChangeText={value => this.setState({value})}
|
|
166
|
+
label="Email"
|
|
167
|
+
placeholder="Enter email"
|
|
168
|
+
enableErrors
|
|
169
|
+
validationMessage={['Email is required', 'Email is invalid']}
|
|
170
|
+
// validationMessageStyle={Typography.text90R}
|
|
171
|
+
validationMessagePosition={errorPosition}
|
|
172
|
+
validate={['required', 'email']}
|
|
173
|
+
validateOnChange
|
|
174
|
+
onChangeValidity={(isValid: boolean) => console.warn('validity changed:', isValid, Date.now())}
|
|
175
|
+
// validateOnStart
|
|
176
|
+
// validateOnBlur
|
|
177
|
+
/>
|
|
178
|
+
<View row spread center marginV-s3>
|
|
144
179
|
<TextField
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
// validationMessageStyle={Typography.text90R}
|
|
180
|
+
ref={this.inputWithValidation}
|
|
181
|
+
label="Name"
|
|
182
|
+
placeholder="Enter full name"
|
|
183
|
+
validate="required"
|
|
184
|
+
validationMessage="This field is required"
|
|
185
|
+
containerStyle={{flexGrow: 1}}
|
|
152
186
|
validationMessagePosition={errorPosition}
|
|
153
|
-
validate={['required', 'email']}
|
|
154
|
-
validateOnChange
|
|
155
|
-
onChangeValidity={(isValid: boolean) => console.warn('validity changed:', isValid, Date.now())}
|
|
156
|
-
// validateOnStart
|
|
157
|
-
// validateOnBlur
|
|
158
|
-
fieldStyle={styles.withUnderline}
|
|
159
|
-
marginB-s4
|
|
160
187
|
/>
|
|
188
|
+
<Button
|
|
189
|
+
outline
|
|
190
|
+
marginL-s5
|
|
191
|
+
label="Validate"
|
|
192
|
+
size={Button.sizes.xSmall}
|
|
193
|
+
onPress={() => {
|
|
194
|
+
this.inputWithValidation.current?.validate?.();
|
|
195
|
+
}}
|
|
196
|
+
/>
|
|
197
|
+
</View>
|
|
198
|
+
</>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
161
201
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
202
|
+
onChangeIndexColors = (index: number) => {
|
|
203
|
+
let readonly, disabled = false;
|
|
204
|
+
|
|
205
|
+
switch (index) {
|
|
206
|
+
case 0:
|
|
207
|
+
// this.input3.current?.clear();
|
|
208
|
+
break;
|
|
209
|
+
case 1:
|
|
210
|
+
this.input3.current?.focus();
|
|
211
|
+
break;
|
|
212
|
+
case 2:
|
|
213
|
+
this.input3.current?.clear();
|
|
214
|
+
this.input3.current?.validate();
|
|
215
|
+
break;
|
|
216
|
+
case 3:
|
|
217
|
+
readonly = true;
|
|
218
|
+
break;
|
|
219
|
+
case 4:
|
|
220
|
+
disabled = true;
|
|
221
|
+
break;
|
|
222
|
+
default:
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
this.setState({isReadonly: readonly, isDisabled: disabled});
|
|
226
|
+
};
|
|
180
227
|
|
|
181
|
-
|
|
182
|
-
|
|
228
|
+
renderStateColorsExample() {
|
|
229
|
+
const {isReadonly, isDisabled} = this.state;
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<>
|
|
233
|
+
<View row centerV spread>
|
|
234
|
+
<View marginB-s3>
|
|
235
|
+
<Text h3 marginB-s2>
|
|
183
236
|
Colors By State
|
|
184
237
|
</Text>
|
|
185
|
-
<
|
|
186
|
-
<Button
|
|
187
|
-
label={isReadonly ? 'Enable' : 'Readonly'}
|
|
188
|
-
onPress={() => this.setState({isReadonly: !isReadonly})}
|
|
189
|
-
size={Button.sizes.xSmall}
|
|
190
|
-
marginR-s4
|
|
191
|
-
/>
|
|
192
|
-
<Button
|
|
193
|
-
label={shouldDisable ? 'Enable' : 'Disable'}
|
|
194
|
-
onPress={() => this.setState({shouldDisable: !shouldDisable})}
|
|
195
|
-
size={Button.sizes.xSmall}
|
|
196
|
-
/>
|
|
197
|
-
</View>
|
|
238
|
+
<SegmentedControl segments={[{label: 'Empty'}, {label: 'Focus'}, {label: 'Error'}, {label: 'Readonly'}, {label: 'Disable'}]} onChangeIndex={this.onChangeIndexColors}/>
|
|
198
239
|
</View>
|
|
240
|
+
</View>
|
|
199
241
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
242
|
+
<TextField
|
|
243
|
+
ref={this.input3}
|
|
244
|
+
label="Email"
|
|
245
|
+
labelColor={{
|
|
246
|
+
default: Colors.purple10,
|
|
247
|
+
focus: Colors.green40,
|
|
248
|
+
error: Colors.orange40,
|
|
249
|
+
readonly: Colors.purple50,
|
|
250
|
+
disabled: Colors.cyan60
|
|
251
|
+
}}
|
|
252
|
+
placeholder="Enter valid email"
|
|
253
|
+
validationMessage="Email is invalid"
|
|
254
|
+
validate={'email'}
|
|
255
|
+
validateOnChange
|
|
256
|
+
readonly={isReadonly}
|
|
257
|
+
editable={!isDisabled}
|
|
258
|
+
/>
|
|
259
|
+
</>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
217
262
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
</Text>
|
|
222
|
-
<Button
|
|
223
|
-
label={preset}
|
|
224
|
-
onPress={() => this.setState({preset: preset === 'withUnderline' ? 'withFrame' : 'withUnderline'})}
|
|
225
|
-
size={Button.sizes.xSmall}
|
|
226
|
-
/>
|
|
227
|
-
</View>
|
|
263
|
+
onChangeIndexFieldStyle = (index: number) => {
|
|
264
|
+
this.setState({customPreset: index === 0 ? 'underline' : 'outline'});
|
|
265
|
+
};
|
|
228
266
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
placeholder="Enter text..."
|
|
232
|
-
preset={preset}
|
|
233
|
-
dynamicFieldStyle={(_state, {preset}) =>
|
|
234
|
-
preset === 'withUnderline' ? styles.withUnderline : styles.withFrame
|
|
235
|
-
}
|
|
236
|
-
editable={!shouldDisable}
|
|
237
|
-
readonly={isReadonly}
|
|
238
|
-
/>
|
|
267
|
+
renderDynamicFieldExample() {
|
|
268
|
+
const {customPreset, isDisabled, isReadonly} = this.state;
|
|
239
269
|
|
|
240
|
-
|
|
241
|
-
|
|
270
|
+
return (
|
|
271
|
+
<>
|
|
272
|
+
<View>
|
|
273
|
+
<Text h3 marginB-s3>
|
|
274
|
+
Dynamic Field Style
|
|
242
275
|
</Text>
|
|
276
|
+
<View row centerV>
|
|
277
|
+
<Text marginR-s4 $textPrimary>Custom style:</Text>
|
|
278
|
+
<SegmentedControl segments={[{label: 'Underline'}, {label: 'Outline'}]} onChangeIndex={this.onChangeIndexFieldStyle}/>
|
|
279
|
+
</View>
|
|
280
|
+
</View>
|
|
243
281
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
/>
|
|
258
|
-
<Text h3 marginV-s4>
|
|
259
|
-
Hint
|
|
260
|
-
</Text>
|
|
261
|
-
<TextField
|
|
262
|
-
label="Password"
|
|
263
|
-
placeholder="Enter password"
|
|
264
|
-
hint="1-6 chars including numeric chars"
|
|
265
|
-
fieldStyle={styles.withUnderline}
|
|
266
|
-
/>
|
|
267
|
-
<Text h3 marginV-s4>
|
|
268
|
-
Formatter
|
|
269
|
-
</Text>
|
|
270
|
-
<TextField
|
|
271
|
-
value={price}
|
|
272
|
-
onChangeText={value => this.setState({price: value})}
|
|
273
|
-
label="Price"
|
|
274
|
-
placeholder="Enter price"
|
|
275
|
-
validate={'number'}
|
|
276
|
-
validationMessage="Invalid price"
|
|
277
|
-
// @ts-expect-error
|
|
278
|
-
formatter={value => (isNaN(value) ? value : priceFormatter.format(Number(value)))}
|
|
279
|
-
leadingAccessory={
|
|
280
|
-
<Text marginR-s1 $textNeutral>
|
|
281
|
-
$
|
|
282
|
-
</Text>
|
|
283
|
-
}
|
|
284
|
-
fieldStyle={styles.withUnderline}
|
|
285
|
-
/>
|
|
282
|
+
<TextField
|
|
283
|
+
label="Label"
|
|
284
|
+
placeholder="Enter text..."
|
|
285
|
+
preset={customPreset}
|
|
286
|
+
dynamicFieldStyle={(_state, {preset}) =>
|
|
287
|
+
preset === 'underline' ? styles.underline : styles.outline
|
|
288
|
+
}
|
|
289
|
+
editable={!isDisabled}
|
|
290
|
+
readonly={isReadonly}
|
|
291
|
+
/>
|
|
292
|
+
</>
|
|
293
|
+
);
|
|
294
|
+
}
|
|
286
295
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
296
|
+
renderCherCounterExample() {
|
|
297
|
+
return (
|
|
298
|
+
<>
|
|
299
|
+
<Text h3 marginB-s3>
|
|
300
|
+
Char Counter
|
|
301
|
+
</Text>
|
|
302
|
+
|
|
303
|
+
<TextField
|
|
304
|
+
label="Description"
|
|
305
|
+
placeholder="Enter text..."
|
|
306
|
+
multiline
|
|
307
|
+
showCharCounter
|
|
308
|
+
bottomAccessory={<Text text100>{Assets.emojis.grapes} {Assets.emojis.melon} {Assets.emojis.banana}</Text>}
|
|
309
|
+
charCounterStyle={{color: Colors.$textGeneral}}
|
|
310
|
+
maxLength={20}
|
|
311
|
+
/>
|
|
312
|
+
</>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
290
315
|
|
|
291
|
-
|
|
292
|
-
|
|
316
|
+
renderHintExample() {
|
|
317
|
+
return (
|
|
318
|
+
<>
|
|
319
|
+
<Text h3>
|
|
320
|
+
Hint
|
|
321
|
+
</Text>
|
|
293
322
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
323
|
+
<TextField
|
|
324
|
+
placeholder="Enter password"
|
|
325
|
+
floatingPlaceholder
|
|
326
|
+
floatOnFocus
|
|
327
|
+
hint="1-6 chars including numeric chars"
|
|
328
|
+
/>
|
|
329
|
+
</>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
renderFormatterExample() {
|
|
334
|
+
const {price} = this.state;
|
|
335
|
+
|
|
336
|
+
return (
|
|
337
|
+
<>
|
|
338
|
+
<Text h3 marginB-s3 marginT-s4>
|
|
339
|
+
Formatter
|
|
340
|
+
</Text>
|
|
341
|
+
|
|
342
|
+
<TextField
|
|
343
|
+
value={price}
|
|
344
|
+
onChangeText={value => this.setState({price: value})}
|
|
345
|
+
label="Price"
|
|
346
|
+
placeholder="Enter price"
|
|
347
|
+
validate={'number'}
|
|
348
|
+
validationMessage="Invalid price"
|
|
349
|
+
// @ts-expect-error
|
|
350
|
+
formatter={value => (isNaN(value) ? value : priceFormatter.format(Number(value)))}
|
|
351
|
+
leadingAccessory={<Text marginR-s1 $textNeutral>$</Text>}
|
|
352
|
+
/>
|
|
353
|
+
</>
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
renderCustomAlignmentExample() {
|
|
358
|
+
return (
|
|
359
|
+
<>
|
|
360
|
+
<Text h3 marginB-3>
|
|
361
|
+
Custom Alignments
|
|
362
|
+
</Text>
|
|
363
|
+
|
|
364
|
+
<Text marginB-s1 $textPrimary>Centered:</Text>
|
|
365
|
+
<TextField label="PIN" placeholder="XXXX" centered/>
|
|
366
|
+
|
|
367
|
+
<Text marginB-s1 $textPrimary>Inline:</Text>
|
|
368
|
+
<View row>
|
|
369
|
+
<TextField placeholder="hours"/>
|
|
370
|
+
<Text marginT-s1 marginH-s1>:</Text>
|
|
371
|
+
<TextField placeholder="minutes"/>
|
|
372
|
+
</View>
|
|
373
|
+
</>
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
render() {
|
|
378
|
+
return (
|
|
379
|
+
<ScrollView keyboardShouldPersistTaps="always" showsVerticalScrollIndicator={false}>
|
|
380
|
+
<View flex padding-page>
|
|
381
|
+
<Text h1 marginB-s4>TextField</Text>
|
|
382
|
+
|
|
383
|
+
{this.renderDefaultExample()}
|
|
384
|
+
{this.renderPresetExample()}
|
|
385
|
+
{this.renderPlaceholdersExample()}
|
|
386
|
+
{this.renderValidationExample()}
|
|
387
|
+
{this.renderStateColorsExample()}
|
|
388
|
+
{this.renderHintExample()}
|
|
389
|
+
{this.renderCherCounterExample()}
|
|
390
|
+
{this.renderAccessoriesExample()}
|
|
391
|
+
{this.renderDynamicFieldExample()}
|
|
392
|
+
{this.renderFormatterExample()}
|
|
393
|
+
{this.renderCustomAlignmentExample()}
|
|
300
394
|
</View>
|
|
301
395
|
<KeyboardAwareInsetsView/>
|
|
302
396
|
</ScrollView>
|
|
@@ -305,16 +399,15 @@ export default class TextFieldScreen extends Component {
|
|
|
305
399
|
}
|
|
306
400
|
|
|
307
401
|
const styles = StyleSheet.create({
|
|
308
|
-
|
|
309
|
-
withUnderline: {
|
|
402
|
+
underline: {
|
|
310
403
|
borderBottomWidth: 1,
|
|
311
|
-
borderColor: Colors
|
|
404
|
+
borderColor: Colors.cyan20,
|
|
312
405
|
paddingBottom: 4
|
|
313
406
|
},
|
|
314
|
-
|
|
407
|
+
outline: {
|
|
315
408
|
borderWidth: 1,
|
|
316
|
-
borderColor: Colors
|
|
409
|
+
borderColor: Colors.cyan20,
|
|
317
410
|
padding: 4,
|
|
318
|
-
borderRadius:
|
|
411
|
+
borderRadius: 4
|
|
319
412
|
}
|
|
320
413
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {useCallback, useRef, useState} from 'react';
|
|
2
2
|
import {StyleSheet, ScrollView} from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {Colors, Timeline, View, Card, Text, Button} from 'react-native-ui-lib';
|
|
4
|
+
import Assets from '../../assets/Assets';
|
|
5
5
|
const contents = [
|
|
6
6
|
'CURRENT (default) state with dashed line.\nAligned to title',
|
|
7
7
|
'SUCCESS state with label.',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {ScrollView, StyleSheet} from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import {Colors, View, Button, Text, Incubator} from 'react-native-ui-lib';
|
|
4
4
|
import {renderMultipleSegmentOptions, renderBooleanOption, renderRadioGroup} from '../ExampleScreenPresenter';
|
|
5
5
|
import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
|
|
6
|
-
|
|
6
|
+
import Assets from '../../assets/Assets';
|
|
7
7
|
const {Toast} = Incubator;
|
|
8
8
|
|
|
9
9
|
const TOAST_ACTIONS = {
|
|
@@ -2,7 +2,6 @@ import React, {Component} from 'react';
|
|
|
2
2
|
import {StyleSheet, ScrollView} from 'react-native';
|
|
3
3
|
import {GestureHandlerRootView, FlatList} from 'react-native-gesture-handler';
|
|
4
4
|
import {
|
|
5
|
-
Assets,
|
|
6
5
|
View,
|
|
7
6
|
Text,
|
|
8
7
|
Colors,
|
|
@@ -15,7 +14,7 @@ import {
|
|
|
15
14
|
TouchableOpacity
|
|
16
15
|
} from 'react-native-ui-lib';
|
|
17
16
|
const {PanView} = Incubator;
|
|
18
|
-
|
|
17
|
+
import Assets from '../../assets/Assets';
|
|
19
18
|
interface Item {
|
|
20
19
|
value: string;
|
|
21
20
|
label: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {StyleSheet, ScrollView} from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import {Colors, Spacings, View, Card, Text, Image, Button, Constants} from 'react-native-ui-lib';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
+
import Assets from '../../../assets/Assets';
|
|
5
6
|
|
|
6
7
|
import './configurations';
|
|
7
8
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
import {ScrollView} from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import {View, Text, Icon, Colors, Image, Button, Carousel, Picker, PickerValue} from 'react-native-ui-lib';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
+
import Assets from '../../../assets/Assets';
|
|
5
6
|
|
|
6
7
|
const colorOptions: {[key: string]: {name: string; color: string}} = {
|
|
7
8
|
red: {name: 'Red', color: Colors.red30},
|