@shoutem/ui 6.0.0 → 6.1.0-beta.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.
@@ -0,0 +1,3 @@
1
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.1756 4.93236C15.4413 4.82187 15.7262 4.76498 16.0139 4.76498C16.3017 4.76498 16.5866 4.82186 16.8523 4.93236C17.118 5.04285 17.3592 5.20477 17.5621 5.40881L17.5636 5.4103L18.497 6.34364L18.4982 6.34493C19.1882 7.03151 20.1224 7.41664 21.0939 7.41664H22.4273C23.0063 7.41664 23.5617 7.64667 23.9711 8.05612C24.3806 8.46558 24.6106 9.02092 24.6106 9.59997V10.9333C24.6106 11.9049 24.9958 12.8391 25.6823 13.529L25.6836 13.5303L26.617 14.4636L26.6184 14.4651C26.8225 14.668 26.9844 14.9093 27.0949 15.1749C27.2054 15.4406 27.2623 15.7256 27.2623 16.0133C27.2623 16.3011 27.2054 16.586 27.0949 16.8517C26.9844 17.1174 26.8225 17.3586 26.6184 17.5615L26.617 17.563L25.6836 18.4963L25.6821 18.4978C24.9964 19.1874 24.6112 20.1203 24.6106 21.0929V21.0933V22.4266C24.6106 23.0057 24.3806 23.561 23.9711 23.9705C23.5617 24.3799 23.0063 24.61 22.4273 24.61H21.0939H21.0935C20.121 24.6105 19.1881 24.9957 18.4984 25.6815L18.497 25.683L17.5636 26.6163L17.5621 26.6178C17.3592 26.8218 17.118 26.9838 16.8523 27.0943C16.5866 27.2048 16.3017 27.2616 16.0139 27.2616C15.7262 27.2616 15.4413 27.2048 15.1756 27.0943C14.9099 26.9838 14.6687 26.8218 14.4658 26.6178L14.4643 26.6163L13.5309 25.683L13.5295 25.6815C12.8398 24.9957 11.9069 24.6105 10.9344 24.61H10.9339H9.60061C9.02156 24.61 8.46622 24.3799 8.05677 23.9705C7.64731 23.561 7.41728 23.0057 7.41728 22.4266V21.0933L7.41728 21.0929C7.41673 20.1203 7.03154 19.1874 6.34577 18.4978L6.34428 18.4963L5.41095 17.563L5.40945 17.5615C5.20541 17.3586 5.04349 17.1174 4.933 16.8517C4.82251 16.586 4.76562 16.3011 4.76562 16.0133C4.76562 15.7256 4.82251 15.4406 4.933 15.1749C5.04349 14.9093 5.20541 14.668 5.40945 14.4651L5.41094 14.4636L6.34428 13.5303L6.34577 13.5288C7.03154 12.8392 7.41673 11.9063 7.41728 10.9337L7.41728 10.9333V9.59997C7.41728 9.02092 7.64731 8.46558 8.05677 8.05612C8.46622 7.64667 9.02156 7.41664 9.60061 7.41664H10.9339L10.9344 7.41664C11.9069 7.41608 12.8398 7.0309 13.5295 6.34513L13.5309 6.34364L14.4643 5.4103L14.4658 5.40881C14.6687 5.20477 14.9099 5.04285 15.1756 4.93236ZM6.99611 6.99546C6.30535 7.68622 5.91728 8.62309 5.91728 9.59997V10.9329V10.9331V10.9333C5.91684 11.5093 5.6888 12.0618 5.28285 12.4704L5.28213 12.4711L4.35178 13.4015L4.35093 13.4023C4.00711 13.7445 3.73423 14.1511 3.54799 14.599C3.36158 15.0472 3.26562 15.5279 3.26562 16.0133C3.26562 16.4988 3.36158 16.9794 3.54799 17.4276C3.73422 17.8755 4.00707 18.2821 4.35086 18.6242L4.35178 18.6251L5.28213 19.5555L5.28291 19.5563C5.68882 19.9649 5.91684 20.5173 5.91728 21.0933V21.0935V21.0937V22.4266C5.91728 23.4035 6.30535 24.3404 6.99611 25.0312C7.68686 25.7219 8.62373 26.11 9.60061 26.11H10.9335C11.5097 26.1103 12.0623 26.3383 12.471 26.7444L12.4718 26.7451L13.4021 27.6755L13.4032 27.6766C13.7453 28.0203 14.1519 28.2931 14.5996 28.4793C15.0478 28.6657 15.5285 28.7616 16.0139 28.7616C16.4994 28.7616 16.9801 28.6657 17.4283 28.4793C17.876 28.2931 18.2826 28.0203 18.6247 27.6766L18.6258 27.6755L19.5561 26.7451L19.5569 26.7444C19.9656 26.3383 20.5182 26.1103 21.0944 26.11H22.4273C23.4042 26.11 24.341 25.7219 25.0318 25.0312C25.7226 24.3404 26.1106 23.4035 26.1106 22.4266V21.0937C26.1109 20.5176 26.339 19.965 26.745 19.5563L26.7458 19.5555L27.6761 18.6251L27.6772 18.624C28.0209 18.282 28.2937 17.8754 28.4799 17.4276C28.6663 16.9794 28.7623 16.4988 28.7623 16.0133C28.7623 15.5279 28.6663 15.0472 28.4799 14.599C28.2937 14.1512 28.0209 13.7447 27.6772 13.4026L27.6761 13.4015L26.7456 12.4709L26.7447 12.4701C26.3385 12.0614 26.1106 11.508 26.1106 10.9333V9.59997C26.1106 8.62309 25.7226 7.68622 25.0318 6.99546C24.341 6.30471 23.4042 5.91664 22.4273 5.91664H21.0939C20.5192 5.91664 19.9657 5.68871 19.557 5.2824L19.5563 5.28169L18.6258 4.35114L18.6249 4.35022C18.2827 4.00643 17.8761 3.73358 17.4283 3.54734C16.98 3.36094 16.4994 3.26498 16.0139 3.26498C15.5285 3.26498 15.0478 3.36094 14.5996 3.54734C14.1518 3.73359 13.7451 4.00646 13.403 4.35029L13.4021 4.35114L12.4718 5.28149L12.4711 5.28221C12.0624 5.68816 11.51 5.9162 10.9339 5.91664H10.9337H10.9335H9.60061C8.62373 5.91664 7.68686 6.30471 6.99611 6.99546ZM20.5303 13.8637C20.8232 13.5708 20.8232 13.0959 20.5303 12.803C20.2374 12.5101 19.7626 12.5101 19.4697 12.803L14.6667 17.606L12.5303 15.4697C12.2374 15.1768 11.7626 15.1768 11.4697 15.4697C11.1768 15.7626 11.1768 16.2374 11.4697 16.5303L14.1363 19.197C14.4292 19.4899 14.9041 19.4899 15.197 19.197L20.5303 13.8637Z" />
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M28 16C28 22.6274 22.6274 28 16 28C9.37258 28 4 22.6274 4 16C4 9.37258 9.37258 4 16 4C22.6274 4 28 9.37258 28 16ZM20.5303 13.8637C20.8232 13.5708 20.8232 13.0959 20.5303 12.803C20.2374 12.5101 19.7626 12.5101 19.4697 12.803L14.6667 17.606L12.5303 15.4697C12.2374 15.1768 11.7626 15.1768 11.4697 15.4697C11.1768 15.7626 11.1768 16.2374 11.4697 16.5303L14.1363 19.197C14.4292 19.4899 14.9041 19.4899 15.197 19.197L20.5303 13.8637Z"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M20.4 4H11.6C11.2 4 10.9333 4.13333 10.6667 4.4L4.4 10.6667C4.13333 10.9333 4 11.2 4 11.6V20.4C4 20.8 4.13333 21.0667 4.4 21.3333L10.6667 27.6C10.9333 27.8667 11.2 28 11.6 28H20.4C20.8 28 21.0667 27.8667 21.3333 27.6L27.6 21.3333C27.8667 21.0667 28 20.8 28 20.4V11.6C28 11.2 27.8667 10.9333 27.6 10.6667L21.3333 4.4C21.0667 4.13333 20.8 4 20.4 4ZM16 9.66667C16.5523 9.66667 17 10.1144 17 10.6667V16C17 16.5523 16.5523 17 16 17C15.4477 17 15 16.5523 15 16V10.6667C15 10.1144 15.4477 9.66667 16 9.66667ZM15 21.3333C15 20.781 15.4477 20.3333 16 20.3333H16.0125C16.5648 20.3333 17.0125 20.781 17.0125 21.3333C17.0125 21.8856 16.5648 22.3333 16.0125 22.3333H16C15.4477 22.3333 15 21.8856 15 21.3333Z" />
3
+ </svg>
@@ -17,6 +17,8 @@ import checkboxOff from './checkbox-off.svg';
17
17
  import checkboxOn from './checkbox-on.svg';
18
18
  import checkboxRectangleOff from './checkbox-rectangle-off.svg';
19
19
  import checkboxRectangleOn from './checkbox-rectangle-on.svg';
20
+ import checkmarkOval from './checkmark-oval.svg';
21
+ import checkmarkRound from './checkmark-round.svg';
20
22
  import clearText from './clear-text.svg';
21
23
  import clock from './clock.svg';
22
24
  import close from './close.svg';
@@ -32,6 +34,7 @@ import edit from './edit.svg';
32
34
  import email from './email.svg';
33
35
  import equalizer from './equalizer.svg';
34
36
  import error from './error.svg';
37
+ import errorrRectangle from './error-rectangle.svg';
35
38
  import events from './events.svg';
36
39
  import exitToApp from './exit-to-app.svg';
37
40
  import eye from './eye.svg';
@@ -137,6 +140,8 @@ export const defaultConfig = [
137
140
  { name: 'checkbox-on', icon: checkboxOn },
138
141
  { name: 'checkbox-rectangle-off', icon: checkboxRectangleOff },
139
142
  { name: 'checkbox-rectangle-on', icon: checkboxRectangleOn },
143
+ { name: 'checkmark-oval', icon: checkmarkOval },
144
+ { name: 'checkmark-round', icon: checkmarkRound },
140
145
  { name: 'clear-text', icon: clearText },
141
146
  { name: 'clock', icon: clock },
142
147
  { name: 'close', icon: close },
@@ -152,6 +157,7 @@ export const defaultConfig = [
152
157
  { name: 'email', icon: email },
153
158
  { name: 'equalizer', icon: equalizer },
154
159
  { name: 'error', icon: error },
160
+ { name: 'error-rectangle', icon: errorrRectangle },
155
161
  { name: 'events', icon: events },
156
162
  { name: 'exit-to-app', icon: exitToApp },
157
163
  { name: 'eye', icon: eye },
@@ -0,0 +1,100 @@
1
+ # Shoutem UI Toasts :bread:
2
+
3
+ New component used for multiple types of alerts, or simple action prompts. The component is based on the [react-native-toast-message ](https://github.com/calintamas/react-native-toast-message)package, with our wrapper implementation defining custom styled toast types
4
+
5
+ > You are still free to use the react-native-toast-message show/hide methods directly, through our default export, if you so desire.
6
+
7
+ ## Usage
8
+
9
+ Most of the time, you will want to use one of the four standard methods of showing a toast using this package.
10
+
11
+ - Toast.showInfo
12
+ - Toast.showAlert
13
+ - Toast.showError
14
+ - Toast.showSuccess
15
+
16
+ - Toast.show() and Toast.hide() methods are identical to the ones in the parent library. So if you want to use your own components for alerts, you can do it just like you would normally.
17
+
18
+ Each of these accepts same set or props / params, but implements different styling and color schemes, according to it's semantic significance. Below are a couple of examples of commonly used methods.
19
+
20
+ ```jsx
21
+ import { Toast } from '@shoutem/ui';
22
+ ...
23
+ Toast.showInfo({
24
+ title: 'Hello world!',
25
+ message: `This is a message!`,
26
+ iconSource: {
27
+ uri: 'https://townsquare.media/site/341/files/2012/05/Mr.-Trololo.jpg',
28
+ },
29
+ });
30
+ ...
31
+ ```
32
+
33
+ ```jsx
34
+ import { Toast } from '@shoutem/ui';
35
+ ...
36
+ Toast.showAlert({
37
+ title: 'Stop',
38
+ message: `Hammer time`,
39
+ iconSource: require('../assets/actionIcon.png'),
40
+ cancelButtonText: 'absolutely not',
41
+ confirmButtonText: `Hammer zeit!`,
42
+ onCancel: Toast.hide,
43
+ onConfirm: () => {
44
+ console.log('A man of culture....');
45
+ Toast.hide();
46
+ }
47
+ });
48
+ ...
49
+ ```
50
+
51
+ ```jsx
52
+ import { Toast } from '@shoutem/ui';
53
+ ...
54
+ Toast.showError({
55
+ title: 'Error',
56
+ message: `We've failed to charge your credit card. Please check your CC data`,
57
+ iconName: 'error',
58
+ confirmButtonText: `Take me to payment details`,
59
+ onConfirm: () => {
60
+ navigateTo('PaymentDetailsScreen');
61
+ Toast.hide();
62
+ }
63
+ autoHide: false,
64
+ });
65
+ ...
66
+ ```
67
+
68
+
69
+ ### Props
70
+
71
+ Currently supported props mainly include "native" props from the parent library, with both, a few exclusions and a some additions. Also, you can pass any kind of custom prop you want, and it will be passed in to your custom toast component
72
+
73
+ | **Name** | **Type** | **Default** | **Description** |
74
+ |---------------------------------------------|-------------------|-------------|----------------------------------------------------------------------------------------------------------------------------------|
75
+ | title | String | Required | Title of the toast message |
76
+ | message | String | Required | Description of the toast message |
77
+ | iconName | String | Info | Name of the existing icon in the UI toolkit that will be used as a leading image |
78
+ | iconSource | ImageSourceType | undefined | Standard image source ( uri object, direct require, ... ). If this prop is passed in, it will take presedence over iconName prop |
79
+ | durationIndicator | Bool | true | Displays the duration indicator line below the toast, in the duration of the `visibilityTime` prop |
80
+ | onConfirm | Function | undefined | Callback called when pressing the confirm button |
81
+ | onCancel | Function | undefined | Callback called when pressing the cancel button |
82
+ | confirmButtonText | String | undefined | |
83
+ | cancelButtonText | String | undefined | |
84
+ | `-- props supported from parent library --` | | | |
85
+ | position | `top` or `bottom` | top | |
86
+ | visibilityTime | Number | 4000 | How long is the toast displayed |
87
+ | autoHide | Bool | true | Hide automatically after visibilityTime has expired |
88
+ | topOffset | Number | 40 | |
89
+ | bottomOffset | Number | 40 | |
90
+ | keyboardOffset | Number | 10 | |
91
+ | onShow | Function | | |
92
+ | onHide | Function | | |
93
+ | onPress | Function | | |
94
+
95
+ ## BaseToast
96
+
97
+ This component also exports our base component that contains all of the internal logic that understand how to compose and handle toast message. If you'd like to create a new Toast component, feel free to use the BaseToast, and inject `customToastStyle` prop that will be merged with the default styles, and / or any other prop manipualtion you require.
98
+
99
+
100
+
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { connectStyle } from '@shoutem/theme';
3
+ import BaseToast from './BaseToast';
4
+
5
+ function ActionToast({ style, isVisible, props }) {
6
+ return (
7
+ <BaseToast
8
+ customToastStyle={style}
9
+ iconName="checkmark-oval"
10
+ isVisible={isVisible}
11
+ {...props}
12
+ />
13
+ );
14
+ }
15
+
16
+ ActionToast.propTypes = BaseToast.propTypes;
17
+
18
+ export default connectStyle('shoutem.ui.ActionToast')(ActionToast);
@@ -0,0 +1,123 @@
1
+ import React, { useMemo } from 'react';
2
+ import _ from 'lodash';
3
+ import PropTypes from 'prop-types';
4
+ import { connectStyle } from '@shoutem/theme';
5
+ import { Icon, Image, Text, Touchable, View } from '@shoutem/ui';
6
+ import ToastProgressBar from './ToastProgressBar';
7
+
8
+ function BaseToast({
9
+ message,
10
+ title,
11
+ style,
12
+ iconSource,
13
+ iconName,
14
+ onConfirm,
15
+ confirmButtonText,
16
+ onCancel,
17
+ cancelButtonText,
18
+ durationIndicator,
19
+ visibilityTime,
20
+ customToastStyle,
21
+ isVisible,
22
+ }) {
23
+ const hasConfirmButton = onConfirm && confirmButtonText;
24
+ const hasCancelButton = onCancel && cancelButtonText;
25
+ const resolvedStyle = useMemo(() => _.merge(style, customToastStyle), [
26
+ style,
27
+ customToastStyle,
28
+ ]);
29
+
30
+ return (
31
+ <View style={resolvedStyle.container}>
32
+ <View style={resolvedStyle.detailsContainer}>
33
+ {iconSource && (
34
+ <Image source={iconSource} style={resolvedStyle.image} />
35
+ )}
36
+ {!iconSource && <Icon name={iconName} style={resolvedStyle.icon} />}
37
+ <View style={resolvedStyle.textContainer}>
38
+ {title && <Text style={resolvedStyle.title}>{title}</Text>}
39
+ {message && <Text style={resolvedStyle.message}>{message}</Text>}
40
+ </View>
41
+ </View>
42
+ {(hasConfirmButton || hasCancelButton) && (
43
+ <View style={resolvedStyle.buttonContainer}>
44
+ {hasCancelButton && (
45
+ <Touchable
46
+ style={[
47
+ resolvedStyle.button,
48
+ resolvedStyle.cancelButton,
49
+ !hasConfirmButton && resolvedStyle.fullWidthButton,
50
+ ]}
51
+ onPress={onCancel}
52
+ >
53
+ <Text
54
+ style={[
55
+ resolvedStyle.buttonText,
56
+ resolvedStyle.cancelButtonText,
57
+ ]}
58
+ >
59
+ {cancelButtonText}
60
+ </Text>
61
+ </Touchable>
62
+ )}
63
+ {hasConfirmButton && (
64
+ <Touchable
65
+ style={[
66
+ resolvedStyle.button,
67
+ resolvedStyle.confirmButton,
68
+ !hasCancelButton && resolvedStyle.fullWidthButton,
69
+ ]}
70
+ onPress={onConfirm}
71
+ >
72
+ <Text
73
+ style={[
74
+ resolvedStyle.buttonText,
75
+ resolvedStyle.confirmButtonText,
76
+ ]}
77
+ >
78
+ {confirmButtonText}
79
+ </Text>
80
+ </Touchable>
81
+ )}
82
+ </View>
83
+ )}
84
+ <ToastProgressBar
85
+ duration={visibilityTime}
86
+ color={resolvedStyle.progressBar.color}
87
+ visible={isVisible && durationIndicator}
88
+ />
89
+ </View>
90
+ );
91
+ }
92
+
93
+ BaseToast.propTypes = {
94
+ isVisible: PropTypes.bool.isRequired,
95
+ style: PropTypes.object.isRequired,
96
+ cancelButtonText: PropTypes.string,
97
+ confirmButtonText: PropTypes.string,
98
+ customToastStyle: PropTypes.object,
99
+ durationIndicator: PropTypes.bool,
100
+ iconName: PropTypes.string,
101
+ iconSource: PropTypes.any,
102
+ message: PropTypes.string,
103
+ title: PropTypes.string,
104
+ visibilityTime: PropTypes.number,
105
+ onCancel: PropTypes.func,
106
+ onConfirm: PropTypes.func,
107
+ };
108
+
109
+ BaseToast.defaultProps = {
110
+ customToastStyle: {},
111
+ title: undefined,
112
+ message: undefined,
113
+ confirmButtonText: undefined,
114
+ cancelButtonText: undefined,
115
+ onCancel: undefined,
116
+ onConfirm: undefined,
117
+ durationIndicator: true,
118
+ iconName: 'about',
119
+ iconSource: undefined,
120
+ visibilityTime: 4000,
121
+ };
122
+
123
+ export default connectStyle('shoutem.ui.BaseToast')(BaseToast);
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { connectStyle } from '@shoutem/theme';
3
+ import BaseToast from './BaseToast';
4
+
5
+ function ErrorToast({ style, props, isVisible }) {
6
+ return (
7
+ <BaseToast
8
+ customToastStyle={style}
9
+ isVisible={isVisible}
10
+ iconName="error-rectangle"
11
+ {...props}
12
+ />
13
+ );
14
+ }
15
+
16
+ ErrorToast.propTypes = BaseToast.propTypes;
17
+
18
+ export default connectStyle('shoutem.ui.ErrorToast')(ErrorToast);
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { connectStyle } from '@shoutem/theme';
3
+ import BaseToast from './BaseToast';
4
+
5
+ function InfoToast({ style, props, isVisible }) {
6
+ return (
7
+ <BaseToast customToastStyle={style} isVisible={isVisible} {...props} />
8
+ );
9
+ }
10
+
11
+ InfoToast.propTypes = BaseToast.propTypes;
12
+
13
+ export default connectStyle('shoutem.ui.InfoToast')(InfoToast);
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { connectStyle } from '@shoutem/theme';
3
+ import BaseToast from './BaseToast';
4
+
5
+ function SuccessToast({ style, props, isVisible }) {
6
+ return (
7
+ <BaseToast
8
+ customToastStyle={style}
9
+ iconName="checkmark-round"
10
+ isVisible={isVisible}
11
+ {...props}
12
+ />
13
+ );
14
+ }
15
+
16
+ SuccessToast.propTypes = BaseToast.propTypes;
17
+
18
+ export default connectStyle('shoutem.ui.SuccessToast')(SuccessToast);
@@ -0,0 +1,67 @@
1
+ import React, { useCallback, useEffect, useRef } from 'react';
2
+ import { Animated, View } from 'react-native';
3
+ import PropTypes from 'prop-types';
4
+ import { connectStyle } from '@shoutem/theme';
5
+
6
+ function ToastProgressBar({
7
+ duration,
8
+ style,
9
+ onProgressComplete,
10
+ color,
11
+ visible,
12
+ }) {
13
+ const progressValue = useRef(new Animated.Value(0)).current;
14
+
15
+ useEffect(() => {
16
+ if (!visible) {
17
+ progressValue.setValue(0);
18
+ return;
19
+ }
20
+
21
+ Animated.timing(progressValue, {
22
+ toValue: 1,
23
+ duration,
24
+ useNativeDriver: false,
25
+ }).start(handleAnimationEnd);
26
+ }, [visible, duration, handleAnimationEnd]);
27
+
28
+ const handleAnimationEnd = useCallback(() => {
29
+ progressValue.setValue(0);
30
+ if (onProgressComplete) {
31
+ onProgressComplete();
32
+ }
33
+ }, [onProgressComplete, progressValue]);
34
+
35
+ return (
36
+ <View style={style.container}>
37
+ <Animated.View
38
+ style={[
39
+ style.progressBar,
40
+ {
41
+ backgroundColor: color,
42
+ width: progressValue.interpolate({
43
+ inputRange: [0, 1],
44
+ outputRange: ['0%', '100%'],
45
+ }),
46
+ },
47
+ ]}
48
+ />
49
+ </View>
50
+ );
51
+ }
52
+
53
+ ToastProgressBar.propTypes = {
54
+ style: PropTypes.object.isRequired,
55
+ visible: PropTypes.bool.isRequired,
56
+ color: PropTypes.string,
57
+ duration: PropTypes.number,
58
+ onProgressComplete: PropTypes.func,
59
+ };
60
+
61
+ ToastProgressBar.defaultProps = {
62
+ color: '#00AADF',
63
+ duration: 4000,
64
+ onProgressComplete: undefined,
65
+ };
66
+
67
+ export default connectStyle('shoutem.ui.ToastProgressBar')(ToastProgressBar);
@@ -0,0 +1,6 @@
1
+ export { default as ActionToast } from './ActionToast';
2
+ export { default as BaseToast } from './BaseToast';
3
+ export { default as ErrorToast } from './ErrorToast';
4
+ export { default as InfoToast } from './InfoToast';
5
+ export { default as SuccessToast } from './SuccessToast';
6
+ export { default as ToastProgressBar } from './ToastProgressBar';
@@ -0,0 +1,2 @@
1
+ export { BaseToast } from './components';
2
+ export { default as Toast } from './toastMessage';
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import Toast from 'react-native-toast-message';
3
+ import _ from 'lodash';
4
+ import { ActionToast, ErrorToast, InfoToast, SuccessToast } from './components';
5
+
6
+ const NATIVE_PROPS_MAP = [
7
+ 'position',
8
+ 'visibilityTime',
9
+ 'autoHide',
10
+ 'topOffset',
11
+ 'bottomOffset',
12
+ 'keyboardOffset',
13
+ 'onShow',
14
+ 'onHide',
15
+ 'onPress',
16
+ ];
17
+ const config = {
18
+ 'shoutem-success': props => <SuccessToast {...props} />,
19
+ 'shoutem-error': props => <ErrorToast {...props} />,
20
+ 'shoutem-info': props => <InfoToast {...props} />,
21
+ 'shoutem-action': props => <ActionToast {...props} />,
22
+ };
23
+
24
+ function normalizeProps(type, props) {
25
+ const nativeProps = _.pick(props, NATIVE_PROPS_MAP);
26
+
27
+ return {
28
+ type,
29
+ ...nativeProps,
30
+ props,
31
+ };
32
+ }
33
+
34
+ export const Provider = () => <Toast config={config} />;
35
+
36
+ const showAction = props => Toast.show(normalizeProps('shoutem-action', props));
37
+
38
+ const showInfo = props => Toast.show(normalizeProps('shoutem-info', props));
39
+
40
+ const showSuccess = props =>
41
+ Toast.show(normalizeProps('shoutem-success', props));
42
+
43
+ const showError = props => Toast.show(normalizeProps('shoutem-error', props));
44
+
45
+ export default {
46
+ Provider,
47
+ showAction,
48
+ showError,
49
+ showSuccess,
50
+ showInfo,
51
+ show: Toast.show,
52
+ hide: Toast.hide,
53
+ defaultConfig: config,
54
+ };
package/index.js CHANGED
@@ -65,6 +65,7 @@ export { TabMenu } from './components/TabMenu';
65
65
  export { Caption, Heading, Subtitle, Text, Title } from './components/Text';
66
66
  export { TextInput } from './components/TextInput';
67
67
  export { Tile } from './components/Tile';
68
+ export { Toast } from './components/ToastMessage';
68
69
  export { Touchable } from './components/Touchable';
69
70
  export { TouchableNativeFeedback } from './components/TouchableNativeFeedback';
70
71
  export { TouchableOpacity } from './components/TouchableOpacity';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoutem/ui",
3
- "version": "6.0.0",
3
+ "version": "6.1.0-beta.0",
4
4
  "description": "Styleable set of components for React Native applications",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
@@ -37,6 +37,7 @@
37
37
  "react-native-render-html-table-bridge": "0.6.0",
38
38
  "react-native-svg": "12.3.0",
39
39
  "react-native-svg-transformer": "1.0.0",
40
+ "react-native-toast-message": "2.1.5",
40
41
  "react-native-webview": "11.23.0",
41
42
  "react-native-youtube-iframe": "2.2.2",
42
43
  "stream": "0.0.2",
package/theme.js CHANGED
@@ -253,6 +253,28 @@ export const defaultThemeVariables = {
253
253
  sectionHeaderBackgroundColor: '#F2F2F2',
254
254
  indicatorColor: '#222222',
255
255
 
256
+ // Toast Container
257
+ toastBackgroundColor: '#FFFFFF',
258
+ toastSuccessBackgroundColor: '#333D27',
259
+ toastErrorBackgroundColor: '#3D272A',
260
+ // Toast Text
261
+ toastTitleColor: '#888FA1',
262
+ toastSuccessTitleColor: '#B4BDAA',
263
+ toastErrorTitleColor: '#B4BDAA',
264
+ toastMessageColor: '#444F6C',
265
+ toastSuccessMessageColor: '#FFFFFF',
266
+ toastErrorMessageColor: '#FFFFFF',
267
+ // Toast Action buttons
268
+ toastConfirmButtonBackgroundColor: '#444F6C',
269
+ toastConfirmButtonTextColor: '#FFFFFF',
270
+ toastCancelButtonTextColor: '#444F6C',
271
+ toastCancelButtonBackgroundColor: '#F3F4F6',
272
+ // Toast Progress Bar
273
+ toastProgressBarBackgroundColor: 'rgba(136, 143, 161, 0.1)',
274
+ toastProgressBarColor: '#00AADF',
275
+ toastSuccessProgressBarColor: '#88C242',
276
+ toastErrorProgressBarColor: '#D0021B',
277
+
256
278
  smallGutter: 5,
257
279
  mediumGutter: 15,
258
280
  largeGutter: 30,
@@ -3077,5 +3099,167 @@ export default () => {
3077
3099
  'shoutem.ui.ScrollView': {
3078
3100
  contentContainerStyle: {},
3079
3101
  },
3102
+
3103
+ // Toast messages
3104
+
3105
+ 'shoutem.ui.ToastProgressBar': {
3106
+ container: {
3107
+ marginTop: responsiveWidth(10),
3108
+ flexDirection: 'row',
3109
+ height: responsiveHeight(2),
3110
+ backgroundColor: 'rgba(136, 143, 161, 0.1)',
3111
+ },
3112
+ progressBar: {
3113
+ flexDirection: 'row',
3114
+ width: '100%',
3115
+ position: 'absolute',
3116
+ left: 0,
3117
+ top: 0,
3118
+ bottom: 0,
3119
+ borderBottomLeftRadius: 8,
3120
+ borderBottomRightRadius: 8,
3121
+ },
3122
+ },
3123
+
3124
+ 'shoutem.ui.BaseToast': {
3125
+ container: {
3126
+ width: resolveVariable('sizes.window.width') - responsiveWidth(20),
3127
+ borderRadius: 8,
3128
+ paddingTop: responsiveWidth(12),
3129
+ backgroundColor: resolveVariable('toastBackgroundColor'),
3130
+ shadowColor: '#000000',
3131
+ shadowOffset: {
3132
+ width: 0,
3133
+ height: 2,
3134
+ },
3135
+ shadowOpacity: 0.23,
3136
+ shadowRadius: 2.62,
3137
+ elevation: 4,
3138
+ overflow: 'hidden',
3139
+ borderWidth: 1,
3140
+ borderColor: '#BDC0CB26',
3141
+ },
3142
+ detailsContainer: {
3143
+ paddingHorizontal: responsiveWidth(12),
3144
+ flexDirection: 'row',
3145
+ flex: 1,
3146
+ alignItems: 'center',
3147
+ },
3148
+ image: {
3149
+ width: responsiveHeight(48),
3150
+ height: responsiveHeight(48),
3151
+ marginRight: responsiveWidth(8),
3152
+ borderRadius: 4,
3153
+ },
3154
+ icon: {
3155
+ width: responsiveWidth(32),
3156
+ height: responsiveWidth(32),
3157
+ marginRight: responsiveWidth(8),
3158
+ color: resolveVariable('toastMessageColor'),
3159
+ },
3160
+ textContainer: {
3161
+ height: responsiveHeight(48),
3162
+ justifyContent: 'space-between',
3163
+ },
3164
+ title: {
3165
+ color: resolveVariable('toastTitleColor'),
3166
+ fontSize: 12,
3167
+ fontFamily: resolveFontFamily(
3168
+ resolveVariable('text.fontFamily'),
3169
+ '400',
3170
+ ),
3171
+ fontWeight: resolveFontWeight('400'),
3172
+ lineHeight: 14,
3173
+ },
3174
+ message: {
3175
+ color: resolveVariable('toastMessageColor'),
3176
+ fontSize: 14,
3177
+ fontFamily: resolveFontFamily(
3178
+ resolveVariable('text.fontFamily'),
3179
+ '400',
3180
+ ),
3181
+ fontWeight: resolveFontWeight('400'),
3182
+ lineHeight: 16,
3183
+ },
3184
+ buttonContainer: {
3185
+ paddingHorizontal: responsiveWidth(12),
3186
+ flexDirection: 'row',
3187
+ flex: 1,
3188
+ justifyContent: 'space-between',
3189
+ marginTop: responsiveHeight(12),
3190
+ },
3191
+ button: {
3192
+ borderRadius: 6,
3193
+ flexDirection: 'row',
3194
+ justifyContent: 'center',
3195
+ alignItems: 'center',
3196
+ height: responsiveHeight(32),
3197
+ width: '49%',
3198
+ padding: responsiveWidth(8),
3199
+ },
3200
+ fullWidthButton: {
3201
+ width: '100%',
3202
+ },
3203
+ buttonText: {
3204
+ fontSize: 12,
3205
+ fontFamily: resolveFontFamily(
3206
+ resolveVariable('text.fontFamily'),
3207
+ '500',
3208
+ ),
3209
+ fontWeight: resolveFontWeight('500'),
3210
+ lineHeight: 16,
3211
+ },
3212
+ cancelButton: {
3213
+ backgroundColor: resolveVariable('toastCancelButtonBackgroundColor'),
3214
+ },
3215
+ confirmButton: {
3216
+ backgroundColor: resolveVariable('toastConfirmButtonBackgroundColor'),
3217
+ },
3218
+ cancelButtonText: {
3219
+ color: resolveVariable('toastCancelButtonTextColor'),
3220
+ },
3221
+ confirmButtonText: {
3222
+ color: resolveVariable('toastConfirmButtonTextColor'),
3223
+ },
3224
+ progressBar: {
3225
+ color: resolveVariable('toastProgressBarColor'),
3226
+ },
3227
+ },
3228
+ 'shoutem.ui.ErrorToast': {
3229
+ container: {
3230
+ backgroundColor: resolveVariable('toastErrorBackgroundColor'),
3231
+ borderWidth: 1,
3232
+ },
3233
+ title: {
3234
+ color: resolveVariable('toastErrorTitleColor'),
3235
+ },
3236
+ message: {
3237
+ color: resolveVariable('toastErrorMessageColor'),
3238
+ },
3239
+ progressBar: {
3240
+ color: resolveVariable('toastErrorProgressBarColor'),
3241
+ },
3242
+ icon: {
3243
+ color: '#D0021B',
3244
+ },
3245
+ },
3246
+ 'shoutem.ui.SuccessToast': {
3247
+ container: {
3248
+ backgroundColor: resolveVariable('toastSuccessBackgroundColor'),
3249
+ borderWidth: 1,
3250
+ },
3251
+ title: {
3252
+ color: resolveVariable('toastSuccessTitleColor'),
3253
+ },
3254
+ message: {
3255
+ color: resolveVariable('toastSuccessMessageColor'),
3256
+ },
3257
+ progressBar: {
3258
+ color: resolveVariable('toastSuccessProgressBarColor'),
3259
+ },
3260
+ icon: {
3261
+ color: '#88C242',
3262
+ },
3263
+ },
3080
3264
  };
3081
3265
  };