react-native-toast-message 2.0.0-beta.1 → 2.0.2

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,6 +9,96 @@ Headers are one of:
9
9
 
10
10
  - `Added`, `Changed`, `Removed`, `Fixed` or `Breaking`.
11
11
 
12
+ ## [2.0.2]
13
+
14
+ ### Fixed
15
+
16
+ - Fast swipe up re-creates the toast [#280](https://github.com/calintamas/react-native-toast-message/issues/280)
17
+
18
+ ## [2.0.1]
19
+
20
+ ### Fixed
21
+
22
+ - `ansi-regex` vulnerability by upgrading to `@testing-library/jest-native v4.0.4` ([#277](https://github.com/calintamas/react-native-toast-message/pull/277))
23
+
24
+ ## [2.0.0]
25
+
26
+ ### Breaking
27
+
28
+ - Setting the `ref` is no longer required when rendering the `Toast` component in your app's entry point. Ref storage is now handled internally using [React.createRef](https://reactjs.org/docs/react-api.html#reactcreateref). This should improve ref access reliability at runtime.
29
+
30
+ ```js
31
+ // App.jsx
32
+ import Toast from 'react-native-toast-message';
33
+
34
+ export function App(props) {
35
+ return (
36
+ <>
37
+ {/* ... */}
38
+ <Toast />
39
+ </>
40
+ );
41
+ }
42
+ ```
43
+
44
+ - When you want to have the Toast visible inside a Modal, you no longer need to set a separate `ref`.
45
+
46
+ Simply render the `Toast` component inside the Modal, as well as in your app's entry point. When the Modal is visible, the `ref` from inside the Modal will be automatically used.
47
+
48
+ - `onHide` callback is now always called when the Toast hides (does not matter if `autoHide` was `true` / `false`).
49
+
50
+ - `inProgress` state has been removed and can no longer be relied upon in a custom Toast config.
51
+
52
+ - `style` and `height` props from the Toast component were removed; with the purpose of achieving a cleaner API design. The only way to change the style / layout of different Toast types is through the `config` prop (fixes [#204](https://github.com/calintamas/react-native-toast-message/issues/204)).
53
+
54
+ ### Added
55
+
56
+ - on the `BaseToast` component, the following props were added: `touchableContainerProps`, `contentContainerProps`, `text1Props`, `text2Props` , `text1NumberOfLines`, `text2NumberOfLines` (fixes [#112](https://github.com/calintamas/react-native-toast-message/issues/112), [#133](https://github.com/calintamas/react-native-toast-message/issues/133)).
57
+
58
+ - on the `Toast` component, the following callbacks were added as props: `onShow` , `onHide` and `onPress` (fixes [#143](https://github.com/calintamas/react-native-toast-message/issues/143)).
59
+
60
+ - A new `ToastShowParams` type is exported (fixes [#192](https://github.com/calintamas/react-native-toast-message/issues/192)).
61
+
62
+ ### Changed
63
+
64
+ - `topOffset` and `bottomOffset` are now by default `40px`
65
+ - New test ids on `BaseToast` component: `toastTouchableContainer`, `toastContentContainer`, `toastText1` and `toastText2`.
66
+
67
+ ### Removed
68
+
69
+ - Success, error and info leading icons were removed from the package (to make it as lightweight as possible).
70
+
71
+ It's now possible to pass them via render functions (for more flexibility, see issues regarding svg support, using components as icons, etc) on `BaseToast` component, example below:
72
+
73
+ ```js
74
+ const toastConfig = {
75
+ success: (props) => (
76
+ <BaseToast
77
+ {...props}
78
+ renderLeadingIcon={() => <Image />}
79
+ renderTrailingIcon={() => <Image />}
80
+ />
81
+ )
82
+ }
83
+ ```
84
+
85
+ Fixes [#188](https://github.com/calintamas/react-native-toast-message/issues/188), [#203](https://github.com/calintamas/react-native-toast-message/issues/203), [#245](https://github.com/calintamas/react-native-toast-message/issues/245), [#250](https://github.com/calintamas/react-native-toast-message/issues/250).
86
+
87
+ - Trailing close icon has been removed from default components `BaseToast`, `SuccessToast`, `ErrorToast` and `InfoToast`. Fixes [#167](https://github.com/calintamas/react-native-toast-message/issues/167).
88
+
89
+ ### Fixed
90
+
91
+ - Failed prop type: Invalid props.text2Style key fontSize supplied to BaseToast [#174](https://github.com/calintamas/react-native-toast-message/issues/174).
92
+ - Changing Font Family does not work [#176](https://github.com/calintamas/react-native-toast-message/issues/176)
93
+ - Text1 not showing on Android [#194](https://github.com/calintamas/react-native-toast-message/issues/194)
94
+ - Toast background is Transparent [#219](https://github.com/calintamas/react-native-toast-message/issues/219)
95
+ - TypeError: Cannot read property 'show' of null [#232](https://github.com/calintamas/react-native-toast-message/issues/232)
96
+ - textStyle1 styles not been applied [#233](https://github.com/calintamas/react-native-toast-message/issues/233)
97
+ - Typescript-class component toast message in modal usage [#172](https://github.com/calintamas/react-native-toast-message/issues/172)
98
+ - Getting last toast along with native prompt [#149](https://github.com/calintamas/react-native-toast-message/issues/149)
99
+ - When modal request permission appear then the modal toast on the previous screen also appears -> android [#226](https://github.com/calintamas/react-native-toast-message/issues/226)
100
+ - autoHide: false crashes on android [#256](https://github.com/calintamas/react-native-toast-message/issues/256)
101
+
12
102
  ## [1.6.0]
13
103
 
14
104
  ### Added
package/README.md CHANGED
@@ -3,7 +3,7 @@
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
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)
6
- [![Coverage Status](https://coveralls.io/repos/github/calintamas/react-native-toast-message/badge.svg)](https://coveralls.io/github/calintamas/react-native-toast-message)
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=master)
7
7
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
8
8
 
9
9
  Animated toast message component for React Native.
@@ -20,6 +20,8 @@ Animated toast message component for React Native.
20
20
 
21
21
  ## Documentation
22
22
 
23
+ > This is the documentation for `react-native-toast-message@v2`, which has a similar API to v1, but contains a few important changes. [Read the complete changelog](./CHANGELOG.md#200).
24
+
23
25
  - [Quick start](./docs/quick-start.md)
24
26
  - [API](./docs/api.md)
25
27
  - [Create custom layouts](./docs/custom-layouts.md)
@@ -11,6 +11,12 @@ export declare type AnimatedContainerProps = {
11
11
  onHide: () => void;
12
12
  onRestorePosition?: () => void;
13
13
  };
14
+ /**
15
+ * Produces a positive damping value.
16
+ *
17
+ * To note: `moveY` becomes negative when going off-screen. By making sure the value
18
+ * produced is always positive, we avoid issues like: https://github.com/calintamas/react-native-toast-message/issues/280
19
+ */
14
20
  export declare function dampingFor(gesture: PanResponderGestureState, position: ToastPosition): number;
15
21
  export declare function animatedValueFor(gesture: PanResponderGestureState, position: ToastPosition, damping: number): number;
16
22
  export declare function AnimatedContainer({ children, isVisible, position, topOffset, bottomOffset, keyboardOffset, onHide, onRestorePosition }: AnimatedContainerProps): JSX.Element;
@@ -6,15 +6,21 @@ import { noop } from '../utils/func';
6
6
  import { bound } from '../utils/number';
7
7
  import { getTestId } from '../utils/test-id';
8
8
  import { styles } from './AnimatedContainer.styles';
9
+ /**
10
+ * Produces a positive damping value.
11
+ *
12
+ * To note: `moveY` becomes negative when going off-screen. By making sure the value
13
+ * produced is always positive, we avoid issues like: https://github.com/calintamas/react-native-toast-message/issues/280
14
+ */
9
15
  export function dampingFor(gesture, position) {
10
16
  const { moveY } = gesture;
11
17
  switch (position) {
12
18
  case 'bottom': {
13
19
  const { height: screenHeight } = Dimensions.get('screen');
14
- return screenHeight - moveY;
20
+ return Math.abs(screenHeight - moveY);
15
21
  }
16
22
  case 'top':
17
- return moveY;
23
+ return Math.abs(moveY);
18
24
  default:
19
25
  throw new Error(`Toast position: ${position} not implemented`);
20
26
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "react-native-toast-message",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.2",
4
4
  "description": "Toast message component for React Native",
5
5
  "main": "./lib/index.js",
6
- "types": "./lib/types/index.d.ts",
6
+ "types": "./lib/index.d.ts",
7
7
  "files": [
8
8
  "/lib"
9
9
  ],
@@ -27,7 +27,7 @@
27
27
  "license": "MIT",
28
28
  "devDependencies": {
29
29
  "@babel/core": "^7.15.8",
30
- "@testing-library/jest-native": "^4.0.2",
30
+ "@testing-library/jest-native": "^4.0.4",
31
31
  "@testing-library/react-hooks": "^7.0.2",
32
32
  "@testing-library/react-native": "^8.0.0",
33
33
  "@types/jest": "^27.0.1",