Skip to content

Commit 8b7bb48

Browse files
refactor:Update notification icon, readme, sdk props
1 parent e65d6af commit 8b7bb48

27 files changed

+362
-205
lines changed

README.md

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const config = {
5858

5959

6060
```
61-
The config is a prop for the SirenProvider component is authenticate and initialize sdk.
61+
The config is a property containing userToken and recipientId for authenticate and initialize sdk.
6262

6363
```js
6464
type config = {
@@ -95,6 +95,7 @@ darkMode | Flag to enable dark mode | boolean | false |
9595
onError | Callback for handling errors | (error: SirenErrorType)=> void | null |
9696
onPress | Function for handling press of icon | ()=> void | null |
9797
disabled | Flag to disable click handler of icon | boolean | false |
98+
hideBadge | Flag to hide unread notification count badge | boolean | false |
9899

99100
#### Theming options
100101
Customize the unread badge of the notification icon, and choose between dark and light theming options.
@@ -124,14 +125,16 @@ Customize the notification icon style properties includes size of icon, badge, e
124125
};
125126
badgeStyle?: {
126127
size?: number;
127-
textSize?: number;
128+
textSize?: number;
129+
top?: number;
130+
right?: number;
128131
};
129132
}
130133
```
131134

132135
### 4. Siren Inbox
133136

134-
SirenNotificationWindow is a paginated list view for displaying notifications.
137+
SirenNotificationInbox is a paginated list view for displaying notifications.
135138

136139
```js
137140
import { SirenInbox } from '@siren/react-native-inbox';
@@ -145,27 +148,42 @@ import { SirenInbox } from '@siren/react-native-inbox';
145148
/>
146149

147150
```
148-
#### Siren Notification Window Props
149-
Given below are all props of window component.
151+
#### Siren Notification Inbox Props
152+
Given below are all props of inbox component.
150153

151154
Prop | Description | Type | Default value |
152155
--- | --- | --- | --- |
153-
theme | Theme object for custom styling | Theme | {} |
154-
title | Title of the notification window | string | "Notifications" |
156+
theme | Theme object for custom color theme | Theme | {} |
157+
customStyles | Style object for custom styling | StyleProps | {} |
158+
title | Title of the notification inbox | string | "Notifications" |
155159
hideHeader | Flag to hide or show the header | boolean | false |
156160
hideClearAll | Flag to hide or show the clear all button in header | boolean | false |
157161
darkMode | Flag to enable dark mode | boolean | false |
162+
itemsPerFetch | Number of notifications fetch per api request (have a max cap of 50) | number | 20 |
158163
cardProps | Props for customizing the notification cards | CardProps | null |
159164
customNotificationCard | Custom function for rendering notification cards | (notification)=> JSX Element | null |
160165
onNotificationCardClick | Props for customizing the notification cards | (notification)=> void | ()=>null |
161166
listEmptyComponent | Custom component to display when the notification list is empty | JSX Element | null |
162167
customHeader | Custom header component | JSX Element | null |
163168
customFooter | Custom footer component | JSX Element | null |
169+
customLoader | Custom loader component | JSX Element | null |
170+
customErrorWindow | Custom error component | JSX Element | null |
164171
onError | Callback for handling errors | (error: SirenErrorType)=> void | null |
165172

173+
#### Card props
174+
175+
Style object for customize notification card.
176+
177+
```js
178+
type CardProps = {
179+
hideAvatar?: boolean;
180+
showMedia?: boolean;
181+
};
182+
```
183+
166184
#### Theming options
167185

168-
Customizable UI option for notification window, with dark and light theme options.
186+
Customizable UI option for notification inbox, with dark and light theme options.
169187

170188
```js
171189
type Theme = {
@@ -184,6 +202,7 @@ Customizable UI option for notification window, with dark and light theme option
184202
deleteIcon?: string;
185203
timerIcon?: string;
186204
clearAllIcon?: string;
205+
infiniteLoader?: string;
187206
};
188207
windowHeader?: {
189208
background?: string;
@@ -205,9 +224,9 @@ Customizable UI option for notification window, with dark and light theme option
205224
}
206225
```
207226

208-
#### Theming options
227+
#### Styling options
209228

210-
Customizable Styling option for notification window.
229+
Customizable Styling option for notification inbox.
211230

212231
```js
213232
export type StyleProps = {
@@ -223,7 +242,6 @@ Customizable Styling option for notification window.
223242
titleFontWeight?: TextStyle['fontWeight'];
224243
titleSize?: number;
225244
closeIconSize?: number;
226-
titlePadding?: number;
227245
}
228246
windowContainer?: {
229247
padding?: number;
@@ -234,14 +252,23 @@ Customizable Styling option for notification window.
234252
avatarSize?: number;
235253
titleFontWeight?: TextStyle['fontWeight'];
236254
titleSize?: number;
237-
titlePadding?: number;
238255
descriptionSize?: number;
239-
descriptionPadding?: number;
240256
dateSize?: number;
241257
};
242258
badgeStyle?: {
243259
size?: number;
244260
textSize?: number;
261+
top?: number;
262+
right?: number;
263+
};
264+
deleteIcon?:{
265+
size?: number
266+
};
267+
dateIcon?:{
268+
size?: number
269+
};
270+
clearAllIcon?:{
271+
size?: number
245272
};
246273
};
247274
```
@@ -288,7 +315,7 @@ INVALID_RECIPIENT_ID | Invalid recipient id | Recipient id in provider is invali
288315
TOKEN_VERIFICATION_FAILED | This operation requires a valid token | Failed to verify token and initialize sdk |
289316
INVALID_ERROR_FUNCTION | Invalid error function | Error function is invalid |
290317
GENERIC_API_ERROR | Api error | Failed to call a internal api |
291-
SIREN_OBJECT_NOT_FOUND | Siren Object Not found | Was failed to initialize sdk, Siren object not created |
318+
OUTSIDE_SIREN_CONTEXT | Siren Object Not found | Was failed to initialize sdk, Siren object not created |
292319
MISSING_PARAMETER | Missing Parameter | A parameter is missing in function call |
293320

294321
### Complete Code Example

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@
7878
],
7979
"dependencies": {
8080
"pubsub-js": "^1.9.4",
81-
"test_notification": "^1.0.10"
81+
"test_notification": "^1.0.20"
8282
}
8383
}

src/assets/bellDark.png

7.44 KB
Loading

src/assets/bellLight.png

9.45 KB
Loading

src/assets/emptyDark.png

11.7 KB
Loading

src/assets/emptyLight.png

11.4 KB
Loading

src/assets/notificationIcon.png

-1.18 KB
Binary file not shown.

src/components/card.tsx

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { type ReactElement } from 'react';
1+
import React, { useState, type ReactElement } from 'react';
22
import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
33

44
import type { NotificationDataType } from 'test_notification/dist/esm/types';
@@ -41,27 +41,34 @@ import TimerIcon from './timerIcon';
4141
* @param {Function} props.onDelete - Callback function executed when the delete action is triggered.
4242
*/
4343

44-
const renderAvatar = (
45-
notification: NotificationDataType,
46-
styles: Partial<SirenStyleProps>
47-
): JSX.Element => {
48-
return (
49-
<View style={style.cardIconContainer}>
50-
<View style={[style.cardIconRound, styles.cardIconRound]}>
51-
{Boolean(notification?.message?.avatar?.imageUrl) && (
44+
const Card = (props: NotificationCardProps): ReactElement => {
45+
const { onCardClick, notification, cardProps, styles, onDelete, darkMode } = props;
46+
const emptyState = darkMode
47+
? require('../assets/emptyDark.png')
48+
: require('../assets/emptyLight.png');
49+
const [imageSource, setImageSource] = useState(
50+
notification?.message?.avatar?.imageUrl?.length > 0
51+
? { uri: notification.message?.avatar?.imageUrl }
52+
: emptyState
53+
);
54+
55+
const renderAvatar = (
56+
notification: NotificationDataType,
57+
styles: Partial<SirenStyleProps>
58+
): JSX.Element => {
59+
return (
60+
<View style={style.cardIconContainer}>
61+
<View style={[style.cardIconRound, styles.cardIconRound]}>
5262
<Image
53-
source={{ uri: notification.message?.avatar?.imageUrl }}
63+
source={imageSource}
5464
resizeMode='cover'
5565
style={style.cardAvatarStyle}
66+
onError={() => setImageSource(emptyState)}
5667
/>
57-
)}
68+
</View>
5869
</View>
59-
</View>
60-
);
61-
};
62-
63-
const Card = (props: NotificationCardProps): ReactElement => {
64-
const { onCardClick, notification, cardProps, styles, onDelete } = props;
70+
);
71+
};
6572

6673
return (
6774
<TouchableOpacity
@@ -81,17 +88,17 @@ const Card = (props: NotificationCardProps): ReactElement => {
8188
{!cardProps?.hideAvatar && renderAvatar(notification, styles)}
8289
<View style={style.cardContentContainer}>
8390
<View style={style.cardFooterRow}>
84-
<Text numberOfLines={1} style={[styles.cardTitle, style.cardTitle]}>
91+
<Text numberOfLines={2} style={[styles.cardTitle, style.cardTitle]}>
8592
{notification.message?.header}
8693
</Text>
8794
<CloseIcon onDelete={onDelete} notification={notification} styles={styles} />
8895
</View>
8996
{Boolean(notification.message?.subHeader) && (
90-
<Text numberOfLines={1} style={[style.cardDescription, styles.cardDescription]}>
97+
<Text numberOfLines={2} style={[style.cardDescription, styles.cardDescription]}>
9198
{notification.message?.subHeader}
9299
</Text>
93100
)}
94-
<Text numberOfLines={3} style={[style.cardDescription, styles.cardDescription]}>
101+
<Text numberOfLines={2} style={[style.cardDescription, styles.cardDescription]}>
95102
{notification.message?.body}
96103
</Text>
97104
<View style={style.dateContainer}>
@@ -122,7 +129,8 @@ const style = StyleSheet.create({
122129
paddingTop: 4
123130
},
124131
cardTitle: {
125-
paddingBottom: 4
132+
paddingBottom: 4,
133+
paddingTop: 4
126134
},
127135
icon: {
128136
width: '100%',

src/components/clearIcon.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@ const ClearIcon = ({ styles }: { styles: Partial<SirenStyleProps> }): ReactEleme
88

99
for (let i = 0; i < 3; i++)
1010
icon.push(
11-
<View key={i} style={[style.clearIcon, styles.clearIcon, { marginLeft: (3 - i) * 2 }]} />
11+
<View key={i} style={[style.clearIcon, styles.clearIcon, { marginLeft: (2 - i) * 5 }]} />
1212
);
1313

14-
return <View>{icon}</View>;
14+
return <View style={[style.clearIconContainer, styles.clearIconContainer]}>{icon}</View>;
1515
};
1616

1717
const style = StyleSheet.create({
1818
clearIcon: {
19-
height: 2,
20-
width: 14,
21-
borderRadius: 1.2,
22-
marginTop: 1.5,
23-
marginBottom: 0.5,
24-
marginRight: 5
19+
width: '100%'
2520
},
21+
clearIconContainer: {
22+
justifyContent: 'center',
23+
alignItems: 'center'
24+
}
2625
});
2726

2827
export default ClearIcon;

0 commit comments

Comments
 (0)