Skip to content

Commit 1393b14

Browse files
refactor: Update readme and UI fix on inbox header title
1 parent bc72380 commit 1393b14

File tree

8 files changed

+26
-54
lines changed

8 files changed

+26
-54
lines changed

README.md

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ theme | Object for custom themes | Theme | {} |
112112
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-
customCard | Function for rendering custom notification cards | (notification)=> JSX Element | null |
117-
onCardClick | Custom click handler for notification cards | (notification)=> void | ()=>null |
118-
listEmptyComponent | Custom component for empty notification list | JSX Element | 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 |
119119
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 |
@@ -171,9 +171,6 @@ Here are the custom style options for the notification inbox:
171171

172172
```js
173173
type CustomStyleProps = {
174-
notificationIcon?: {
175-
size?: number;
176-
};
177174
window?: {
178175
width?: DimensionValue;
179176
height?: DimensionValue;
@@ -194,18 +191,12 @@ Here are the custom style options for the notification inbox:
194191
avatarSize?: number;
195192
titleFontWeight?: TextStyle['fontWeight'];
196193
titleSize?: number;
197-
subTitleFontWeight?: TextStyle['fontWeight'];
198-
subTitleSize?: number
194+
subtitleFontWeight?: TextStyle['fontWeight'];
195+
subtitleSize?: number
199196
descriptionFontWeight?: TextStyle['fontWeight'];
200197
descriptionSize?: number;
201198
dateSize?: number;
202199
};
203-
badgeStyle?: {
204-
size?: number;
205-
textSize?: number;
206-
top?: number;
207-
right?: number;
208-
};
209200
deleteIcon?:{
210201
size?: number
211202
};
@@ -249,10 +240,10 @@ Here are the custom style options for the notification inbox:
249240
import { useSiren } from '@sirenapp/react-native-inbox';
250241

251242
function MyComponent() {
252-
const { markAsRead, deleteById } = useSiren();
243+
const { markAsReadById, deleteById } = useSiren();
253244

254245
function handleMarkAsRead(id) {
255-
markAsRead(id);
246+
markAsReadById(id);
256247
}
257248

258249
function handleDeleteNotification(id) {
@@ -269,32 +260,11 @@ function MyComponent() {
269260
Functions | Parameters | Type | Description |
270261
----------|------------|-------|------------|
271262
markAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
272-
markAsRead | id | string | Set read status of a notification to true |
263+
markAsReadById | id | string | Set read status of a notification to true |
273264
deleteById | id | string | Delete a notification by id |
274265
deleteByDate | startDate | ISO date string | Delete all notifications until given date |
275266
markAllAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
276267

277-
## 4. Error codes
278-
Given below are all possible error codes thrown by sdk:
279-
280-
Error code | Description |
281-
--- | --- |
282-
AUTHENTICATION_FAILED | Failed to authenticate given credentials |
283-
TOKEN_VERIFICATION_FAILED | Verification of the given tokens has failed |
284-
TOKEN_VERIFICATION_PENDING | Authentication in progress |
285-
API_ERROR | Occurrence of an unexpected api error |
286-
UNVIEWED_COUNT_FETCH_FAILED | Failed to fetch unviewed notifications count |
287-
NOTIFICATION_FETCH_FAILED | Failed to fetch notifications |
288-
DELETE_FAILED | Failed to delete notification |
289-
MARK_AS_READ_FAILED | Failed to mark notification as read |
290-
BULK_DELETE_FAILED | Bulk deletion of notifications failed |
291-
MARK_ALL_AS_READ_FAILED | Failed to mark all notifications as read |
292-
MARK_ALL_AS_VIEWED_FAILED | Failed to mark notification as viewed |
293-
OUTSIDE_SIREN_CONTEXT | Attempting to invoke the functions outside the siren inbox context |
294-
MISSING_PARAMETER | The required parameter is missing |
295-
UNAUTHORIZED_OPERATION | This operation require valid credentials |
296-
INVALID_ERROR_FUNCTION | The error function passed to sdk is invalid |
297-
298268
## Example
299269
Here's a basic example to help you get started
300270
```js

src/components/card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const Card = (props: NotificationCardProps): ReactElement => {
4949
onAvatarClick,
5050
deleteIcon = null
5151
} = cardProps;
52-
const { markAsRead } = useSiren();
52+
const { markAsReadById } = useSiren();
5353

5454
const opacity = useRef(new Animated.Value(1)).current;
5555

@@ -73,7 +73,7 @@ const Card = (props: NotificationCardProps): ReactElement => {
7373

7474
const cardClick = (): void => {
7575
onCardClick(notification);
76-
if (!disableAutoMarkAsRead) markAsRead(notification.id);
76+
if (!disableAutoMarkAsRead) markAsReadById(notification.id);
7777
};
7878

7979
const onError = (): void => {

src/components/header.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ const style = StyleSheet.create({
9696
paddingRight: 18
9797
},
9898
clearIconContainer: {
99+
width: '20%',
99100
flexDirection: 'row',
100101
alignItems: 'center',
101102
justifyContent: 'center'
102103
},
103104
headerTitle: {
104-
width: '70%'
105+
width: '95%',
105106
},
106107
rowContainer: {
108+
width: '80%',
107109
flexDirection: 'row',
108110
alignItems: 'center'
109111
},

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ export type CustomStyleProps = {
167167
avatarSize?: number;
168168
titleFontWeight?: TextStyle['fontWeight'];
169169
titleSize?: number;
170-
subTitleFontWeight?: TextStyle['fontWeight'];
171-
subTitleSize?: number
170+
subtitleFontWeight?: TextStyle['fontWeight'];
171+
subtitleSize?: number
172172
descriptionFontWeight?: TextStyle['fontWeight'];
173173
descriptionSize?: number;
174174
dateSize?: number;

src/utils/commonUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ export const applyTheme = (
223223
theme.colors?.textColor ||
224224
DefaultTheme[mode].notificationCard.subTitleColor,
225225
fontSize:
226-
customStyles.notificationCard?.subTitleSize || defaultStyles.notificationCard.subTitleSize,
226+
customStyles.notificationCard?.subtitleSize || defaultStyles.notificationCard.subtitleSize,
227227
fontWeight:
228-
customStyles.notificationCard?.subTitleFontWeight ||
229-
defaultStyles.notificationCard.subTitleFontWeight,
228+
customStyles.notificationCard?.subtitleFontWeight ||
229+
defaultStyles.notificationCard.subtitleFontWeight,
230230
lineHeight:
231-
(customStyles.notificationCard?.subTitleSize || defaultStyles.notificationCard.subTitleSize) +
231+
(customStyles.notificationCard?.subtitleSize || defaultStyles.notificationCard.subtitleSize) +
232232
8
233233
},
234234
cardDescription: {

src/utils/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ export const defaultStyles = {
124124
avatarSize: 40,
125125
titleFontWeight: '600',
126126
titleSize: 14,
127-
subTitleFontWeight: '500',
128-
subTitleSize: 14,
127+
subtitleFontWeight: '500',
128+
subtitleSize: 14,
129129
descriptionSize: 14,
130130
descriptionFontWeight: '400',
131131
dateSize: 12

src/utils/sirenHook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useSirenContext } from '../components/sirenProvider';
66
const useSiren = () => {
77
const { siren } = useSirenContext();
88

9-
const markAsRead = async (id: string) => {
9+
const markAsReadById = async (id: string) => {
1010
if (siren)
1111
if (id?.length > 0) {
1212
const response = await siren?.markNotificationAsReadById(id);
@@ -94,7 +94,7 @@ const useSiren = () => {
9494

9595
return {
9696
markAsReadByDate,
97-
markAsRead,
97+
markAsReadById,
9898
deleteById,
9999
deleteByDate,
100100
markAllAsViewed

tests/utils/sirenHook.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ describe('useSiren hook', () => {
9595
verificationStatus: VerificationStatus.SUCCESS
9696
});
9797

98-
const { markAsRead } = useSiren();
99-
const response = await markAsRead('xyz');
98+
const { markAsReadById } = useSiren();
99+
const response = await markAsReadById('xyz');
100100

101101
expect(mockSiren.markNotificationAsReadById).toHaveBeenCalledWith('xyz');
102102
expect(response).toEqual(Response);

0 commit comments

Comments
 (0)