react-native-toast-message 2.1.8 → 2.1.9

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/CHANGELOG.md CHANGED
@@ -9,11 +9,17 @@ Headers are one of:
9
9
 
10
10
  - `Added`, `Changed`, `Removed`, `Fixed` or `Breaking`.
11
11
 
12
+ ## [2.1.9]
13
+
14
+ ### Added
15
+
16
+ - feat: add text1Style and text2Style to ToastOptions [#479](https://github.com/calintamas/react-native-toast-message/pull/479)
17
+
12
18
  ## [2.1.8]
13
19
 
14
20
  ### Fixed
15
21
 
16
- - Type update: add 'success', 'error' and 'info' to ToastType (#510)(https://github.com/calintamas/react-native-toast-message/pull/510)
22
+ - Type update: add 'success', 'error' and 'info' to ToastType [#510](https://github.com/calintamas/react-native-toast-message/pull/510)
17
23
 
18
24
  ## [2.1.7]
19
25
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/react-native-toast-message)](https://www.npmjs.com/package/react-native-toast-message)
4
4
  [![npm downloads](https://img.shields.io/npm/dw/react-native-toast-message)](https://www.npmjs.com/package/react-native-toast-message)
5
- [![Build](https://github.com/calintamas/react-native-toast-message/workflows/tests/badge.svg)](https://github.com/calintamas/react-native-toast-message/actions?query=workflow%3Atests)
5
+ [![Build](https://github.com/calintamas/react-native-toast-message/actions/workflows/publish.yml/badge.svg)](https://github.com/calintamas/react-native-toast-message/actions/workflows/publish.yml?query=workflow%3Abuild)
6
6
  [![Coverage Status](https://coveralls.io/repos/github/calintamas/react-native-toast-message/badge.svg?branch=master)](https://coveralls.io/github/calintamas/react-native-toast-message?branch=main)
7
7
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
8
8
 
@@ -10,7 +10,7 @@ const defaultToastConfig = {
10
10
  };
11
11
  function renderComponent({ data, options, config, isVisible, show, hide }) {
12
12
  const { text1, text2 } = data;
13
- const { type, onPress, position, props } = options;
13
+ const { type, onPress, text1Style, text2Style, position, props } = options;
14
14
  const toastConfig = {
15
15
  ...defaultToastConfig,
16
16
  ...config
@@ -25,6 +25,8 @@ function renderComponent({ data, options, config, isVisible, show, hide }) {
25
25
  isVisible,
26
26
  text1,
27
27
  text2,
28
+ text1Style,
29
+ text2Style,
28
30
  show,
29
31
  hide,
30
32
  onPress,
@@ -9,6 +9,14 @@ export declare type ToastOptions = {
9
9
  * Default value: `success`
10
10
  */
11
11
  type?: ToastType;
12
+ /**
13
+ * Style for the header text in the Toast (text1).
14
+ */
15
+ text1Style?: StyleProp<TextStyle>;
16
+ /**
17
+ * Style for the inner message text in the Toast (text2).
18
+ */
19
+ text2Style?: StyleProp<TextStyle>;
12
20
  /**
13
21
  * Toast position.
14
22
  * Default value: `top`
@@ -93,6 +101,8 @@ export declare type ToastConfigParams<Props> = {
93
101
  isVisible: boolean;
94
102
  text1?: string;
95
103
  text2?: string;
104
+ text1Style?: StyleProp<TextStyle>;
105
+ text2Style?: StyleProp<TextStyle>;
96
106
  show: (params: ToastShowParams) => void;
97
107
  hide: (params: ToastHideParams) => void;
98
108
  onPress: () => void;
@@ -9,6 +9,8 @@ export const DEFAULT_DATA = {
9
9
  };
10
10
  export const DEFAULT_OPTIONS = {
11
11
  type: 'success',
12
+ text1Style: null,
13
+ text2Style: null,
12
14
  position: 'top',
13
15
  autoHide: true,
14
16
  visibilityTime: 4000,
@@ -40,13 +42,15 @@ export function useToast({ defaultOptions }) {
40
42
  }, [clearTimer, log, options]);
41
43
  const show = React.useCallback((params) => {
42
44
  log(`Showing with params: ${JSON.stringify(params)}`);
43
- const { text1 = DEFAULT_DATA.text1, text2 = DEFAULT_DATA.text2, type = initialOptions.type, position = initialOptions.position, autoHide = initialOptions.autoHide, visibilityTime = initialOptions.visibilityTime, topOffset = initialOptions.topOffset, bottomOffset = initialOptions.bottomOffset, keyboardOffset = initialOptions.keyboardOffset, onShow = initialOptions.onShow, onHide = initialOptions.onHide, onPress = initialOptions.onPress, props = initialOptions.props } = params;
45
+ const { text1 = DEFAULT_DATA.text1, text2 = DEFAULT_DATA.text2, type = initialOptions.type, text1Style = initialOptions.text1Style, text2Style = initialOptions.text2Style, position = initialOptions.position, autoHide = initialOptions.autoHide, visibilityTime = initialOptions.visibilityTime, topOffset = initialOptions.topOffset, bottomOffset = initialOptions.bottomOffset, keyboardOffset = initialOptions.keyboardOffset, onShow = initialOptions.onShow, onHide = initialOptions.onHide, onPress = initialOptions.onPress, props = initialOptions.props } = params;
44
46
  setData({
45
47
  text1,
46
48
  text2
47
49
  });
48
50
  setOptions(mergeIfDefined(initialOptions, {
49
51
  type,
52
+ text1Style,
53
+ text2Style,
50
54
  position,
51
55
  autoHide,
52
56
  visibilityTime,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-toast-message",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "description": "Toast message component for React Native",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",