Skip to content

Commit 25866ea

Browse files
feat: Add custom delete icon option in card props
1 parent e244e67 commit 25866ea

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ Here are the custom style options for the notification inbox:
223223
hideAvatar?: boolean;
224224
onAvatarClick?: (notification: NotificationDataType) => void;
225225
disableAutoMarkAsRead?: boolean;
226+
deleteIcon?: JSX.Element;
226227
hideDelete?: boolean;
227228
};
228229
```

src/components/card.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ import TimerIcon from './timerIcon';
4242

4343
const Card = (props: NotificationCardProps): ReactElement => {
4444
const { onCardClick, notification, cardProps = {}, styles, onDelete, darkMode } = props;
45-
const { hideAvatar, disableAutoMarkAsRead, hideDelete = false, onAvatarClick } = cardProps;
45+
const {
46+
hideAvatar,
47+
disableAutoMarkAsRead,
48+
hideDelete = false,
49+
onAvatarClick,
50+
deleteIcon = null
51+
} = cardProps;
4652
const { markAsRead } = useSiren();
4753

4854
const opacity = useRef(new Animated.Value(1)).current;
@@ -99,7 +105,6 @@ const Card = (props: NotificationCardProps): ReactElement => {
99105
}, [styles, darkMode, imageSource, onAvatarClick]);
100106

101107
const onDeleteItem = async (): Promise<void> => {
102-
103108
const isSuccess = await onDelete(notification.id, false);
104109

105110
if (isSuccess)
@@ -136,9 +141,10 @@ const Card = (props: NotificationCardProps): ReactElement => {
136141
<Text numberOfLines={2} style={[styles.cardTitle, style.cardTitle]}>
137142
{notification.message?.header}
138143
</Text>
139-
{!hideDelete && (
140-
<CloseIcon onDelete={onDeleteItem} notification={notification} styles={styles} />
141-
)}
144+
{!hideDelete &&
145+
(deleteIcon || (
146+
<CloseIcon onDelete={onDeleteItem} notification={notification} styles={styles} />
147+
))}
142148
</View>
143149
{Boolean(notification.message?.subHeader) && (
144150
<Text numberOfLines={2} style={[style.cardSubTitle, styles.cardSubTitle]}>
@@ -163,18 +169,18 @@ const Card = (props: NotificationCardProps): ReactElement => {
163169
const style = StyleSheet.create({
164170
cardWrapper: {
165171
flexDirection: 'row',
166-
alignItems: 'center',
172+
alignItems: 'center'
167173
},
168174
cardContainer: {
169175
width: '100%',
170-
flexDirection: 'row',
176+
flexDirection: 'row'
171177
},
172178
cardIconContainer: {
173179
paddingLeft: 6,
174-
paddingRight: 6,
180+
paddingRight: 6
175181
},
176182
cardTitle: {
177-
paddingBottom: 4,
183+
paddingBottom: 4
178184
},
179185
icon: {
180186
width: '100%',
@@ -193,18 +199,18 @@ const style = StyleSheet.create({
193199
flex: 1,
194200
width: '100%',
195201
paddingRight: 6,
196-
paddingLeft: 6,
202+
paddingLeft: 6
197203
},
198204
cardDescription: {
199-
paddingBottom: 10,
205+
paddingBottom: 10
200206
},
201207
cardSubTitle: {
202208
paddingBottom: 6
203209
},
204210
cardFooterRow: {
205211
flexDirection: 'row',
206212
justifyContent: 'space-between',
207-
alignItems: 'center',
213+
alignItems: 'center'
208214
},
209215
dateStyle: {
210216
paddingLeft: 3

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type CardProps = {
8383
hideAvatar?: boolean;
8484
onAvatarClick?: (notification: NotificationDataType) => void;
8585
disableAutoMarkAsRead?: boolean;
86+
deleteIcon?: JSX.Element;
8687
hideDelete?: boolean;
8788
};
8889

0 commit comments

Comments
 (0)