Skip to content

Commit 3acabd5

Browse files
Merge pull request #57 from KeyValueSoftwareSystems/dev
Merge Dev to staging
2 parents 3a84a84 + 91d44ff commit 3acabd5

28 files changed

+333
-210
lines changed

README.md

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Below are optional props available for the icon component:
5151
Prop | Description | Type | Default value |
5252
--- | --- | --- | --- |
5353
theme | Object for custom themes | Theme | {} |
54-
customStyles | Object for custom styling | StyleProps | {} |
54+
customStyles | Object for custom styling | CustomStyleProps | {} |
5555
notificationIcon | Option to use custom notification icon | JSX Element | null |
5656
darkMode | Toggle to enable dark mode | boolean | false |
5757
onError | Callback for handling errors | (error: SirenErrorType)=> void | null |
@@ -80,7 +80,7 @@ Here are the available theme options:
8080
Here are the custom style options for the notification icon:
8181
```js
8282

83-
type StyleProps = {
83+
type CustomStyleProps = {
8484
notificationIcon?: {
8585
size?: number,
8686
};
@@ -109,14 +109,14 @@ Below are optional props available for the inbox component:
109109
Prop | Description | Type | Default value |
110110
--- | --- | --- | --- |
111111
theme | Object for custom themes | Theme | {} |
112-
customStyles | Object for custom styling | StyleProps | {} |
112+
customStyles | Object for custom styling | CustomStyleProps | {} |
113113
darkMode | Toggle to enable dark mode| boolean | false |
114114
itemsPerFetch | Number of notifications fetch per api request (have a max cap of 50) | number | 20 |
115-
cardProps | Props for customizing the notification cards | CardProps | { hideAvatar: false, disableAutoMarkAsRead: false, hideDelete: false } |
116-
customNotificationCard | Function for rendering custom notification cards | (notification)=> JSX Element | null |
117-
onNotificationCardClick | Custom click handler for notification cards | (notification)=> void | ()=>null |
118-
listEmptyComponent | Custom component for empty notification list | JSX Element | null |
119-
inboxHeaderProps | Props for customizing the header | InboxHeaderProps | { title: "Notifications", hideHeader: false, hideClearAll: false, customHeader: null, showBackButton:false, backButton: null, onBackPress: ()=> null } |
115+
cardProps | Props for customizing the card | CardProps | { hideAvatar: false, disableAutoMarkAsRead: false, hideDelete: false, deleteIcon: JSX.Element, onAvatarClick: ()=> null } |
116+
customCard | Function for rendering custom card | (notification)=> JSX Element | null |
117+
onCardClick | Custom click handler for card | (notification)=> void | ()=>null |
118+
listEmptyComponent | Custom component for empty list | JSX Element | null |
119+
headerProps | Props for customizing the header | HeaderProps | { title: "Notifications", hideHeader: false, hideClearAll: false, customHeader: null, showBackButton:false, backButton: null, onBackPress: ()=> null } |
120120
customFooter | Custom footer component | JSX Element | null |
121121
customLoader | Custom component to display the initial loading state| JSX Element | null |
122122
customErrorWindow | Custom error window | JSX Element | null |
@@ -151,7 +151,6 @@ Here are the available theme options:
151151
titleColor?: string;
152152
headerActionColor?: string;
153153
borderColor?: string;
154-
borderWidth?: string;
155154
};
156155
windowContainer?: {
157156
background?: string;
@@ -160,8 +159,8 @@ Here are the available theme options:
160159
borderColor?: string;
161160
background?: string;
162161
titleColor?: string;
162+
subTitleColor?: string;
163163
descriptionColor?: string;
164-
dateColor?: string;
165164
};
166165
}
167166
```
@@ -171,10 +170,7 @@ Here are the available theme options:
171170
Here are the custom style options for the notification inbox:
172171

173172
```js
174-
type StyleProps = {
175-
notificationIcon?: {
176-
size?: number;
177-
};
173+
type CustomStyleProps = {
178174
window?: {
179175
width?: DimensionValue;
180176
height?: DimensionValue;
@@ -183,6 +179,8 @@ Here are the custom style options for the notification inbox:
183179
height?: number;
184180
titleFontWeight?: TextStyle['fontWeight'];
185181
titleSize?: number;
182+
borderWidth?: string;
183+
titlePadding?: number;
186184
}
187185
windowContainer?: {
188186
padding?: number;
@@ -193,15 +191,12 @@ Here are the custom style options for the notification inbox:
193191
avatarSize?: number;
194192
titleFontWeight?: TextStyle['fontWeight'];
195193
titleSize?: number;
194+
subtitleFontWeight?: TextStyle['fontWeight'];
195+
subtitleSize?: number
196+
descriptionFontWeight?: TextStyle['fontWeight'];
196197
descriptionSize?: number;
197198
dateSize?: number;
198199
};
199-
badgeStyle?: {
200-
size?: number;
201-
textSize?: number;
202-
top?: number;
203-
right?: number;
204-
};
205200
deleteIcon?:{
206201
size?: number
207202
};
@@ -217,14 +212,16 @@ Here are the custom style options for the notification inbox:
217212
```js
218213
type CardProps = {
219214
hideAvatar?: boolean;
215+
onAvatarClick?: (notification: NotificationDataType) => void;
220216
disableAutoMarkAsRead?: boolean;
217+
deleteIcon?: JSX.Element;
221218
hideDelete?: boolean;
222219
};
223220
```
224221

225-
#### InboxHeaderProps
222+
#### HeaderProps
226223
```js
227-
type InboxHeaderProps = {
224+
type HeaderProps = {
228225
title?: string;
229226
hideHeader?: boolean;
230227
hideClearAll?: boolean;
@@ -243,14 +240,14 @@ Here are the custom style options for the notification inbox:
243240
import { useSiren } from '@sirenapp/react-native-inbox';
244241

245242
function MyComponent() {
246-
const { markAsRead, deleteNotification } = useSiren();
243+
const { markAsReadById, deleteById } = useSiren();
247244

248245
function handleMarkAsRead(id) {
249-
markAsRead(id);
246+
markAsReadById(id);
250247
}
251248

252249
function handleDeleteNotification(id) {
253-
deleteNotification(id);
250+
deleteById(id);
254251
}
255252

256253
return (
@@ -262,23 +259,11 @@ function MyComponent() {
262259

263260
Functions | Parameters | Type | Description |
264261
----------|------------|-------|------------|
265-
markNotificationsAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
266-
markAsRead | id | string | Set read status of a notification to true |
267-
deleteNotification | id | string | Delete a notification by id |
268-
deleteNotificationsByDate | startDate | ISO date string | Delete all notifications until given date |
269-
markNotificationsAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
270-
271-
## 4. Error codes
272-
Given below are all possible error codes thrown by sdk:
273-
274-
Error code | Description |
275-
--- | --- |
276-
INVALID_TOKEN | The token passed in the provider is invalid |
277-
INVALID_RECIPIENT_ID | The recipient id passed in the provider is invalid |
278-
TOKEN_VERIFICATION_FAILED | Verification of the given tokens has failed |
279-
GENERIC_API_ERROR | Occurrence of an unexpected api error |
280-
OUTSIDE_SIREN_CONTEXT | Attempting to invoke the functions outside the siren inbox context |
281-
MISSING_PARAMETER | The required parameter is missing |
262+
markAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
263+
markAsReadById | id | string | Set read status of a notification to true |
264+
deleteById | id | string | Delete a notification by id |
265+
deleteByDate | startDate | ISO date string | Delete all notifications until given date |
266+
markAllAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
282267

283268
## Example
284269
Here's a basic example to help you get started
@@ -312,7 +297,6 @@ function MyContainer(): React.JSX.Element {
312297
darkMode={false}
313298
/>
314299
<SirenInbox
315-
title="Notifications"
316300
hideHeader={false}
317301
darkMode={false}
318302
cardProps={{hideAvatar: false, disableAutoMarkAsRead: false}}

example/screens/notifications.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function Notifications(): React.JSX.Element {
5252
backgroundColor: isDarkMode ? '#000' : '#FFF'
5353
};
5454

55-
const { markNotificationsAsReadByDate } = useSiren();
55+
const { markAsReadByDate } = useSiren();
5656

5757
const renderListEmpty = () => {
5858
return (
@@ -76,7 +76,9 @@ function Notifications(): React.JSX.Element {
7676
<TouchableOpacity onPress={() => navigation.goBack()}>
7777
<Text style={styles.whiteLabel}>Back</Text>
7878
</TouchableOpacity>
79-
<TouchableOpacity onPress={() => markNotificationsAsReadByDate(String(new Date().getTime()))}>
79+
<TouchableOpacity
80+
onPress={() => markAsReadByDate(String(new Date().getTime()))}
81+
>
8082
<Text style={styles.whiteLabel}>Mark allAsRead</Text>
8183
</TouchableOpacity>
8284
</View>
@@ -108,12 +110,9 @@ function Notifications(): React.JSX.Element {
108110
</View>
109111
{showTestingWindow && (
110112
<View style={styles.testingWindowInnerContainer}>
111-
{renderButton(
112-
`${showNetwork ? 'Hide' : 'Show'} network`,
113-
() => {
114-
setShowNetwork((showNetwork) => !showNetwork);
115-
}
116-
)}
113+
{renderButton(`${showNetwork ? 'Hide' : 'Show'} network`, () => {
114+
setShowNetwork((showNetwork) => !showNetwork);
115+
})}
117116
{renderButton('Theme-Mode', () =>
118117
setSdkDarkModeEnabled((sdkDarkModeEnabled) => !sdkDarkModeEnabled)
119118
)}
@@ -163,29 +162,34 @@ function Notifications(): React.JSX.Element {
163162
/>
164163
<View style={styles.contentContainer}>
165164
<SirenInbox
166-
title='Siren Notifications'
167-
inboxHeaderProps={{
165+
headerProps={{
168166
hideHeader: hideHeader,
169167
customHeader: showCustomHeader ? renderCustomHeader() : undefined,
170168
showBackButton: true,
171169
onBackPress: () => navigation.goBack(),
170+
title: 'Siren Inbox'
172171
}}
173172
darkMode={sdkDarkModeEnabled}
174-
cardProps={{ hideAvatar: hideAvatar, disableAutoMarkAsRead: false }}
173+
cardProps={{
174+
hideAvatar: hideAvatar,
175+
disableAutoMarkAsRead: false,
176+
onAvatarClick: (notification: NotificationDataType) =>
177+
console.log('avatar click', notification)
178+
}}
175179
theme={windowThemes[windowThemeIndex]}
176180
customFooter={showCustomFooter ? renderCustomFooter() : undefined}
177181
listEmptyComponent={showCustomEmptyComponent ? renderListEmpty() : undefined}
178182
customStyles={{
179183
notificationCard: {
180-
avatarSize: 30,
184+
avatarSize: 30
181185
}
182186
}}
183-
customNotificationCard={
187+
customCard={
184188
showCustomNotificationCard
185189
? (notification: NotificationDataType) => renderCustomNotificationCard(notification)
186190
: undefined
187191
}
188-
onNotificationCardClick={(notification: NotificationDataType) => {
192+
onCardClick={(notification: NotificationDataType) => {
189193
console.log('click on notification');
190194
}}
191195
onError={(error: SirenErrorType) => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"source": "src",
6868
"output": "dist",
6969
"targets": [
70-
"module",
70+
["module", { "sourceMaps": false }],
7171
"typescript"
7272
]
7373
},

src/assets/closeIcon.png

-705 Bytes
Binary file not shown.

src/components/backIcon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { type ReactElement } from 'react';
22
import { StyleSheet, View } from 'react-native';
33

4-
import type { SirenStyleProps } from '../types';
4+
import type { StyleProps } from '../types';
55

6-
const BackIcon = ({ styles }: { styles: Partial<SirenStyleProps> }): ReactElement => {
6+
const BackIcon = ({ styles }: { styles: Partial<StyleProps> }): ReactElement => {
77
return (
88
<View style={style.backIconContainer}>
99
<View style={[style.backIconLine1, styles.backIcon]} />

0 commit comments

Comments
 (0)