@janiscommerce/ui-native 1.7.0 → 1.8.1
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/dist/android/app/src/main/assets/fonts/Roboto-Bold.ttf +0 -0
- package/dist/android/app/src/main/assets/fonts/Roboto-Light.ttf +0 -0
- package/dist/android/app/src/main/assets/fonts/Roboto-Medium.ttf +0 -0
- package/dist/android/app/src/main/assets/fonts/Roboto-Regular.ttf +0 -0
- package/dist/components/BaseToast/index.d.ts +17 -0
- package/dist/components/BaseToast/index.js +31 -0
- package/dist/components/BaseToast/utils/index.d.ts +7 -0
- package/dist/components/BaseToast/utils/index.js +7 -0
- package/dist/components/FullScreenMessage/index.js +5 -2
- package/dist/components/Toast/index.d.ts +16 -0
- package/dist/components/Toast/index.js +92 -0
- package/dist/components/Toast/utils/index.d.ts +16 -0
- package/dist/components/Toast/utils/index.js +16 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/theme/palette.js +1 -0
- package/package.json +3 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import { BaseToastProps as Props } from 'react-native-toast-message';
|
|
4
|
+
export declare enum Types {
|
|
5
|
+
Success = "success",
|
|
6
|
+
Notice = "notice",
|
|
7
|
+
Warning = "warning",
|
|
8
|
+
Error = "error",
|
|
9
|
+
Action = "action"
|
|
10
|
+
}
|
|
11
|
+
export interface BaseToastProps extends Props {
|
|
12
|
+
type?: Types;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
style?: {} | ViewStyle;
|
|
15
|
+
}
|
|
16
|
+
declare const BaseToast: FC<BaseToastProps>;
|
|
17
|
+
export default BaseToast;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { black, palette } from '../../theme/palette';
|
|
4
|
+
import { parseType } from './utils';
|
|
5
|
+
export var Types;
|
|
6
|
+
(function (Types) {
|
|
7
|
+
Types["Success"] = "success";
|
|
8
|
+
Types["Notice"] = "notice";
|
|
9
|
+
Types["Warning"] = "warning";
|
|
10
|
+
Types["Error"] = "error";
|
|
11
|
+
Types["Action"] = "action";
|
|
12
|
+
})(Types || (Types = {}));
|
|
13
|
+
const defaultType = Types.Notice;
|
|
14
|
+
const BaseToast = ({ children, style, type = defaultType, ...props }) => {
|
|
15
|
+
if (!children) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const selectedType = parseType[type];
|
|
19
|
+
const backgroundColor = palette[selectedType]?.main || palette[defaultType]?.main;
|
|
20
|
+
const styles = StyleSheet.create({
|
|
21
|
+
container: {
|
|
22
|
+
backgroundColor,
|
|
23
|
+
elevation: 5,
|
|
24
|
+
shadowColor: black.shadow,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return (<View style={[styles.container, style]} {...props}>
|
|
28
|
+
{children}
|
|
29
|
+
</View>);
|
|
30
|
+
};
|
|
31
|
+
export default BaseToast;
|
|
@@ -17,9 +17,10 @@ const FullScreenMessage = ({ backgroundColor = primary.main, title = '', isVisib
|
|
|
17
17
|
const validPaddingHorizontal = scaledForDevice(50, moderateScale);
|
|
18
18
|
const validMarginBottomTitle = scaledForDevice(30, moderateScale);
|
|
19
19
|
const validMarginBottomSubtitle = scaledForDevice(50, moderateScale);
|
|
20
|
-
const validFontTitle = scaledForDevice(
|
|
20
|
+
const validFontTitle = scaledForDevice(34, moderateScale);
|
|
21
21
|
const validFontSubtitle = scaledForDevice(16, moderateScale);
|
|
22
22
|
const validLineHeightTitle = scaledForDevice(40, moderateScale);
|
|
23
|
+
const validLineHeightSubtitle = scaledForDevice(20, moderateScale);
|
|
23
24
|
const styles = StyleSheet.create({
|
|
24
25
|
container: {
|
|
25
26
|
justifyContent: 'center',
|
|
@@ -29,7 +30,7 @@ const FullScreenMessage = ({ backgroundColor = primary.main, title = '', isVisib
|
|
|
29
30
|
backgroundColor: backgroundColor,
|
|
30
31
|
},
|
|
31
32
|
title: {
|
|
32
|
-
|
|
33
|
+
fontFamily: 'Roboto-Medium',
|
|
33
34
|
textAlign: 'center',
|
|
34
35
|
color: textsColor,
|
|
35
36
|
paddingHorizontal: validPaddingHorizontal,
|
|
@@ -38,11 +39,13 @@ const FullScreenMessage = ({ backgroundColor = primary.main, title = '', isVisib
|
|
|
38
39
|
lineHeight: validLineHeightTitle,
|
|
39
40
|
},
|
|
40
41
|
subtitle: {
|
|
42
|
+
fontFamily: 'Roboto-Regular',
|
|
41
43
|
textAlign: 'center',
|
|
42
44
|
color: textsColor,
|
|
43
45
|
paddingHorizontal: validPaddingHorizontal,
|
|
44
46
|
marginBottom: validMarginBottomSubtitle,
|
|
45
47
|
fontSize: validFontSubtitle,
|
|
48
|
+
lineHeight: validLineHeightSubtitle,
|
|
46
49
|
},
|
|
47
50
|
});
|
|
48
51
|
useEffect(() => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { TextStyle } from 'react-native';
|
|
3
|
+
import { BaseToastProps } from '../BaseToast';
|
|
4
|
+
export interface ToastProps extends BaseToastProps {
|
|
5
|
+
props?: {
|
|
6
|
+
showIcon?: boolean;
|
|
7
|
+
customIcon?: string;
|
|
8
|
+
showCloseIcon?: boolean;
|
|
9
|
+
actionTitle?: string;
|
|
10
|
+
onCloseCb?: () => void;
|
|
11
|
+
actionCb?: () => void;
|
|
12
|
+
iconStyle?: TextStyle;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
declare const Toast: FC<ToastProps>;
|
|
16
|
+
export default Toast;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import { moderateScale, scaledForDevice } from '../../scale';
|
|
5
|
+
import { defaultIcon } from './utils';
|
|
6
|
+
import { base, black } from '../../theme/palette';
|
|
7
|
+
import BaseToast from '../BaseToast';
|
|
8
|
+
import ToastAction from 'react-native-toast-message';
|
|
9
|
+
import Text from '../Text';
|
|
10
|
+
import Icon from '../Icon';
|
|
11
|
+
const Toast = ({ type, text1, text2, style, props }) => {
|
|
12
|
+
const validType = type && typeof type === 'string';
|
|
13
|
+
const validTitle = text1 && typeof text1 === 'string';
|
|
14
|
+
const validMessage = text2 && typeof text2 === 'string';
|
|
15
|
+
if (!validType || !validMessage) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const { showIcon = false, customIcon = null, showCloseIcon = false, actionTitle = null, onCloseCb = () => { }, actionCb = () => { }, iconStyle = {}, } = props || {};
|
|
19
|
+
const validColor = type === 'warning' ? black.main : base.white;
|
|
20
|
+
const defaultIconName = defaultIcon[type] || defaultIcon.notice;
|
|
21
|
+
const selectedIconName = customIcon || defaultIconName;
|
|
22
|
+
const horizontalAlign = validTitle ? 'flex-start' : 'center';
|
|
23
|
+
const handleActionCb = () => actionCb();
|
|
24
|
+
const handleCloseCb = () => {
|
|
25
|
+
ToastAction.hide();
|
|
26
|
+
onCloseCb();
|
|
27
|
+
};
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
container: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'row',
|
|
32
|
+
alignItems: horizontalAlign,
|
|
33
|
+
width: '95%',
|
|
34
|
+
borderRadius: scaledForDevice(4, moderateScale),
|
|
35
|
+
paddingHorizontal: scaledForDevice(16, moderateScale),
|
|
36
|
+
paddingVertical: scaledForDevice(16, moderateScale),
|
|
37
|
+
},
|
|
38
|
+
textWrapper: {
|
|
39
|
+
flex: 1,
|
|
40
|
+
},
|
|
41
|
+
title: {
|
|
42
|
+
fontFamily: 'Roboto-Bold',
|
|
43
|
+
fontSize: scaledForDevice(18, moderateScale),
|
|
44
|
+
lineHeight: scaledForDevice(22, moderateScale),
|
|
45
|
+
marginBottom: scaledForDevice(10, moderateScale),
|
|
46
|
+
color: validColor,
|
|
47
|
+
},
|
|
48
|
+
message: {
|
|
49
|
+
fontFamily: 'Roboto-Regular',
|
|
50
|
+
fontSize: scaledForDevice(14, moderateScale),
|
|
51
|
+
lineHeight: scaledForDevice(20, moderateScale),
|
|
52
|
+
color: validColor,
|
|
53
|
+
},
|
|
54
|
+
icon: {
|
|
55
|
+
paddingRight: scaledForDevice(10, moderateScale),
|
|
56
|
+
},
|
|
57
|
+
feedbackWrapper: {
|
|
58
|
+
display: 'flex',
|
|
59
|
+
flexDirection: 'row',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
},
|
|
62
|
+
closeIcon: {
|
|
63
|
+
paddingLeft: scaledForDevice(10, moderateScale),
|
|
64
|
+
},
|
|
65
|
+
actionTitle: {
|
|
66
|
+
marginRight: scaledForDevice(5, moderateScale),
|
|
67
|
+
marginLeft: scaledForDevice(10, moderateScale),
|
|
68
|
+
fontFamily: 'Roboto-Medium',
|
|
69
|
+
fontSize: scaledForDevice(14, moderateScale),
|
|
70
|
+
lineHeight: scaledForDevice(16, moderateScale),
|
|
71
|
+
color: validColor,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
return (<BaseToast type={type} style={[styles.container, style]}>
|
|
75
|
+
{showIcon && (<Icon name={selectedIconName} color={validColor} size={24} style={{ ...styles.icon, ...iconStyle }}/>)}
|
|
76
|
+
|
|
77
|
+
<View style={styles.textWrapper}>
|
|
78
|
+
{validTitle && <Text style={styles.title}>{text1}</Text>}
|
|
79
|
+
{validMessage && <Text style={styles.message}>{text2}</Text>}
|
|
80
|
+
</View>
|
|
81
|
+
|
|
82
|
+
<View style={styles.feedbackWrapper}>
|
|
83
|
+
{actionTitle && (<TouchableOpacity onPress={handleActionCb} activeOpacity={0.6}>
|
|
84
|
+
<Text style={styles.actionTitle}>{actionTitle}</Text>
|
|
85
|
+
</TouchableOpacity>)}
|
|
86
|
+
{showCloseIcon && (<TouchableOpacity onPress={handleCloseCb} activeOpacity={0.6}>
|
|
87
|
+
<Icon name="cross_light" color={validColor} size={24} style={styles.closeIcon}/>
|
|
88
|
+
</TouchableOpacity>)}
|
|
89
|
+
</View>
|
|
90
|
+
</BaseToast>);
|
|
91
|
+
};
|
|
92
|
+
export default Toast;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToastProps } from '../';
|
|
3
|
+
export declare const configToast: {
|
|
4
|
+
success: (props: ToastProps) => React.JSX.Element;
|
|
5
|
+
notice: (props: ToastProps) => React.JSX.Element;
|
|
6
|
+
warning: (props: ToastProps) => React.JSX.Element;
|
|
7
|
+
error: (props: ToastProps) => React.JSX.Element;
|
|
8
|
+
action: (props: ToastProps) => React.JSX.Element;
|
|
9
|
+
};
|
|
10
|
+
export declare const defaultIcon: {
|
|
11
|
+
success: string;
|
|
12
|
+
notice: string;
|
|
13
|
+
warning: string;
|
|
14
|
+
error: string;
|
|
15
|
+
action: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Toast from '..';
|
|
3
|
+
export const configToast = {
|
|
4
|
+
success: (props) => <Toast {...props}/>,
|
|
5
|
+
notice: (props) => <Toast {...props}/>,
|
|
6
|
+
warning: (props) => <Toast {...props}/>,
|
|
7
|
+
error: (props) => <Toast {...props}/>,
|
|
8
|
+
action: (props) => <Toast {...props}/>,
|
|
9
|
+
};
|
|
10
|
+
export const defaultIcon = {
|
|
11
|
+
success: 'check_circle_bold',
|
|
12
|
+
notice: 'info_circle_bold',
|
|
13
|
+
warning: 'exclamation_triangle_bold',
|
|
14
|
+
error: 'cross_big_circle_bold',
|
|
15
|
+
action: 'info_circle_bold',
|
|
16
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -20,5 +20,7 @@ import BaseButton from './components/BaseButton';
|
|
|
20
20
|
import Button from './components/Button/index';
|
|
21
21
|
import FullScreenMessage from './components/FullScreenMessage';
|
|
22
22
|
import LayoutWithBottomButtons from './components/LayoutWithBottomButtons';
|
|
23
|
+
import Toast from 'react-native-toast-message';
|
|
24
|
+
import { configToast } from './components/Toast/utils';
|
|
23
25
|
import * as getScale from './scale';
|
|
24
|
-
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, };
|
|
26
|
+
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, Toast, configToast, };
|
package/dist/index.js
CHANGED
|
@@ -20,5 +20,7 @@ import BaseButton from './components/BaseButton';
|
|
|
20
20
|
import Button from './components/Button/index';
|
|
21
21
|
import FullScreenMessage from './components/FullScreenMessage';
|
|
22
22
|
import LayoutWithBottomButtons from './components/LayoutWithBottomButtons';
|
|
23
|
+
import Toast from 'react-native-toast-message';
|
|
24
|
+
import { configToast } from './components/Toast/utils';
|
|
23
25
|
import * as getScale from './scale';
|
|
24
|
-
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, };
|
|
26
|
+
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, Toast, configToast, };
|
package/dist/theme/palette.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@janiscommerce/ui-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "components library for Janis app",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"react": ">=17.0.2",
|
|
47
47
|
"react-native": ">=0.67.5",
|
|
48
48
|
"react-native-gesture-handler": ">=2.9.0",
|
|
49
|
+
"react-native-toast-message": ">=1.6.0",
|
|
49
50
|
"react-native-reanimated": "2.17.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
@@ -126,6 +127,7 @@
|
|
|
126
127
|
"react-native-safe-area-context": "^4.6.4",
|
|
127
128
|
"react-native-svg": "12.1.1",
|
|
128
129
|
"react-native-vector-icons": "^9.2.0",
|
|
130
|
+
"react-native-toast-message": ">=1.6.0",
|
|
129
131
|
"react-native-web": "^0.15.0"
|
|
130
132
|
}
|
|
131
133
|
}
|