Skip to main content

Notification Feed

Overview

The LMFeedNotificationFeedScreen is designed to present a list of notifications to the user. Users can pull to refresh the list of notifications, and the screen shows an empty state view when there are no notifications to display. It supports navigating to different parts of the app based on the notification's content.

LMFeedNotificationScreen

UI Components

Data Variables

Callbacks

  • onNotificationItemClickedProp: Triggered when a notification item is clicked. Provides the LMActivityViewData notification object.

Customisation

The LMFeedContextStyles class allows you to customize the appearance of the LMPostContent. You can set the styles in notificationFeedStyle in LMFeedContextStyles.

Customization Table

PropertyTypeDescription
screenHeaderLMHeaderPropsCustomizes the screen header.
backgroundColorstringSets the background color of the screen.
unreadBackgroundColorstringBackground color for unread notifications.
activityTextStylesTextStyleStyles for the activity text.
timestampTextStylesTextStyleStyles for the timestamp text.
userImageStylesUserImageStylesStyles for the user image, including fallback and size.
activityAttachmentImageStyleLMIconPropsStyles for the activity attachment image.
noActivityViewTextstringText to display when there are no activities.
noActivityViewTextStyleTextStyleStyles for the text displayed when there are no activities.
noActivityViewImageReact.ReactNodeImage to display when there are no activities.
noActivityViewImageStyleImageStyleStyles for the image displayed when there are no activities.
customScreenHeaderReact.ReactNodeCustom component to replace the default screen header.
activityTextComponentFunctionCustom component for rendering activity text.

UserImageStyles Table

PropertyTypeDescription
fallbackTextStyleTextStyleStyles for fallback text if the image fails to load.
sizenumberSize of the user image.
onTapFunctionCallback function triggered when the user image is tapped.
fallbackTextBoxStyleViewStyleStyles for the fallback text box.
profilePictureStyleImageStyleStyles for the user profile picture.

Usage Example

Step 1: Create Custom Screen and Wrapper

  • In your app, create a NotificationScreenWrapper file which will wrap the NotificationScreen within the NotificationFeedContextProvider so that the callbacks becomes accessible inside of the NotificationScreen.
  • Create notificationFeedStyles for customisation and call the setNotificationFeedStyles to set the customisation.
import {
LMFeedNotificationFeedScreen,
useNotificationFeedContext,
} from "@likeminds.community/feed-rn-core";

const NotificationScreen = () => {
const { handleActivityOnTap, handleScreenBackPress } =
useNotificationFeedContext();

// customised handleActivityOnTap callback
const customNotificationOnTap = (activity) => {
console.log("do something before notification tap", activity);
handleActivityOnTap(activity);
console.log("do something after notification tap");
};

const notificationFeedStyles = {
backgroundColor: "green",
unreadBackgroundColor: "red",
};

// notification feed screen customisation
if (notificationFeedStyles) {
STYLES.setNotificationFeedStyles(notificationFeedStyles);
}

return (
<LMFeedNotificationFeedScreen
onNotificationItemClickedProp={(activity) =>
customNotificationOnTap(activity)
}
/>
);
};

export default NotificationScreen;

Step 2: Add the Custom Screen in App.tsx

  • In your App.tsx, create a Stack.Navigatorin theNavigationContainerwrapped by LMOverlayProvider.
  • Add NotificationScreenWrapper as a Stack screen in your NavigationContainer.
import {
NOTIFICATION_FEED,
LMOverlayProvider,
STYLES,
} from "@likeminds.community/feed-rn-core";
import NotificationScreenWrapper from "<<path_to_NotificationScreenWrapper.tsx>>";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";

export const App = () => {
const Stack = createNativeStackNavigator();
return (
<LMOverlayProvider
myClient={myClient} // pass in the LMFeedClient created
apiKey={apiKey} // pass in the API Key generated
userName={userName} // pass in the logged-in user's name
userUniqueId={userUniqueID} // pass in the logged-in user's uuid
>
<NavigationContainer ref={navigationRef} independent={true}>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen
name={NOTIFICATION_FEED}
component={NotificationScreenWrapper}
/>
</Stack.Navigator>
</NavigationContainer>
</LMOverlayProvider>
);
};