From c758829621b78aadfb17c52da81aa2cba28dbf4d Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 1 Feb 2021 17:44:11 -0500 Subject: first version --- src/components/notifications/Notification.tsx | 14 ++++++++++++++ src/types/types.ts | 19 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index e0ae231e..265c21b1 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -166,6 +166,20 @@ const Notification: React.FC = (props) => { }, 500); } break; + case 'MOMENT_3+': + case 'MOMENT_FRIEND': + const object = notification_object as MomentType; + await fetchUserX( + dispatch, + {userId: id, username: username}, + screenType, + ); + navigation.push('IndividualMoment', { + moment: object, + userXId: id, + screenType, + }); + break; default: break; } diff --git a/src/types/types.ts b/src/types/types.ts index 1775cd5f..f5f96278 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -179,10 +179,25 @@ export type TaggPopupType = { export type NotificationType = { actor: ProfilePreviewType; verbage: string; - notification_type: 'DFT' | 'FRD_REQ' | 'FRD_ACPT' | 'FRD_DEC' | 'CMT'; - notification_object: CommentType | CommentThreadType | undefined; + notification_type: TypeOfNotification; + notification_object: CommentType | CommentThreadType | MomentType | undefined; timestamp: string; unread: boolean; }; export type TypeOfComment = 'Comment' | 'Thread'; +export type TypeOfNotification = + // notification_object is undefined + | 'DFT' + // notification_object is undefined + | 'FRD_REQ' + // notification_object is undefined + | 'FRD_ACPT' + // notification_object is undefined + | 'FRD_DEC' + // notification_object is CommentType || CommentThreadType + | 'CMT' + // notification_object is MomentType + | 'MOMENT_3+' + // notification_object is MomentType + | 'MOMENT_FRIEND'; -- cgit v1.2.3-70-g09d2 From 3e6e2834aead9ee8e7f16fabcaf89e7f2a4263c2 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 1 Feb 2021 17:58:44 -0500 Subject: to MOM --- src/components/notifications/Notification.tsx | 4 ++-- src/types/types.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index 265c21b1..fc3119ed 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -166,8 +166,8 @@ const Notification: React.FC = (props) => { }, 500); } break; - case 'MOMENT_3+': - case 'MOMENT_FRIEND': + case 'MOM_3+': + case 'MOM_FRIEND': const object = notification_object as MomentType; await fetchUserX( dispatch, diff --git a/src/types/types.ts b/src/types/types.ts index f5f96278..b014aa2e 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -198,6 +198,6 @@ export type TypeOfNotification = // notification_object is CommentType || CommentThreadType | 'CMT' // notification_object is MomentType - | 'MOMENT_3+' + | 'MOM_3+' // notification_object is MomentType - | 'MOMENT_FRIEND'; + | 'MOM_FRIEND'; -- cgit v1.2.3-70-g09d2 From f8a3e57ab04af5658cb48aaa3fded31126bdaa8b Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 1 Feb 2021 18:25:55 -0500 Subject: gradient --- src/components/notifications/Notification.tsx | 6 ++++-- src/constants/constants.ts | 4 ++++ src/types/types.ts | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index fc3119ed..28a5d912 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -2,7 +2,9 @@ import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; import {Alert, Image, StyleSheet, Text, View} from 'react-native'; import {TouchableWithoutFeedback} from 'react-native-gesture-handler'; +import LinearGradient from 'react-native-linear-gradient'; import {useDispatch, useStore} from 'react-redux'; +import {BACKGROUND_GRADIENT_MAP} from '../../constants'; import {ERROR_DELETED_OBJECT} from '../../constants/strings'; import { loadImageFromURL, @@ -199,7 +201,7 @@ const Notification: React.FC = (props) => { }; return ( - <> + @@ -232,7 +234,7 @@ const Notification: React.FC = (props) => { )} - + ); }; diff --git a/src/constants/constants.ts b/src/constants/constants.ts index ad43c337..7fcc457f 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -130,6 +130,10 @@ export const BACKGROUND_GRADIENT_MAP: Record< > = { [BackgroundGradientType.Light]: ['#9F00FF', '#27EAE9'], [BackgroundGradientType.Dark]: ['#421566', '#385D5E'], + [BackgroundGradientType.Notification]: [ + 'rgba(143, 1, 255, 0.5)', + 'rgba(110, 231, 231, 0.5)', + ], }; export const CLASS_YEAR_LIST: Array = [ diff --git a/src/types/types.ts b/src/types/types.ts index b014aa2e..f1ba12f4 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -165,6 +165,7 @@ export enum CategorySelectionScreenType { export enum BackgroundGradientType { Light, Dark, + Notification } /** -- cgit v1.2.3-70-g09d2 From ddaf0797be48876eade913d2b9b5c1357ce6bc5e Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 2 Feb 2021 16:17:47 -0500 Subject: fixed thumbnail reuse bug, added gradient --- src/components/notifications/Notification.tsx | 82 ++++++++++++++++----------- src/services/CommonService.ts | 2 +- 2 files changed, 51 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index 28a5d912..4258e288 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -53,7 +53,6 @@ const Notification: React.FC = (props) => { const [avatar, setAvatar] = useState(undefined); const [momentURI, setMomentURI] = useState(undefined); - const backgroundColor = unread ? '#DCF1F1' : 'rgba(0,0,0,0)'; const [onTapLoadProfile, setOnTapLoadProfile] = useState(false); useEffect(() => { @@ -61,6 +60,8 @@ const Notification: React.FC = (props) => { const response = await loadImageFromURL(thumbnail_url); if (response) { setAvatar(response); + } else { + setAvatar(''); } })(); }, []); @@ -81,9 +82,17 @@ const Notification: React.FC = (props) => { const response = await loadMomentThumbnail(moment_id); if (mounted && response) { setMomentURI(response); + } else { + // if not set to empty, it will re-use the previous notification's state + setMomentURI(''); } }; - if (notification_type === 'CMT' && notification_object) { + if ( + (notification_type === 'CMT' || + notification_type === 'MOM_3+' || + notification_type === 'MOM_FRIEND') && + notification_object + ) { loadMomentImage( notification_object.moment_id ? notification_object.moment_id @@ -200,41 +209,50 @@ const Notification: React.FC = (props) => { dispatch(loadUserNotifications()); }; - return ( - - - - ( + + + + + + + {first_name} {last_name} + + {verbage} + + {notification_type === 'FRD_REQ' && ( + + - - - {first_name} {last_name} - - {verbage} - - {notification_type === 'FRD_REQ' && ( - - - - )} - {notification_type === 'CMT' && notification_object && ( + )} + {(notification_type === 'CMT' || + notification_type === 'MOM_3+' || + notification_type === 'MOM_FRIEND') && + notification_object && ( )} - + + ); + + return unread ? ( + + {renderContent()} + ) : ( + renderContent() ); }; diff --git a/src/services/CommonService.ts b/src/services/CommonService.ts index 4f9fb47a..dfbbf70e 100644 --- a/src/services/CommonService.ts +++ b/src/services/CommonService.ts @@ -6,7 +6,7 @@ export const loadImageFromURL = async (url: string) => { return undefined; } const response = await RNFetchBlob.config({ - fileCache: true, + fileCache: false, appendExt: 'jpg', }).fetch('GET', url); const status = response.info().status; -- cgit v1.2.3-70-g09d2 From b24c549932fa4091d99b261c1b3e9e8460d77dc4 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 2 Feb 2021 18:27:24 -0500 Subject: fixed thumbnail issue --- src/components/notifications/Notification.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index 4258e288..6ee04108 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -61,7 +61,7 @@ const Notification: React.FC = (props) => { if (response) { setAvatar(response); } else { - setAvatar(''); + setAvatar(undefined); } })(); }, []); @@ -84,7 +84,7 @@ const Notification: React.FC = (props) => { setMomentURI(response); } else { // if not set to empty, it will re-use the previous notification's state - setMomentURI(''); + setMomentURI(undefined); } }; if ( -- cgit v1.2.3-70-g09d2 From c75ed458a0ce5cacd522b8ba0ec8979b27f9aa65 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 3 Feb 2021 16:26:08 -0500 Subject: fixed border line issue --- src/components/notifications/Notification.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index 6ee04108..951a5bf6 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -259,7 +259,7 @@ const Notification: React.FC = (props) => { const styles = StyleSheet.create({ container: { flexDirection: 'row', - height: SCREEN_HEIGHT / 10, + height: Math.round(SCREEN_HEIGHT / 10), flex: 1, alignItems: 'center', }, -- cgit v1.2.3-70-g09d2