@janiscommerce/ui-native 1.7.0 → 1.8.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,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;
@@ -0,0 +1,7 @@
1
+ export declare const parseType: {
2
+ notice: string;
3
+ action: string;
4
+ success: string;
5
+ warning: string;
6
+ error: string;
7
+ };
@@ -0,0 +1,7 @@
1
+ export const parseType = {
2
+ notice: 'primary',
3
+ action: 'black',
4
+ success: 'success',
5
+ warning: 'alert',
6
+ error: 'error',
7
+ };
@@ -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(32, moderateScale);
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
- fontWeight: 'bold',
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,86 @@
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 Text from '../Text';
9
+ import Icon from '../Icon';
10
+ const Toast = ({ type, text1, text2, style, props }) => {
11
+ const validType = type && typeof type === 'string';
12
+ const validTitle = text1 && typeof text1 === 'string';
13
+ const validMessage = text2 && typeof text2 === 'string';
14
+ if (!validType || !validMessage) {
15
+ return null;
16
+ }
17
+ const { showIcon = false, customIcon = null, showCloseIcon = false, actionTitle = null, onCloseCb = () => { }, actionCb = () => { }, iconStyle = {}, } = props || {};
18
+ const validColor = type === 'warning' ? black.main : base.white;
19
+ const defaultIconName = defaultIcon[type] || defaultIcon.notice;
20
+ const selectedIconName = customIcon || defaultIconName;
21
+ const horizontalAlign = validTitle ? 'flex-start' : 'center';
22
+ const styles = StyleSheet.create({
23
+ container: {
24
+ display: 'flex',
25
+ flexDirection: 'row',
26
+ alignItems: horizontalAlign,
27
+ width: '95%',
28
+ borderRadius: scaledForDevice(4, moderateScale),
29
+ paddingHorizontal: scaledForDevice(16, moderateScale),
30
+ paddingVertical: scaledForDevice(16, moderateScale),
31
+ },
32
+ textWrapper: {
33
+ flex: 1,
34
+ },
35
+ title: {
36
+ fontFamily: 'Roboto-Bold',
37
+ fontSize: scaledForDevice(18, moderateScale),
38
+ lineHeight: scaledForDevice(22, moderateScale),
39
+ marginBottom: scaledForDevice(10, moderateScale),
40
+ color: validColor,
41
+ },
42
+ message: {
43
+ fontFamily: 'Roboto-Regular',
44
+ fontSize: scaledForDevice(14, moderateScale),
45
+ lineHeight: scaledForDevice(20, moderateScale),
46
+ color: validColor,
47
+ },
48
+ icon: {
49
+ paddingRight: scaledForDevice(10, moderateScale),
50
+ },
51
+ feedbackWrapper: {
52
+ display: 'flex',
53
+ flexDirection: 'row',
54
+ alignItems: 'center',
55
+ },
56
+ closeIcon: {
57
+ paddingLeft: scaledForDevice(10, moderateScale),
58
+ },
59
+ actionTitle: {
60
+ marginRight: scaledForDevice(5, moderateScale),
61
+ marginLeft: scaledForDevice(10, moderateScale),
62
+ fontFamily: 'Roboto-Medium',
63
+ fontSize: scaledForDevice(14, moderateScale),
64
+ lineHeight: scaledForDevice(16, moderateScale),
65
+ color: validColor,
66
+ },
67
+ });
68
+ return (<BaseToast type={type} style={[styles.container, style]}>
69
+ {showIcon && (<Icon name={selectedIconName} color={validColor} size={24} style={{ ...styles.icon, ...iconStyle }}/>)}
70
+
71
+ <View style={styles.textWrapper}>
72
+ {validTitle && <Text style={styles.title}>{text1}</Text>}
73
+ {validMessage && <Text style={styles.message}>{text2}</Text>}
74
+ </View>
75
+
76
+ <View style={styles.feedbackWrapper}>
77
+ {actionTitle && (<TouchableOpacity onPress={actionCb} activeOpacity={0.6}>
78
+ <Text style={styles.actionTitle}>{actionTitle}</Text>
79
+ </TouchableOpacity>)}
80
+ {showCloseIcon && (<TouchableOpacity onPress={onCloseCb} activeOpacity={0.6}>
81
+ <Icon name="cross_light" color={validColor} size={24} style={styles.closeIcon}/>
82
+ </TouchableOpacity>)}
83
+ </View>
84
+ </BaseToast>);
85
+ };
86
+ 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, };
@@ -6,6 +6,7 @@ const primary = {
6
6
  const black = {
7
7
  main: '#2F2F2F',
8
8
  dark: '#050505',
9
+ shadow: '#00000096',
9
10
  semiTransparent: '#0000001a',
10
11
  };
11
12
  const white = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janiscommerce/ui-native",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
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
  }