Skip to content

Commit 274cd0c

Browse files
authored
Merge pull request #9 from seniv/dev
Dev to Master
2 parents d8cf054 + bb3c0d8 commit 274cd0c

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![npm](https://img.shields.io/npm/v/react-native-notifier)](https://www.npmjs.com/package/react-native-notifier)
44
[![npm bundle size](https://img.shields.io/bundlephobia/min/react-native-notifier)](https://bundlephobia.com/result?p=react-native-notifier)
5+
![platforms: ios, android, web](https://img.shields.io/badge/platform-ios%2C%20android%2C%20web-blue)
56
[![license MIT](https://img.shields.io/badge/license-MIT-brightgreen)](https://github.com/seniv/react-native-notifier/blob/master/LICENSE)
67

78
Fast and simple in-app notifications for React Native
@@ -162,7 +163,7 @@ Name | Type | Default | Description
162163
title | String | null | Title of notification.
163164
description | String | null | Description of notification.
164165
componentProps.imageSource | Object | null | Passed to `<Image />` as `source` param.
165-
componentProps.ContainerComponent | Object | SafeAreaView | A container of the component. Set it in case you use different SafeAreaView than the standard
166+
componentProps.ContainerComponent | Component| SafeAreaView | A container of the component. Set it in case you use different SafeAreaView than the standard
166167
167168
### `NotifierComponents.Alert`
168169
@@ -190,7 +191,7 @@ description | String | null | Description of not
190191
componentProps.alertType | String | 'success' | Background color will be changed depending on the type. Available values: `error`(red), `success`(green), `warn`(orange) and `info`(blue).
191192
componentProps.backgroundColor | String | null | While the background of the alert depends on `alertType`, you can also set the other color you want.
192193
componentProps.textColor | String | 'white' | Color of `title` and `description`.
193-
componentProps.ContainerComponent | Object | SafeAreaView | A container of the component. Set it in case you use different SafeAreaView than the standard
194+
componentProps.ContainerComponent | Component| SafeAreaView | A container of the component. Set it in case you use different SafeAreaView than the standard
194195
195196
## Custom Component
196197

src/Notifier.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from './constants';
2020
import {
2121
ShowParams,
22-
ShowNotification,
22+
ShowNotificationParams,
2323
StateInterface,
2424
EndCallback,
2525
NotifierInterface,
@@ -30,17 +30,17 @@ export const Notifier: NotifierInterface = {
3030
hideNotification: () => {},
3131
};
3232

33-
export class NotifierRoot extends React.PureComponent<ShowNotification, StateInterface> {
33+
export class NotifierRoot extends React.PureComponent<ShowNotificationParams, StateInterface> {
3434
private isShown: boolean;
3535
private isHiding: boolean;
3636
private hideTimer: any;
3737
private showParams: ShowParams | null;
38-
private callStack: Array<ShowNotification>;
38+
private callStack: Array<ShowNotificationParams>;
3939
private readonly translateY: Animated.Value;
4040
private readonly translateYInterpolated: Animated.AnimatedInterpolation;
4141
private readonly onGestureEvent: (...args: any[]) => void;
4242

43-
constructor(props: ShowNotification) {
43+
constructor(props: ShowNotificationParams) {
4444
super(props);
4545

4646
this.state = {
@@ -104,8 +104,12 @@ export class NotifierRoot extends React.PureComponent<ShowNotification, StateInt
104104
this.onStartHiding();
105105
}
106106

107-
public showNotification(functionParams: ShowNotification) {
108-
const params = { ...this.props, ...functionParams };
107+
public showNotification(functionParams: ShowNotificationParams) {
108+
const params = {
109+
...this.props,
110+
...functionParams,
111+
componentProps: { ...this.props?.componentProps, ...functionParams?.componentProps },
112+
};
109113

110114
if (this.isShown) {
111115
switch (params.queueMode) {
@@ -139,13 +143,13 @@ export class NotifierRoot extends React.PureComponent<ShowNotification, StateInt
139143
Component,
140144
componentProps,
141145
...restParams
142-
} = params ?? {};
146+
} = params;
143147
this.setState({
144148
title,
145149
description,
146150
Component: Component ?? NotificationComponent,
147151
swipeEnabled: swipeEnabled ?? DEFAULT_SWIPE_ENABLED,
148-
componentProps: componentProps ?? {},
152+
componentProps: componentProps,
149153
});
150154
this.showParams = restParams;
151155
if (duration && !isNaN(duration)) {
@@ -226,11 +230,7 @@ export class NotifierRoot extends React.PureComponent<ShowNotification, StateInt
226230
style={[
227231
s.container,
228232
{
229-
transform: [
230-
{
231-
translateY: this.translateYInterpolated,
232-
},
233-
],
233+
transform: [{ translateY: this.translateYInterpolated }],
234234
},
235235
]}
236236
>

src/NotifierWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import { NotifierRoot } from './Notifier';
3-
import { ShowNotification } from './types';
3+
import { ShowNotificationParams } from './types';
44

5-
interface NotifierWrapperProps extends ShowNotification {
5+
interface NotifierWrapperProps extends ShowNotificationParams {
66
children: React.ReactNode;
77
}
88

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type QueueMode = 'immediate' | 'next' | 'standby' | 'reset';
2424

2525
type ComponentProps = NotificationComponentProps | AlertComponentProps | object;
2626

27-
export interface ShowNotification extends ShowParams {
27+
export interface ShowNotificationParams extends ShowParams {
2828
title?: string; // null
2929
description?: string; // null
3030
swipeEnabled?: boolean; // true
@@ -46,6 +46,6 @@ export type EndResult = { finished: boolean };
4646
export type EndCallback = (result: EndResult) => void;
4747

4848
export interface NotifierInterface {
49-
showNotification: (params: ShowNotification) => void;
49+
showNotification: (params: ShowNotificationParams) => void;
5050
hideNotification: (onHidden?: EndCallback) => void;
5151
}

0 commit comments

Comments
 (0)