rn-toastify 1.0.9 → 1.0.11
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/README.MD +96 -190
- package/index.js +25 -21
- package/package.json +2 -2
- package/src/context/ToastContainer.js +22 -10
package/README.MD
CHANGED
|
@@ -1,47 +1,63 @@
|
|
|
1
|
+
# React Native Toastify
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
A highly customizable and performant toast notification library for React Native. Featuring smooth animations, swipe gestures, and flexible styling options.
|
|
3
4
|
|
|
5
|
+

|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
---
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
# rn-toastify (react-native-toast)
|
|
9
|
+
## 🚀 Features
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
- **Single-root container**: Mount once at the app root.
|
|
12
|
+
- **Imperative API**: Use `useToast` hook anywhere in your app.
|
|
13
|
+
- **Light/Dark Theme**: System-aware with optional forced theme.
|
|
14
|
+
- **Promise Helper**: Show loading, success, and error states.
|
|
15
|
+
- **Customizable**: Add custom content, styles, and emojis.
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
---
|
|
13
18
|
|
|
14
|
-
##
|
|
19
|
+
## 📦 Installation
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
- Imperative hook API (useToast) — call from anywhere in your component tree
|
|
18
|
-
- System-aware light/dark theme with optional forced theme
|
|
19
|
-
- Promise helper (loading → success/error)
|
|
20
|
-
- Custom content and emoji toasts
|
|
21
|
-
|
|
22
|
-
## Installation
|
|
21
|
+
Install the package using npm or yarn:
|
|
23
22
|
|
|
24
23
|
```bash
|
|
25
24
|
npm install rn-toastify
|
|
26
25
|
```
|
|
27
26
|
|
|
28
|
-
Or
|
|
27
|
+
Or:
|
|
29
28
|
|
|
30
29
|
```bash
|
|
31
30
|
yarn add rn-toastify
|
|
32
31
|
```
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
### Peer Dependencies
|
|
34
|
+
|
|
35
|
+
Ensure the following peer dependencies are installed:
|
|
36
|
+
|
|
37
|
+
- `react`
|
|
38
|
+
- `react-native`
|
|
39
|
+
- `react-native-reanimated` (v2+)
|
|
40
|
+
- `lottie-react-native`
|
|
41
|
+
|
|
42
|
+
For iOS, run:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
cd ios && pod install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
35
49
|
|
|
36
|
-
|
|
50
|
+
## 🛠️ Quick Start
|
|
37
51
|
|
|
38
|
-
|
|
52
|
+
### Step 1: Mount the Toast Container
|
|
53
|
+
|
|
54
|
+
Add the `ToastContainer` to your app's root component (e.g., `App.js`):
|
|
39
55
|
|
|
40
56
|
```javascript
|
|
41
57
|
import React from 'react';
|
|
42
58
|
import { NavigationContainer } from '@react-navigation/native';
|
|
43
59
|
import MainNavigator from './src/navigation';
|
|
44
|
-
import
|
|
60
|
+
import { ToastContainer } from 'rn-toastify';
|
|
45
61
|
|
|
46
62
|
export default function App() {
|
|
47
63
|
return (
|
|
@@ -49,15 +65,15 @@ export default function App() {
|
|
|
49
65
|
<NavigationContainer>
|
|
50
66
|
<MainNavigator />
|
|
51
67
|
</NavigationContainer>
|
|
52
|
-
|
|
53
|
-
{/* Mount once at root. Optionally force theme: <ToastContainer theme="dark" /> */}
|
|
54
|
-
<ToastContainer />
|
|
68
|
+
<ToastContainer theme="dark" /> {/* Optional: Force theme */}
|
|
55
69
|
</>
|
|
56
70
|
);
|
|
57
71
|
}
|
|
58
72
|
```
|
|
59
73
|
|
|
60
|
-
2
|
|
74
|
+
### Step 2: Use the `useToast` Hook
|
|
75
|
+
|
|
76
|
+
Call toast methods anywhere in your app:
|
|
61
77
|
|
|
62
78
|
```javascript
|
|
63
79
|
import React from 'react';
|
|
@@ -65,44 +81,62 @@ import { View, Button } from 'react-native';
|
|
|
65
81
|
import useToast from 'rn-toastify';
|
|
66
82
|
|
|
67
83
|
export default function HomeScreen() {
|
|
68
|
-
const { success, error
|
|
84
|
+
const { success, error } = useToast();
|
|
69
85
|
|
|
70
86
|
return (
|
|
71
87
|
<View>
|
|
72
|
-
<Button title="Success" onPress={() => success('
|
|
73
|
-
<Button title="Error" onPress={() => error('
|
|
88
|
+
<Button title="Show Success" onPress={() => success('Operation successful!')} />
|
|
89
|
+
<Button title="Show Error" onPress={() => error('Something went wrong.', { position: 'top' })} />
|
|
74
90
|
</View>
|
|
75
91
|
);
|
|
76
92
|
}
|
|
77
93
|
```
|
|
78
94
|
|
|
79
|
-
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 📖 API Reference
|
|
98
|
+
|
|
99
|
+
### `useToast` Hook
|
|
100
|
+
|
|
101
|
+
The `useToast` hook provides the following methods:
|
|
102
|
+
|
|
103
|
+
| Method | Description |
|
|
104
|
+
|----------|--------------------------------------|
|
|
105
|
+
| `show` | Display a custom toast. |
|
|
106
|
+
| `success`| Show a success toast. |
|
|
107
|
+
| `error` | Show an error toast. |
|
|
108
|
+
| `custom` | Render a custom React element. |
|
|
109
|
+
| `emoji` | Display a toast with an emoji. |
|
|
110
|
+
| `promise`| Handle promise states with toasts. |
|
|
80
111
|
|
|
81
|
-
|
|
112
|
+
### Common Options
|
|
82
113
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
- `promise(promise, { loading, success, error }, options)`
|
|
114
|
+
| Option | Type | Description |
|
|
115
|
+
|------------|----------|--------------------------------------|
|
|
116
|
+
| `duration` | `number` | Duration in milliseconds. |
|
|
117
|
+
| `position` | `string` | `'top' | 'bottom' | 'center'`. |
|
|
118
|
+
| `style` | `object` | Custom styles for the toast wrapper. |
|
|
89
119
|
|
|
90
|
-
### Options
|
|
120
|
+
### `promise` Method Options
|
|
91
121
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
122
|
+
| Option | Type | Description |
|
|
123
|
+
|------------|----------|--------------------------------------|
|
|
124
|
+
| `loading` | `string` | Message during loading. |
|
|
125
|
+
| `success` | `string` | Message on success. |
|
|
126
|
+
| `error` | `string` | Message on error. |
|
|
95
127
|
|
|
96
|
-
|
|
128
|
+
---
|
|
97
129
|
|
|
98
|
-
|
|
130
|
+
## 🌈 Examples
|
|
131
|
+
|
|
132
|
+
### Success Toast
|
|
99
133
|
|
|
100
134
|
```javascript
|
|
101
135
|
const { success } = useToast();
|
|
102
|
-
success('Operation successful', { duration: 1500, position: 'top' });
|
|
136
|
+
success('Operation successful!', { duration: 1500, position: 'top' });
|
|
103
137
|
```
|
|
104
138
|
|
|
105
|
-
Promise
|
|
139
|
+
### Promise Helper
|
|
106
140
|
|
|
107
141
|
```javascript
|
|
108
142
|
const { promise } = useToast();
|
|
@@ -111,174 +145,46 @@ const myPromise = fetch('/api/save');
|
|
|
111
145
|
|
|
112
146
|
promise(myPromise, {
|
|
113
147
|
loading: 'Saving…',
|
|
114
|
-
success: 'Saved!',
|
|
115
|
-
error: 'Save failed',
|
|
148
|
+
success: 'Saved successfully!',
|
|
149
|
+
error: 'Save failed.',
|
|
116
150
|
});
|
|
117
151
|
```
|
|
118
152
|
|
|
119
|
-
Custom
|
|
153
|
+
### Custom Content
|
|
120
154
|
|
|
121
155
|
```javascript
|
|
122
156
|
const { custom } = useToast();
|
|
123
|
-
custom(<
|
|
157
|
+
custom(<MyCustomComponent />, { duration: 2000 });
|
|
124
158
|
```
|
|
125
159
|
|
|
126
|
-
Emoji
|
|
160
|
+
### Emoji Toast
|
|
127
161
|
|
|
128
162
|
```javascript
|
|
129
163
|
const { emoji } = useToast();
|
|
130
|
-
emoji('Great job!', '
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Theme
|
|
134
|
-
|
|
135
|
-
- By default `ToastContainer` detects the system color scheme (via `Appearance`) and passes a `theme` prop to visual toast components.
|
|
136
|
-
- To force a theme, mount the container with `theme`:
|
|
137
|
-
|
|
138
|
-
```jsx
|
|
139
|
-
<ToastContainer theme="dark" />
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
If the system color scheme is unavailable, the toast theme defaults to `light`.
|
|
143
|
-
|
|
144
|
-
## Compatibility & installation notes
|
|
145
|
-
|
|
146
|
-
- Peer dependencies: `react`, `react-native`, `react-native-reanimated` (v2+), `lottie-react-native` (if using animations). Install and link those in your app. See `package.json`.
|
|
147
|
-
- Reanimated setup: add `react-native-reanimated/plugin` to `babel.config.js` as the last plugin.
|
|
148
|
-
- iOS: run `cd ios && pod install` on macOS after installing native dependencies.
|
|
149
|
-
|
|
150
|
-
## Import styles
|
|
151
|
-
|
|
152
|
-
This package exports a default `useToast` hook and named exports. Both of the following work:
|
|
153
|
-
|
|
154
|
-
```javascript
|
|
155
|
-
// ES default + named
|
|
156
|
-
import useToast, { ToastContainer } from 'rn-toastify';
|
|
157
|
-
|
|
158
|
-
// CommonJS
|
|
159
|
-
const rnToastify = require('rn-toastify');
|
|
160
|
-
const useToast = rnToastify.useToast || rnToastify.default;
|
|
161
|
-
const { ToastContainer } = rnToastify;
|
|
164
|
+
emoji('Great job!', '🎉', { duration: 1300 });
|
|
162
165
|
```
|
|
163
166
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
- Crash on app start / `_rnToastify.default is not a function`:
|
|
167
|
-
- Clear Metro cache and rebuild: `npx react-native start --reset-cache` and rebuild the app.
|
|
168
|
-
- Ensure your app resolves the package's `index.js` correctly (this package exports a CommonJS-friendly entry to avoid interop issues).
|
|
169
|
-
|
|
170
|
-
- Reanimated-related errors:
|
|
171
|
-
- Add the Reanimated babel plugin and rebuild the app. See Reanimated installation docs.
|
|
172
|
-
|
|
173
|
-
- Lottie errors on iOS:
|
|
174
|
-
- Run `cd ios && pod install` and rebuild from Xcode.
|
|
175
|
-
|
|
176
|
-
- Toasts not showing:
|
|
177
|
-
- Make sure `ToastContainer` is mounted once at the app root.
|
|
178
|
-
- Ensure native peer dependencies are installed and app rebuilt.
|
|
179
|
-
|
|
180
|
-
## Publishing & versioning
|
|
181
|
-
|
|
182
|
-
When you're ready to release this change to npm:
|
|
183
|
-
|
|
184
|
-
1. Update the package version in `package.json` (or run `npm version patch|minor|major`).
|
|
185
|
-
2. Run tests and build (if any): `npm test`.
|
|
186
|
-
3. Pack and inspect: `npm pack`.
|
|
187
|
-
4. Publish: `npm publish --access public` (make sure you're logged in via `npm login`).
|
|
188
|
-
|
|
189
|
-
## Contributing
|
|
190
|
-
|
|
191
|
-
PRs welcome. Please open an issue if you find bugs or want features like scoped containers, configurable color tokens, or example apps.
|
|
192
|
-
|
|
193
|
-
## License
|
|
194
|
-
|
|
195
|
-
MIT
|
|
196
|
-
<Button title="Show Custom Toast" onPress={() => custom(
|
|
197
|
-
<View style={styles.customContent}>
|
|
198
|
-
<Text>Custom Toast Content</Text>
|
|
199
|
-
</View>,
|
|
200
|
-
{ duration: 1500, position: 'top' }
|
|
201
|
-
)} />
|
|
202
|
-
<Button title="Show Emoji Toast" onPress={() => emoji('Great job!', '👍', { duration: 1500, position: 'top' })} />
|
|
203
|
-
<ToastContainer />
|
|
204
|
-
</View>
|
|
205
|
-
);
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
const styles = StyleSheet.create({
|
|
209
|
-
container: {
|
|
210
|
-
flex: 1,
|
|
211
|
-
justifyContent: 'center',
|
|
212
|
-
alignItems: 'center',
|
|
213
|
-
},
|
|
214
|
-
customContent: {
|
|
215
|
-
padding: 10,
|
|
216
|
-
backgroundColor: '#fff',
|
|
217
|
-
borderRadius: 5,
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
export default AppContent;
|
|
222
|
-
```
|
|
223
|
-
This example integrates multiple toast types and demonstrates how to trigger each one. It also includes the necessary ToastContainer to display the toasts.
|
|
224
|
-
|
|
225
|
-
Theme and single-root notes
|
|
226
|
-
- Mount `ToastContainer` once at the app root (recommended). The container detects the system color scheme by default and passes a `theme` prop to all toast components.
|
|
227
|
-
- To force a theme, pass `theme="dark"` or `theme="light"` to `<ToastContainer />`.
|
|
228
|
-
- If the system color scheme is unavailable, the toast theme defaults to `light`.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
## API Reference
|
|
232
|
-
|
|
233
|
-
#### useToast Hook Methods
|
|
234
|
-
All toast methods accept the following parameters:
|
|
235
|
-
|
|
236
|
-
| Parameter | Type | Description |
|
|
237
|
-
| :-------- | :------- | :------------------------- |
|
|
238
|
-
| `message` | `string` | **Required**. The message to display in the toast. |
|
|
239
|
-
| `options` | `object` | **Optional**. Configuration options for the toast (e.g., duration, position). |
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
- Methods
|
|
243
|
-
|
|
244
|
-
- success : Displays a success toast.
|
|
245
|
-
|
|
246
|
-
- error : Displays an error toast.
|
|
247
|
-
|
|
248
|
-
- promise : Handles a promise and displays loading, success, and error toasts based on the promise's state.
|
|
249
|
-
|
|
250
|
-
Additional options for promise method:
|
|
251
|
-
| Option | Type | Description |
|
|
252
|
-
| :-------- | :------- | :------------------------- |
|
|
253
|
-
| `loading` | `string` | The message to display in the toast. |
|
|
254
|
-
| `success` | `string` | Message to display if the promise resolves. |
|
|
255
|
-
| `error` | `string` | Message to display if the promise is rejected. |
|
|
256
|
-
|
|
257
|
-
- custom
|
|
167
|
+
---
|
|
258
168
|
|
|
259
|
-
|
|
169
|
+
## 🎨 Theme Support
|
|
260
170
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
| `content` | `element` | **Required**. React element to render in the toast. |
|
|
171
|
+
- **Automatic**: Detects system theme (light/dark).
|
|
172
|
+
- **Forced**: Pass `theme="light"` or `theme="dark"` to `ToastContainer`.
|
|
264
173
|
|
|
265
|
-
|
|
174
|
+
If the system theme is unavailable, the default is `light`.
|
|
266
175
|
|
|
267
|
-
|
|
176
|
+
---
|
|
268
177
|
|
|
269
|
-
|
|
270
|
-
| :-------- | :------- | :------------------------- |
|
|
271
|
-
| `emoji` | `string` | **Required**. The emoji to display alongside the message. |
|
|
178
|
+
## 🐛 Troubleshooting
|
|
272
179
|
|
|
273
|
-
|
|
180
|
+
### Common Issues
|
|
274
181
|
|
|
275
|
-
|
|
182
|
+
- **Toasts not showing**: Ensure `ToastContainer` is mounted at the app root.
|
|
183
|
+
- **Reanimated errors**: Add the Reanimated Babel plugin and rebuild.
|
|
184
|
+
- **Lottie issues on iOS**: Run `cd ios && pod install`.
|
|
276
185
|
|
|
277
|
-
|
|
278
|
-
| :-------- | :------- | :------------------------- |
|
|
279
|
-
| `duration` | `number` |**Optional**. Duration in milliseconds for which the toast is visible. |
|
|
280
|
-
| `position` | `string` | **Optional**. Position of the toast on the screen (top, bottom, center). |
|
|
186
|
+
---
|
|
281
187
|
|
|
282
|
-
## License
|
|
188
|
+
## 📜 License
|
|
283
189
|
|
|
284
|
-
[
|
|
190
|
+
MIT License. See [LICENSE](./LICENSE) for details.
|
package/index.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const _loadingMod = require('./src/components/LoadingToast');
|
|
1
|
+
// Fixed index.js - Simplified export structure
|
|
2
|
+
const useToastModule = require('./src/hooks/useToast');
|
|
3
|
+
const ToastModule = require('./src/Toast');
|
|
4
|
+
const ToastContainerModule = require('./src/context/ToastContainer');
|
|
5
|
+
const SuccessToastModule = require('./src/components/SuccessToast');
|
|
6
|
+
const CustomeToastModule = require('./src/components/CustomeToast');
|
|
7
|
+
const EmojiToastModule = require('./src/components/EmojiToast');
|
|
8
|
+
const ErrorToastModule = require('./src/components/ErrorToast');
|
|
9
|
+
const LoadingToastModule = require('./src/components/LoadingToast');
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
11
|
+
// Extract default exports properly
|
|
12
|
+
const useToast = useToastModule.default || useToastModule;
|
|
13
|
+
const Toast = ToastModule.default || ToastModule;
|
|
14
|
+
const ToastContainer = ToastContainerModule.default || ToastContainerModule;
|
|
15
|
+
const SuccessToast = SuccessToastModule.default || SuccessToastModule;
|
|
16
|
+
const CustomeToast = CustomeToastModule.default || CustomeToastModule;
|
|
17
|
+
const EmojiToast = EmojiToastModule.default || EmojiToastModule;
|
|
18
|
+
const ErrorToast = ErrorToastModule.default || ErrorToastModule;
|
|
19
|
+
const LoadingToast = LoadingToastModule.default || LoadingToastModule;
|
|
20
20
|
|
|
21
|
-
//
|
|
21
|
+
// Primary default export
|
|
22
22
|
module.exports = useToast;
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
// Named exports
|
|
24
25
|
module.exports.useToast = useToast;
|
|
25
26
|
module.exports.Toast = Toast;
|
|
26
27
|
module.exports.ToastContainer = ToastContainer;
|
|
@@ -28,4 +29,7 @@ module.exports.SuccessToast = SuccessToast;
|
|
|
28
29
|
module.exports.CustomeToast = CustomeToast;
|
|
29
30
|
module.exports.EmojiToast = EmojiToast;
|
|
30
31
|
module.exports.ErrorToast = ErrorToast;
|
|
31
|
-
module.exports.LoadingToast = LoadingToast;
|
|
32
|
+
module.exports.LoadingToast = LoadingToast;
|
|
33
|
+
|
|
34
|
+
// Also support default property for ES6 imports
|
|
35
|
+
module.exports.default = useToast;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rn-toastify",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "A customizable and performant toast notification library for React Native, featuring smooth animations, swipe gestures, and flexible styling options.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "Mukesh Prajapati",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"react": ">=16.8.0 <
|
|
28
|
+
"react": ">=16.8.0 <20.0.0",
|
|
29
29
|
"react-native": ">=0.60.0 <1.0.0",
|
|
30
30
|
"react-native-reanimated": ">=2.0.0 <5.0.0",
|
|
31
31
|
"lottie-react-native": ">=3.0.0 <9.0.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { View, StyleSheet, Appearance } from 'react-native';
|
|
2
|
+
import { View, StyleSheet, Appearance, StatusBar, Platform } from 'react-native';
|
|
3
3
|
import Toast from '../Toast';
|
|
4
4
|
import toastManagerInstance from './ToastManager';
|
|
5
5
|
import {
|
|
@@ -35,17 +35,31 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
|
|
|
35
35
|
toastManagerInstance.off('remove', handleRemove);
|
|
36
36
|
if (appearanceSub && appearanceSub.remove) appearanceSub.remove();
|
|
37
37
|
};
|
|
38
|
-
}, []);
|
|
38
|
+
}, [forcedTheme]);
|
|
39
|
+
|
|
40
|
+
// Calculate safe top margin for status bar
|
|
41
|
+
const getTopMargin = () => {
|
|
42
|
+
if (Platform.OS === 'android') {
|
|
43
|
+
return StatusBar.currentHeight || 0;
|
|
44
|
+
}
|
|
45
|
+
// For iOS, use a default safe area top margin
|
|
46
|
+
return 44; // Standard iOS notch/status bar height
|
|
47
|
+
};
|
|
39
48
|
|
|
40
49
|
// Separate toasts by position
|
|
41
50
|
const topToasts = toasts.filter(toast => toast?.options?.position === 'top');
|
|
42
51
|
const centerToasts = toasts.filter(toast => toast?.options?.position === 'center');
|
|
43
52
|
const bottomToasts = toasts.filter(toast => toast?.options?.position === 'bottom');
|
|
44
53
|
|
|
54
|
+
const topMargin = getTopMargin();
|
|
55
|
+
|
|
45
56
|
return (
|
|
46
57
|
<>
|
|
47
58
|
{/* Top positioned toasts */}
|
|
48
|
-
<View
|
|
59
|
+
<View
|
|
60
|
+
style={[styles.topContainer, { top: topMargin + hp(1) }]}
|
|
61
|
+
pointerEvents="box-none"
|
|
62
|
+
>
|
|
49
63
|
{topToasts.map((toast, index) => (
|
|
50
64
|
<Toast
|
|
51
65
|
key={toast.id}
|
|
@@ -53,7 +67,7 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
|
|
|
53
67
|
duration={toast?.options?.duration}
|
|
54
68
|
position="top"
|
|
55
69
|
theme={theme}
|
|
56
|
-
style={[toast?.options?.style || {}, {
|
|
70
|
+
style={[toast?.options?.style || {}, { marginTop: index * (hp(7) + hp(1)) }]}
|
|
57
71
|
onHide={() => toastManagerInstance.remove(toast.id)}
|
|
58
72
|
>
|
|
59
73
|
{toast.content}
|
|
@@ -70,7 +84,7 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
|
|
|
70
84
|
duration={toast?.options?.duration}
|
|
71
85
|
position="center"
|
|
72
86
|
theme={theme}
|
|
73
|
-
style={[toast?.options?.style || {}, { marginTop: index *
|
|
87
|
+
style={[toast?.options?.style || {}, { marginTop: index * (hp(7) + hp(1)) }]}
|
|
74
88
|
onHide={() => toastManagerInstance.remove(toast.id)}
|
|
75
89
|
>
|
|
76
90
|
{toast.content}
|
|
@@ -87,7 +101,7 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
|
|
|
87
101
|
duration={toast?.options?.duration}
|
|
88
102
|
position="bottom"
|
|
89
103
|
theme={theme}
|
|
90
|
-
style={[toast?.options?.style || {}, { bottom: hp(2) + index *
|
|
104
|
+
style={[toast?.options?.style || {}, { bottom: hp(2) + index * (hp(7) + hp(1)) }]}
|
|
91
105
|
onHide={() => toastManagerInstance.remove(toast.id)}
|
|
92
106
|
>
|
|
93
107
|
{toast.content}
|
|
@@ -101,7 +115,6 @@ const ToastContainer = ({ theme: forcedTheme } = {}) => {
|
|
|
101
115
|
const styles = StyleSheet.create({
|
|
102
116
|
topContainer: {
|
|
103
117
|
position: 'absolute',
|
|
104
|
-
top: 0,
|
|
105
118
|
left: 0,
|
|
106
119
|
right: 0,
|
|
107
120
|
zIndex: 9999,
|
|
@@ -111,13 +124,12 @@ const styles = StyleSheet.create({
|
|
|
111
124
|
centerContainer: {
|
|
112
125
|
position: 'absolute',
|
|
113
126
|
top: '50%',
|
|
114
|
-
bottom: '50%',
|
|
115
127
|
left: 0,
|
|
116
128
|
right: 0,
|
|
117
129
|
zIndex: 9999,
|
|
118
130
|
pointerEvents: 'box-none',
|
|
119
131
|
alignItems: 'center',
|
|
120
|
-
transform: [{ translateY: -
|
|
132
|
+
transform: [{ translateY: -hp(3.5) }]
|
|
121
133
|
},
|
|
122
134
|
bottomContainer: {
|
|
123
135
|
position: 'absolute',
|
|
@@ -130,4 +142,4 @@ const styles = StyleSheet.create({
|
|
|
130
142
|
},
|
|
131
143
|
});
|
|
132
144
|
|
|
133
|
-
export default React.memo(ToastContainer);
|
|
145
|
+
export default React.memo(ToastContainer);
|