@janiscommerce/ui-native 1.6.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.
Files changed (32) hide show
  1. package/dist/android/app/src/main/assets/fonts/Roboto-Bold.ttf +0 -0
  2. package/dist/android/app/src/main/assets/fonts/Roboto-Light.ttf +0 -0
  3. package/dist/android/app/src/main/assets/fonts/Roboto-Medium.ttf +0 -0
  4. package/dist/android/app/src/main/assets/fonts/Roboto-Regular.ttf +0 -0
  5. package/dist/components/BaseButton/index.d.ts +6 -12
  6. package/dist/components/BaseButton/index.js +9 -43
  7. package/dist/components/BaseToast/index.d.ts +17 -0
  8. package/dist/components/BaseToast/index.js +31 -0
  9. package/dist/components/BaseToast/utils/index.d.ts +7 -0
  10. package/dist/components/BaseToast/utils/index.js +7 -0
  11. package/dist/components/Button/index.d.ts +50 -0
  12. package/dist/components/Button/index.js +54 -0
  13. package/dist/components/Button/types/index.d.ts +45 -0
  14. package/dist/components/Button/types/index.js +1 -0
  15. package/dist/components/Button/utils/getButtonStyles/index.d.ts +3 -0
  16. package/dist/components/Button/utils/getButtonStyles/index.js +84 -0
  17. package/dist/components/Button/utils/getButtonStyles/utils/constants/index.d.ts +5 -0
  18. package/dist/components/Button/utils/getButtonStyles/utils/constants/index.js +5 -0
  19. package/dist/components/Button/utils/getButtonStyles/utils/defaultValues/index.d.ts +5 -0
  20. package/dist/components/Button/utils/getButtonStyles/utils/defaultValues/index.js +5 -0
  21. package/dist/components/Button/utils/getButtonStyles/utils/styleConfigs/index.d.ts +118 -0
  22. package/dist/components/Button/utils/getButtonStyles/utils/styleConfigs/index.js +121 -0
  23. package/dist/components/FullScreenMessage/index.js +5 -2
  24. package/dist/components/Select/Components/Modal/index.js +3 -9
  25. package/dist/components/Toast/index.d.ts +16 -0
  26. package/dist/components/Toast/index.js +86 -0
  27. package/dist/components/Toast/utils/index.d.ts +16 -0
  28. package/dist/components/Toast/utils/index.js +16 -0
  29. package/dist/index.d.ts +4 -1
  30. package/dist/index.js +4 -1
  31. package/dist/theme/palette.js +1 -0
  32. package/package.json +3 -1
@@ -1,16 +1,10 @@
1
- import React, { FC } from 'react';
2
- import { PressableProps, ViewStyle, TextStyle } from 'react-native';
3
- interface BaseButtonProps extends PressableProps {
4
- title?: string | null;
5
- icon?: string;
6
- iconRight?: boolean;
7
- disabled?: boolean;
1
+ import { FC, ReactNode } from 'react';
2
+ import { PressableProps } from 'react-native';
3
+ export interface BaseButtonProps extends PressableProps {
8
4
  borderRadius?: number;
9
- pressedColor?: string;
10
- style?: ViewStyle;
11
- iconStyle?: ViewStyle;
12
- textStyle?: TextStyle;
13
- children?: React.ReactNode;
5
+ children?: ReactNode | null;
6
+ pressedStyle?: ReactNode;
7
+ style?: any;
14
8
  }
15
9
  declare const BaseButton: FC<BaseButtonProps>;
16
10
  export default BaseButton;
@@ -1,58 +1,24 @@
1
1
  import React from 'react';
2
2
  import { Pressable, StyleSheet } from 'react-native';
3
- import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
4
- import { palette } from '../../theme/palette';
5
- import Text from '../Text';
6
- import Icon from '../Icon';
7
- const BaseButton = ({ title = null, icon = null, iconRight = false, disabled = false, borderRadius = 0, pressedColor, style, iconStyle, textStyle, children = null, ...props }) => {
8
- if (!title && !icon && !children) {
3
+ import { moderateScale, scaledForDevice } from '../../scale';
4
+ const BaseButton = ({ borderRadius = 0, children = null, style, pressedStyle, ...props }) => {
5
+ if (!children) {
9
6
  return null;
10
7
  }
11
- const bgColor = !disabled ? palette.primary.main : palette.grey[200];
12
- const iconPaddingLeft = iconRight && title ? 8 : 0;
13
- const iconPaddingRight = !iconRight && title ? 8 : 0;
14
- const validatePaddingVertical = scaledForDevice(10, moderateScale);
15
- const validatePaddingHorizontal = scaledForDevice(16, horizontalScale);
16
- const validateFontSize = scaledForDevice(14, moderateScale);
17
8
  const validateBorderRadius = scaledForDevice(borderRadius, moderateScale);
18
- const validatePaddingRightIcon = scaledForDevice(iconPaddingRight, horizontalScale);
19
- const validatePaddingLeftIcon = scaledForDevice(iconPaddingLeft, horizontalScale);
20
9
  const styles = StyleSheet.create({
21
10
  container: {
22
- display: 'flex',
23
- flexDirection: 'row',
24
11
  alignItems: 'center',
25
12
  justifyContent: 'center',
26
- paddingHorizontal: validatePaddingHorizontal,
27
- paddingVertical: validatePaddingVertical,
28
13
  borderRadius: validateBorderRadius,
29
- backgroundColor: bgColor,
30
- },
31
- icon: {
32
- color: palette.base.white,
33
- paddingRight: validatePaddingRightIcon,
34
- paddingLeft: validatePaddingLeftIcon,
35
- },
36
- title: {
37
- fontSize: validateFontSize,
38
- fontWeight: '500',
39
- textAlign: 'center',
40
- color: palette.base.white,
41
14
  },
42
15
  });
43
- const noChildren = () => (<>
44
- {icon && !iconRight && <Icon name={icon} style={[styles.icon, iconStyle]} size={24}/>}
45
- {title && <Text style={[styles.title, textStyle]}>{title}</Text>}
46
- {icon && iconRight && <Icon name={icon} style={[styles.icon, iconStyle]} size={24}/>}
47
- </>);
48
- /* istanbul ignore next */
49
- const PressableStyle = ({ pressed }) => {
50
- const backgroundColor = pressedColor ?? palette.primary.dark;
51
- const pressedBgColor = pressed ? [{ backgroundColor }] : [];
52
- return [styles.container, style, ...pressedBgColor];
53
- };
54
- return (<Pressable style={PressableStyle} disabled={disabled} {...props}>
55
- {children ?? noChildren}
16
+ return (<Pressable style={({ pressed }) => [
17
+ styles.container,
18
+ style,
19
+ pressed && /* istanbul ignore next */ pressedStyle,
20
+ ]} {...props}>
21
+ {children}
56
22
  </Pressable>);
57
23
  };
58
24
  export default BaseButton;
@@ -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
+ };
@@ -0,0 +1,50 @@
1
+ import { FC } from 'react';
2
+ import { ViewStyle, TextStyle } from 'react-native';
3
+ import { BaseButtonProps } from '../BaseButton';
4
+ export declare const types: {
5
+ main: string;
6
+ secondary: string;
7
+ };
8
+ export declare const variant: {
9
+ contained: string;
10
+ outlined: string;
11
+ text: string;
12
+ };
13
+ export declare const color: {
14
+ primary: string;
15
+ black: string;
16
+ success: string;
17
+ error: string;
18
+ warning: string;
19
+ alert: string;
20
+ };
21
+ export declare const iconPosition: {
22
+ top: string;
23
+ bottom: string;
24
+ left: string;
25
+ right: string;
26
+ };
27
+ export type buttonType = typeof types;
28
+ export type keyType = keyof buttonType;
29
+ export type buttonVariant = typeof variant;
30
+ export type keyVariant = keyof buttonVariant;
31
+ export type buttonColor = typeof color;
32
+ export type keyColor = keyof buttonColor;
33
+ export type buttonIconPosition = typeof iconPosition;
34
+ export type keyIconPosition = keyof buttonIconPosition;
35
+ interface ButtonProps extends BaseButtonProps {
36
+ type?: keyType;
37
+ variant?: keyVariant;
38
+ color?: keyColor;
39
+ isLoading?: boolean;
40
+ value?: string | null;
41
+ icon?: string;
42
+ iconPosition?: keyIconPosition;
43
+ disabled?: boolean;
44
+ style?: ViewStyle;
45
+ pressedStyle?: ViewStyle;
46
+ iconStyle?: TextStyle;
47
+ textStyle?: TextStyle;
48
+ }
49
+ declare const Button: FC<ButtonProps>;
50
+ export default Button;
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import BaseButton from '../BaseButton';
4
+ import getButtonStyles from './utils/getButtonStyles';
5
+ import Loading from '../Loading';
6
+ import Text from '../Text';
7
+ import Icon from '../Icon';
8
+ export const types = {
9
+ main: 'main',
10
+ secondary: 'secondary',
11
+ };
12
+ export const variant = {
13
+ contained: 'contained',
14
+ outlined: 'outlined',
15
+ text: 'text',
16
+ };
17
+ export const color = {
18
+ primary: 'primary',
19
+ black: 'black',
20
+ success: 'success',
21
+ error: 'error',
22
+ warning: 'warning',
23
+ alert: 'alert',
24
+ };
25
+ export const iconPosition = {
26
+ top: 'top',
27
+ bottom: 'bottom',
28
+ left: 'left',
29
+ right: 'right',
30
+ };
31
+ const Button = ({ type = 'main', variant = 'contained', color = 'primary', iconPosition = 'left', isLoading = false, value = 'Button', icon = null, disabled = false, style, iconStyle, textStyle, ...props }) => {
32
+ const validDisabled = disabled || isLoading;
33
+ const hasIconAndText = !!icon && !!value;
34
+ const borderRadius = variant === 'text' ? 6 : 50;
35
+ const buttonStyles = getButtonStyles({
36
+ type,
37
+ variant,
38
+ color,
39
+ iconPosition,
40
+ isLoading,
41
+ isDisabled: disabled,
42
+ hasIconAndText,
43
+ });
44
+ const styles = StyleSheet.create(buttonStyles);
45
+ const LoadingCompontent = <Loading isLoading={isLoading} color={styles.loadingColor} size={24}/>;
46
+ const WrapperComponent = (<View style={styles.direction}>
47
+ {icon && <Icon name={icon} style={[styles.icon, iconStyle]} size={24}/>}
48
+ {value && <Text style={[styles.text, textStyle]}>{value}</Text>}
49
+ </View>);
50
+ return (<BaseButton style={[styles.container, style]} pressedStyle={!validDisabled && styles.pressed} borderRadius={borderRadius} disabled={validDisabled} {...props}>
51
+ {isLoading ? LoadingCompontent : WrapperComponent}
52
+ </BaseButton>);
53
+ };
54
+ export default Button;
@@ -0,0 +1,45 @@
1
+ import type { keyColor, keyIconPosition, keyType, keyVariant } from '../';
2
+ export interface SelectedColor {
3
+ main: string;
4
+ dark: string;
5
+ }
6
+ export interface Params {
7
+ type: keyType;
8
+ variant: keyVariant;
9
+ color: keyColor;
10
+ iconPosition: keyIconPosition;
11
+ isLoading: Boolean;
12
+ isDisabled: Boolean;
13
+ hasIconAndText?: Boolean;
14
+ }
15
+ export interface ReturnStyles {
16
+ container: object;
17
+ direction: object;
18
+ pressed: object;
19
+ icon: object;
20
+ text: object;
21
+ loadingColor: any;
22
+ }
23
+ export interface ContainerStyle {
24
+ isDisabled: Boolean;
25
+ isLoading: Boolean;
26
+ color: keyColor;
27
+ variant: keyVariant;
28
+ type: keyType;
29
+ iconPosition: keyIconPosition;
30
+ }
31
+ export interface TextStyle {
32
+ type: keyType;
33
+ variant: keyVariant;
34
+ color: keyColor;
35
+ isDisabled: Boolean;
36
+ isLoading: Boolean;
37
+ hasIconAndText?: Boolean;
38
+ iconPosition: keyIconPosition;
39
+ }
40
+ export interface LoadingStyle {
41
+ color: keyColor;
42
+ }
43
+ export interface DirectionStyle {
44
+ iconPosition: keyIconPosition;
45
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Params, ReturnStyles } from '../../types';
2
+ declare const getButtonStyles: (params: Params) => ReturnStyles;
3
+ export default getButtonStyles;
@@ -0,0 +1,84 @@
1
+ import { moderateScale, scaledForDevice } from '../../../../scale';
2
+ import { palette } from '../../../../theme/palette';
3
+ import { colorConfig, styleConfig } from './utils/styleConfigs';
4
+ import { validTypes, validVariants, validIconPositions, verticalHeights } from './utils/constants';
5
+ import { defaultColor, defaultIconPosition, defaultType, defaultVariant, } from './utils/defaultValues';
6
+ const containerStyle = ({ isDisabled, isLoading, color, variant, type, iconPosition, }) => {
7
+ const selectedColor = palette[color] || palette[defaultColor];
8
+ const { main, disabled } = colorConfig(selectedColor);
9
+ const { container } = styleConfig;
10
+ const validType = validTypes.includes(type) ? type : defaultType;
11
+ const validVariant = validVariants.includes(variant) ? variant : defaultVariant;
12
+ const mainBgColor = main.background[validVariant];
13
+ const mainBorderColor = main.border[validVariant];
14
+ const disabledBgColor = disabled.background[validVariant];
15
+ const disabledBorderColor = disabled.border[validType][validVariant];
16
+ const containerHeight = container.height[validType];
17
+ // validation of height
18
+ const hasVerticalHeight = verticalHeights.includes(iconPosition);
19
+ return {
20
+ borderWidth: 1,
21
+ borderColor: isDisabled || isLoading ? disabledBorderColor : mainBorderColor,
22
+ backgroundColor: isDisabled || isLoading ? disabledBgColor : mainBgColor,
23
+ paddingHorizontal: scaledForDevice(type === 'main' ? 12 : 8, moderateScale),
24
+ ...(hasVerticalHeight && { paddingVertical: scaledForDevice(10, moderateScale) }),
25
+ ...(!hasVerticalHeight && {
26
+ height: variant !== 'text' ? containerHeight : scaledForDevice(35, moderateScale),
27
+ }),
28
+ };
29
+ };
30
+ const pressedStyle = ({ variant, color }) => {
31
+ const selectedColor = palette[color] || palette[defaultColor];
32
+ const { pressed } = colorConfig(selectedColor);
33
+ const validVariant = validVariants.includes(variant) ? variant : defaultVariant;
34
+ return {
35
+ borderColor: pressed.border[validVariant],
36
+ backgroundColor: pressed.background[validVariant],
37
+ };
38
+ };
39
+ const directionWrapperStyle = ({ iconPosition }) => {
40
+ const { directionWrapper } = styleConfig;
41
+ const flexCenter = directionWrapper.center;
42
+ const validIconPosition = validIconPositions.includes(iconPosition)
43
+ ? iconPosition
44
+ : defaultIconPosition;
45
+ const flexDirection = directionWrapper.flexDirection[validIconPosition];
46
+ return {
47
+ ...flexCenter,
48
+ flexDirection,
49
+ };
50
+ };
51
+ const baseTextStyle = ({ isDisabled, type, variant, color, isLoading }) => {
52
+ const selectedColor = palette[color] || palette[defaultColor];
53
+ const { main, disabled } = colorConfig(selectedColor);
54
+ const { text: textStyle } = styleConfig;
55
+ const validType = validTypes.includes(type) ? type : defaultType;
56
+ const validVariant = validVariants.includes(variant) ? variant : defaultVariant;
57
+ const mainTextColor = main.text[validType][validVariant];
58
+ const disabledTextColor = disabled.text[validType][validVariant];
59
+ return {
60
+ ...textStyle,
61
+ color: isDisabled || isLoading ? disabledTextColor : mainTextColor,
62
+ };
63
+ };
64
+ const textStyle = (params) => ({
65
+ ...baseTextStyle(params),
66
+ fontSize: scaledForDevice(14, moderateScale),
67
+ });
68
+ const iconStyle = (params) => {
69
+ const { hasIconAndText, iconPosition } = params;
70
+ const { icon } = styleConfig;
71
+ return {
72
+ ...baseTextStyle(params),
73
+ ...((!!hasIconAndText && icon.margin[iconPosition]) || {}),
74
+ };
75
+ };
76
+ const getButtonStyles = (params) => ({
77
+ container: containerStyle(params),
78
+ pressed: pressedStyle(params),
79
+ direction: directionWrapperStyle(params),
80
+ text: textStyle(params),
81
+ icon: iconStyle(params),
82
+ loadingColor: palette.primary.main,
83
+ });
84
+ export default getButtonStyles;
@@ -0,0 +1,5 @@
1
+ declare const verticalHeights: string[];
2
+ declare const validTypes: string[];
3
+ declare const validVariants: string[];
4
+ declare const validIconPositions: string[];
5
+ export { verticalHeights, validTypes, validVariants, validIconPositions };
@@ -0,0 +1,5 @@
1
+ const verticalHeights = ['top', 'bottom'];
2
+ const validTypes = ['main', 'secondary'];
3
+ const validVariants = ['contained', 'outlined', 'text'];
4
+ const validIconPositions = ['top', 'bottom', 'left', 'right'];
5
+ export { verticalHeights, validTypes, validVariants, validIconPositions };
@@ -0,0 +1,5 @@
1
+ declare const defaultColor = "primary";
2
+ declare const defaultType = "main";
3
+ declare const defaultVariant = "contained";
4
+ declare const defaultIconPosition = "left";
5
+ export { defaultColor, defaultType, defaultVariant, defaultIconPosition };
@@ -0,0 +1,5 @@
1
+ const defaultColor = 'primary';
2
+ const defaultType = 'main';
3
+ const defaultVariant = 'contained';
4
+ const defaultIconPosition = 'left';
5
+ export { defaultColor, defaultType, defaultVariant, defaultIconPosition };
@@ -0,0 +1,118 @@
1
+ import { SelectedColor } from '../../../../types';
2
+ export declare const colorConfig: (selectedColor: SelectedColor) => {
3
+ main: {
4
+ background: {
5
+ contained: string;
6
+ outlined: string;
7
+ text: string;
8
+ };
9
+ border: {
10
+ contained: string;
11
+ outlined: string;
12
+ text: string;
13
+ };
14
+ text: {
15
+ main: {
16
+ contained: string;
17
+ outlined: string;
18
+ text: string;
19
+ };
20
+ secondary: {
21
+ contained: string;
22
+ outlined: string;
23
+ text: string;
24
+ };
25
+ };
26
+ };
27
+ pressed: {
28
+ background: {
29
+ contained: string;
30
+ outlined: string;
31
+ text: string;
32
+ };
33
+ border: {
34
+ contained: string;
35
+ outlined: string;
36
+ text: string;
37
+ };
38
+ text: {
39
+ main: {
40
+ contained: string;
41
+ outlined: string;
42
+ text: string;
43
+ };
44
+ secondary: {
45
+ contained: string;
46
+ outlined: string;
47
+ text: string;
48
+ };
49
+ };
50
+ };
51
+ disabled: {
52
+ background: {
53
+ contained: string;
54
+ outlined: string;
55
+ text: string;
56
+ };
57
+ border: {
58
+ main: {
59
+ contained: string;
60
+ outlined: string;
61
+ text: string;
62
+ };
63
+ secondary: {
64
+ contained: string;
65
+ outlined: string;
66
+ text: string;
67
+ };
68
+ };
69
+ text: {
70
+ main: {
71
+ contained: string;
72
+ outlined: string;
73
+ text: string;
74
+ };
75
+ secondary: {
76
+ contained: string;
77
+ outlined: string;
78
+ text: string;
79
+ };
80
+ };
81
+ };
82
+ };
83
+ export declare const styleConfig: {
84
+ container: {
85
+ height: {
86
+ main: number;
87
+ secondary: number;
88
+ };
89
+ };
90
+ directionWrapper: {
91
+ center: {
92
+ justifyContent: string;
93
+ alignItems: string;
94
+ };
95
+ flexDirection: {
96
+ left: string;
97
+ right: string;
98
+ top: string;
99
+ bottom: string;
100
+ };
101
+ };
102
+ text: {
103
+ fontWeight: string;
104
+ textAlign: string;
105
+ };
106
+ icon: {
107
+ margin: {
108
+ top: {};
109
+ bottom: {};
110
+ left: {
111
+ marginRight: number;
112
+ };
113
+ right: {
114
+ marginLeft: number;
115
+ };
116
+ };
117
+ };
118
+ };
@@ -0,0 +1,121 @@
1
+ import { moderateScale, scaledForDevice } from '../../../../../../scale';
2
+ import { base, black, grey, white } from '../../../../../../theme/palette';
3
+ export const colorConfig = (selectedColor) => {
4
+ return {
5
+ main: {
6
+ background: {
7
+ contained: selectedColor.main,
8
+ outlined: base.white,
9
+ text: 'transparent',
10
+ },
11
+ border: {
12
+ contained: 'transparent',
13
+ outlined: grey[300],
14
+ text: 'transparent',
15
+ },
16
+ text: {
17
+ main: {
18
+ contained: base.white,
19
+ outlined: black.main,
20
+ text: black.main,
21
+ },
22
+ secondary: {
23
+ contained: base.white,
24
+ outlined: selectedColor.main,
25
+ text: selectedColor.main,
26
+ },
27
+ },
28
+ },
29
+ pressed: {
30
+ background: {
31
+ contained: selectedColor.dark,
32
+ outlined: base.white,
33
+ text: white.main,
34
+ },
35
+ border: {
36
+ contained: 'transparent',
37
+ outlined: selectedColor.main,
38
+ text: 'transparent',
39
+ },
40
+ text: {
41
+ main: {
42
+ contained: base.white,
43
+ outlined: black.main,
44
+ text: black.main,
45
+ },
46
+ secondary: {
47
+ contained: base.white,
48
+ outlined: selectedColor.main,
49
+ text: selectedColor.dark,
50
+ },
51
+ },
52
+ },
53
+ disabled: {
54
+ background: {
55
+ contained: grey[200],
56
+ outlined: grey[100],
57
+ text: 'transparent',
58
+ },
59
+ border: {
60
+ main: {
61
+ contained: 'transparent',
62
+ outlined: 'transparent',
63
+ text: 'transparent',
64
+ },
65
+ secondary: {
66
+ contained: 'transparent',
67
+ outlined: grey[300],
68
+ text: 'transparent',
69
+ },
70
+ },
71
+ text: {
72
+ main: {
73
+ contained: grey[400],
74
+ outlined: grey[300],
75
+ text: grey[300],
76
+ },
77
+ secondary: {
78
+ contained: grey[400],
79
+ outlined: grey[300],
80
+ text: grey[300],
81
+ },
82
+ },
83
+ },
84
+ };
85
+ };
86
+ export const styleConfig = {
87
+ container: {
88
+ height: {
89
+ main: scaledForDevice(50, moderateScale),
90
+ secondary: scaledForDevice(42, moderateScale),
91
+ },
92
+ },
93
+ directionWrapper: {
94
+ center: {
95
+ justifyContent: 'center',
96
+ alignItems: 'center',
97
+ },
98
+ flexDirection: {
99
+ left: 'row',
100
+ right: 'row-reverse',
101
+ top: 'column',
102
+ bottom: 'column-reverse',
103
+ },
104
+ },
105
+ text: {
106
+ fontWeight: '500',
107
+ textAlign: 'center',
108
+ },
109
+ icon: {
110
+ margin: {
111
+ top: {},
112
+ bottom: {},
113
+ left: {
114
+ marginRight: scaledForDevice(8, moderateScale),
115
+ },
116
+ right: {
117
+ marginLeft: scaledForDevice(8, moderateScale),
118
+ },
119
+ },
120
+ },
121
+ };
@@ -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(() => {
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Modal as ModalComponent, StyleSheet, View } from 'react-native';
3
- import { base, primary, white } from '../../../../theme/palette';
4
- import BaseButton from '../../../BaseButton';
3
+ import { base } from '../../../../theme/palette';
5
4
  import { moderateScale, scaledForDevice } from '../../../../scale';
5
+ import Button from '../../../Button';
6
6
  const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
7
7
  const validBottom = scaledForDevice(20, moderateScale);
8
8
  const validMinWidth = scaledForDevice(270, moderateScale);
@@ -11,7 +11,6 @@ const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
11
11
  const validPaddingHorizontal = scaledForDevice(20, moderateScale);
12
12
  const validLeft = scaledForDevice(8, moderateScale);
13
13
  const validTop = scaledForDevice(4, moderateScale);
14
- const validFontSize = scaledForDevice(13, moderateScale);
15
14
  const styles = StyleSheet.create({
16
15
  background: {
17
16
  display: 'flex',
@@ -41,12 +40,7 @@ const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
41
40
  left: validLeft,
42
41
  top: validTop,
43
42
  },
44
- button: {
45
- backgroundColor: base.white,
46
- },
47
43
  buttonText: {
48
- color: primary.main,
49
- fontSize: validFontSize,
50
44
  fontWeight: '700',
51
45
  textTransform: 'uppercase',
52
46
  },
@@ -56,7 +50,7 @@ const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
56
50
  <View style={styles.contentWrapper}>
57
51
  <View style={styles.containerModal}>{children}</View>
58
52
  {isMulti && (<View style={styles.buttonWrapper}>
59
- <BaseButton title={modalAcceptText} iconRight={false} pressedColor={white.main} style={styles.button} textStyle={styles.buttonText} onPress={() => setShow(false)}/>
53
+ <Button value={modalAcceptText} variant={'text'} type={'secondary'} textStyle={styles.buttonText} onPress={() => setShow(false)}/>
60
54
  </View>)}
61
55
  </View>
62
56
  </View>
@@ -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
@@ -17,7 +17,10 @@ import Carousel from './components/Carousel';
17
17
  import ProgressBar from './components/ProgressBar';
18
18
  import List from './components/List';
19
19
  import BaseButton from './components/BaseButton';
20
+ import Button from './components/Button/index';
20
21
  import FullScreenMessage from './components/FullScreenMessage';
21
22
  import LayoutWithBottomButtons from './components/LayoutWithBottomButtons';
23
+ import Toast from 'react-native-toast-message';
24
+ import { configToast } from './components/Toast/utils';
22
25
  import * as getScale from './scale';
23
- export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, 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
@@ -17,7 +17,10 @@ import Carousel from './components/Carousel';
17
17
  import ProgressBar from './components/ProgressBar';
18
18
  import List from './components/List';
19
19
  import BaseButton from './components/BaseButton';
20
+ import Button from './components/Button/index';
20
21
  import FullScreenMessage from './components/FullScreenMessage';
21
22
  import LayoutWithBottomButtons from './components/LayoutWithBottomButtons';
23
+ import Toast from 'react-native-toast-message';
24
+ import { configToast } from './components/Toast/utils';
22
25
  import * as getScale from './scale';
23
- export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, 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.6.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
  }