Skip to content

Commit cb1f952

Browse files
[Version 1.1.0] Merge pull request #64 from KeyValueSoftwareSystems/staging
2 parents 2e9d0a6 + 63f762e commit cb1f952

36 files changed

+813
-421
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [1.0.0] - 2024-03-26
5+
## 1.1.0
6+
7+
### Added
8+
- Added support for custom delete icon and a flag to toggle the visibility of the delete icon.
9+
- Added functionality to display thumbnail URL previews for media content.
10+
- Exposed avatar click property.
11+
- Implemented specific error code mapping.
12+
- Enhanced style and theme customizations.
13+
14+
## 1.0.0
615

716
### Added
817

README.md

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ The `@sirenapp/react-native-inbox` sdk is a comprehensive and customizable React
99
You can install the react sdk from npm
1010

1111
```bash
12-
npm @sirenapp/react-native-inbox
12+
npm install @sirenapp/react-native-inbox
1313
```
1414
or from yarn
1515

1616
```bash
17-
yarn @sirenapp/react-native-inbox
17+
yarn add @sirenapp/react-native-inbox
1818
```
1919

2020
## 2. Configuration
@@ -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,17 +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 | {} |
113-
title | Title of the notification inbox | string | "Notifications" |
114-
hideHeader | Toggle to hide or show the header section | boolean | false |
115-
hideClearAll | Toggle to hide or show the clear all button | boolean | false |
112+
customStyles | Object for custom styling | CustomStyleProps | {} |
116113
darkMode | Toggle to enable dark mode| boolean | false |
117114
itemsPerFetch | Number of notifications fetch per api request (have a max cap of 50) | number | 20 |
118-
cardProps | Props for customizing the notification cards | { hideAvatar: boolean } | { hideAvatar: false } |
119-
customNotificationCard | Function for rendering custom notification cards | (notification)=> JSX Element | null |
120-
onNotificationCardClick | Custom click handler for notification cards | (notification)=> void | ()=>null |
121-
listEmptyComponent | Custom component for empty notification list | JSX Element | null |
122-
customHeader | Custom header component | JSX Element | null |
115+
cardProps | Props for customizing the card | CardProps | { hideAvatar: false, disableAutoMarkAsRead: false, hideDelete: false, deleteIcon: JSX.Element, onAvatarClick: ()=> null, hideMediaThumbnailL: false, onMediaThumbnailClick: ()=> 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 } |
123120
customFooter | Custom footer component | JSX Element | null |
124121
customLoader | Custom component to display the initial loading state| JSX Element | null |
125122
customErrorWindow | Custom error window | JSX Element | null |
@@ -154,7 +151,6 @@ Here are the available theme options:
154151
titleColor?: string;
155152
headerActionColor?: string;
156153
borderColor?: string;
157-
borderWidth?: string;
158154
};
159155
windowContainer?: {
160156
background?: string;
@@ -163,8 +159,8 @@ Here are the available theme options:
163159
borderColor?: string;
164160
background?: string;
165161
titleColor?: string;
162+
subTitleColor?: string;
166163
descriptionColor?: string;
167-
dateColor?: string;
168164
};
169165
}
170166
```
@@ -174,10 +170,7 @@ Here are the available theme options:
174170
Here are the custom style options for the notification inbox:
175171

176172
```js
177-
export type StyleProps = {
178-
notificationIcon?: {
179-
size?: number;
180-
};
173+
type CustomStyleProps = {
181174
window?: {
182175
width?: DimensionValue;
183176
height?: DimensionValue;
@@ -186,6 +179,8 @@ Here are the custom style options for the notification inbox:
186179
height?: number;
187180
titleFontWeight?: TextStyle['fontWeight'];
188181
titleSize?: number;
182+
borderWidth?: string;
183+
titlePadding?: number;
189184
}
190185
windowContainer?: {
191186
padding?: number;
@@ -196,26 +191,48 @@ Here are the custom style options for the notification inbox:
196191
avatarSize?: number;
197192
titleFontWeight?: TextStyle['fontWeight'];
198193
titleSize?: number;
194+
subtitleFontWeight?: TextStyle['fontWeight'];
195+
subtitleSize?: number
196+
descriptionFontWeight?: TextStyle['fontWeight'];
199197
descriptionSize?: number;
200198
dateSize?: number;
201199
};
202-
badgeStyle?: {
203-
size?: number;
204-
textSize?: number;
205-
top?: number;
206-
right?: number;
207-
};
208200
deleteIcon?:{
209201
size?: number
210202
};
211-
dateIcon?:{
203+
timerIcon?:{
212204
size?: number
213205
};
214206
clearAllIcon?:{
215207
size?: number
216208
};
217209
};
218210
```
211+
#### CardProps
212+
```js
213+
type CardProps = {
214+
hideAvatar?: boolean;
215+
onAvatarClick?: (notification: NotificationDataType) => void;
216+
disableAutoMarkAsRead?: boolean;
217+
deleteIcon?: JSX.Element;
218+
hideDelete?: boolean;
219+
hideMediaThumbnail?: boolean;
220+
onMediaThumbnailClick?: (notification: NotificationDataType) => void;
221+
};
222+
```
223+
224+
#### HeaderProps
225+
```js
226+
type HeaderProps = {
227+
title?: string;
228+
hideHeader?: boolean;
229+
hideClearAll?: boolean;
230+
customHeader?: JSX.Element | null;
231+
showBackButton?: boolean;
232+
backButton?: JSX.Element;
233+
onBackPress?: () => void;
234+
};
235+
```
219236

220237
## 3. Hooks
221238

@@ -225,14 +242,10 @@ Here are the custom style options for the notification inbox:
225242
import { useSiren } from '@sirenapp/react-native-inbox';
226243

227244
function MyComponent() {
228-
const { markAsRead, deleteNotification } = useSiren();
245+
const { markAsReadById, deleteById } = useSiren();
229246

230247
function handleMarkAsRead(id) {
231-
markAsRead(id);
232-
}
233-
234-
function handleDeleteNotification(id) {
235-
deleteNotification(id);
248+
markAsReadById(id);
236249
}
237250

238251
return (
@@ -244,23 +257,11 @@ function MyComponent() {
244257

245258
Functions | Parameters | Type | Description |
246259
----------|------------|-------|------------|
247-
markNotificationsAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
248-
markAsRead | id | string | Set read status of a notification to true |
249-
deleteNotification | id | string | Delete a notification by id |
250-
deleteNotificationsByDate | startDate | ISO date string | Delete all notifications until given date |
251-
markNotificationsAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
252-
253-
## 4. Error codes
254-
Given below are all possible error codes thrown by sdk:
255-
256-
Error code | Description |
257-
--- | --- |
258-
INVALID_TOKEN | The token passed in the provider is invalid |
259-
INVALID_RECIPIENT_ID | The recipient id passed in the provider is invalid |
260-
TOKEN_VERIFICATION_FAILED | Verification of the given tokens has failed |
261-
GENERIC_API_ERROR | Occurrence of an unexpected api error |
262-
OUTSIDE_SIREN_CONTEXT | Attempting to invoke the functions outside the siren inbox context |
263-
MISSING_PARAMETER | The required parameter is missing |
260+
markAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
261+
markAsReadById | id | string | Set read status of a notification to true |
262+
deleteById | id | string | Delete a notification by id |
263+
deleteByDate | startDate | ISO date string | Delete all notifications until given date |
264+
markAllAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
264265

265266
## Example
266267
Here's a basic example to help you get started
@@ -294,10 +295,9 @@ function MyContainer(): React.JSX.Element {
294295
darkMode={false}
295296
/>
296297
<SirenInbox
297-
title="Notifications"
298298
hideHeader={false}
299299
darkMode={false}
300-
cardProps={{hideAvatar: false}}
300+
cardProps={{hideAvatar: false, disableAutoMarkAsRead: false}}
301301
/>
302302
</View>
303303
);

example/App.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ const Stack = createNativeStackNavigator();
1111
function MyStack() {
1212
return (
1313
<Stack.Navigator>
14-
<Stack.Screen name='Home' component={Home} />
14+
<Stack.Screen
15+
name='Home'
16+
options={{
17+
headerShown: false
18+
}}
19+
component={Home}
20+
/>
1521
<Stack.Screen
1622
name='Notifications'
1723
options={{
@@ -31,11 +37,7 @@ function App(): React.JSX.Element {
3137

3238
return (
3339
<NavigationContainer>
34-
<SirenProvider
35-
config={config}
36-
>
37-
{MyStack()}
38-
</SirenProvider>
40+
<SirenProvider config={config}>{MyStack()}</SirenProvider>
3941
</NavigationContainer>
4042
);
4143
}

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@react-navigation/bottom-tabs": "^6.5.14",
1414
"@react-navigation/native": "^6.1.12",
1515
"@react-navigation/native-stack": "^6.9.20",
16-
"@sirenapp/react-native-inbox": "^1.0.0",
16+
"@sirenapp/react-native-inbox": "^1.1.0",
1717
"react": "18.2.0",
1818
"react-native": "0.73.4",
1919
"react-native-modal": "^13.0.1",

example/screens/home.tsx

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ const badgeThemes = [
1919
{
2020
light: {
2121
badgeStyle: {
22-
color: 'black',
23-
},
22+
color: 'black'
23+
}
2424
},
2525
dark: {
2626
badgeStyle: {
27-
color: 'green',
27+
color: 'green'
2828
}
2929
}
3030
},
3131
{
3232
light: {
3333
badgeStyle: {
34-
color: 'blue',
34+
color: 'blue'
3535
}
3636
},
3737
dark: {
3838
badgeStyle: {
39-
color: 'pink',
39+
color: 'pink'
4040
}
4141
}
4242
}
@@ -48,7 +48,7 @@ function Home(): React.JSX.Element {
4848
const [showTestingWindow, setShowTestingWindow] = useState(false);
4949
const [showCustomNotification, setShowCustomNotification] = useState(false);
5050
const [badgeThemeIndex, setBadgeThemeIndex] = useState(0);
51-
const [showNetwork, setShowNetwork] = useState(true);
51+
const [showNetwork, setShowNetwork] = useState(false);
5252

5353
const backgroundStyle = {
5454
backgroundColor: isDarkMode ? '#000' : '#FFF'
@@ -79,12 +79,9 @@ function Home(): React.JSX.Element {
7979
</View>
8080
{showTestingWindow && (
8181
<View style={styles.testingWindowInnerContainer}>
82-
{renderButton(
83-
`${showNetwork ? 'Hide' : 'Show'} network`,
84-
() => {
85-
setShowNetwork((showNetwork) => !showNetwork);
86-
}
87-
)}
82+
{renderButton(`${showNetwork ? 'Hide' : 'Show'} network`, () => {
83+
setShowNetwork((showNetwork) => !showNetwork);
84+
})}
8885
{renderButton(`${showCustomNotification ? 'Default' : 'Custom'}-N-Icon`, () =>
8986
setShowCustomNotification((showCustomNotification) => !showCustomNotification)
9087
)}
@@ -120,20 +117,24 @@ function Home(): React.JSX.Element {
120117
backgroundColor={backgroundStyle.backgroundColor}
121118
/>
122119
<View style={styles.contentContainer}>
123-
<SirenInboxIcon
124-
theme={badgeThemes[badgeThemeIndex]}
125-
customStyles={{
126-
notificationIcon: {
127-
size: 60
128-
}
129-
}}
130-
notificationIcon={showCustomNotification ? renderNotificationIcon() : undefined}
131-
onPress={() => navigation.navigate('Notifications')}
132-
/>
133-
<Text>Siren Notification Icon Theme Testing</Text>
134-
{showNetwork && <NetworkLogDebugModal />}
120+
<View style={styles.iconContainer}>
121+
<SirenInboxIcon
122+
theme={badgeThemes[badgeThemeIndex]}
123+
customStyles={{
124+
notificationIcon: {
125+
size: 30
126+
}
127+
}}
128+
notificationIcon={showCustomNotification ? renderNotificationIcon() : undefined}
129+
onPress={() => navigation.navigate('Notifications')}
130+
/>
131+
</View>
132+
<View style={styles.contentContainer}>
133+
<Text>Home screen</Text>
134+
{showNetwork && <NetworkLogDebugModal />}
135+
</View>
136+
{testingWindow()}
135137
</View>
136-
{testingWindow()}
137138
</SafeAreaView>
138139
);
139140
}
@@ -171,7 +172,7 @@ const styles = StyleSheet.create({
171172
},
172173
testingWindowInnerContainer: {
173174
flexWrap: 'wrap',
174-
flexDirection: 'row',
175+
flexDirection: 'row'
175176
},
176177
whiteLabel: {
177178
color: '#fff',
@@ -187,6 +188,12 @@ const styles = StyleSheet.create({
187188
margin: 6,
188189
borderRadius: 4,
189190
height: 30
191+
},
192+
iconContainer: {
193+
position: 'absolute',
194+
top: 0,
195+
right: 10,
196+
zIndex:2,
190197
}
191198
});
192199

0 commit comments

Comments
 (0)