Source

containers/Custom/Profile/ProfileGroupsScreen.ts

import {compose} from "recompose";
import ProfileGroups from "../../Profile/ProfileGroupsScreen";
import withActiveCallBacks from "../../../navigators/react-navigation-addons/withActiveCallBacks";
import {withNavigation} from "../../../components/hocs/withNavigation";
import withLoadProfile from "../../../components/hocs/withLoadProfile";
import PropTypes from "prop-types";

/**
 * You can use this component to display the Profile Groups Screen in your custom screen.
 * @component
 * @example <caption> Display groups which the logged-in user is a member of </caption>
 * //In custom_code/components/MyCustomScreen.js...
 * import React from 'react';
 * import ProfileGroupsScreen from "@src/containers/Custom/Profile/ProfileGroupsScreen";
 *
 * const MyCustomScreen = (props) => {
 *
 *  const t = props.screenProps.t;
 *
 *  const filters = [
 *    {value: "my-groups", label: t("groups:my-groups")},
 *    // {value: "invites", label: t("groups:invites")} //commented out "invites" to only show My Groups
 *  ];
 *
 *  if (!props.isFocused)
 *    return null;
 *
 *  return (
 *    <>
 *        <ProfileGroupsScreen
 *          screenTitle="MY GROUPS"
 *          hideBackButton={true}
 *          filters={filters}
 *          {...props}
 *        />
 *    </>
 *  )
 * }
 *
 * MyCustomScreen.navigationOptions = { header: null };
 *
 * export default MyCustomScreen;
 *
 * //In custom_code/index.js...
 *
 * ...
 *
 * import MyCustomScreen from "./components/MyCustomScreen";
 * export const applyCustomCode = externalCodeSetup => {
 *
 *  externalCodeSetup.navigationApi.addNavigationRoute(
 *    "book",
 *    "BookScreen",
 *    MyCustomScreen,
 *    "All"
 *  );
 *  externalCodeSetup.navigationApi.addNavigationRoute(
 *    "book",
 *    "BookScreen",
 *    MyCustomScreen,
 *    "Main"
 *  );
 * }
 *
 * @example <caption> Display groups of a specific user </caption>
 *
 * //In custom_code/components/MyCustomScreen.js...
 * import React from "react";
 * import ProfileGroupsScreen from "@src/containers/Custom/Profile/ProfileGroupsScreen";
 * import {useScreenProps} from "@src/navigators/v5/ScreenPropsProvider";
 * const MyCustomScreen = props => {
 *     const {t} = useScreenProps(["t"]);
 *
 *     const filters = [
 *         {value: "my-groups", label: t("groups:my-groups")}
 *         // {value: "invites", label: t("groups:invites")} //commented out "invites" to only show My Groups
 *     ];
 *
 *     if (!props.isFocused) return null;
 *
 *     return (
 *         <>
 *             <ProfileGroupsScreen
 *                 screenTitle="MY GROUPS"
 *                 hideBackButton={true}
 *                 filters={filters}
 *                 {...props}
 *             />
 *         </>
 *     );
 * };
 *
 * MyCustomScreen.navigationOptions = {header: null};
 *
 * export default MyCustomScreen;
 *
 *
 * //In custom_code/index.js...
 *
 * ...
 *
 * import MyCustomScreen from "./components/MyCustomScreen";
 * export const applyCustomCode = externalCodeSetup => {
 *
 *  externalCodeSetup.navigationApi.addNavigationRoute(
 *    "book",
 *    "BookScreen",
 *    MyCustomScreen,
 *    "All"
 *  );
 *  externalCodeSetup.navigationApi.addNavigationRoute(
 *    "book",
 *    "BookScreen",
 *    MyCustomScreen,
 *    "Main"
 *  );
 * }
 *
 */
const ProfileGroupsScreen = compose(
	withNavigation,
	withActiveCallBacks
)(ProfileGroups);

export default withLoadProfile(ProfileGroupsScreen);

ProfileGroupsScreen.propTypes = {
	/**
	 * You can use this to display a specific user's profile groups by assigning their userId as this props's value
	 * {Number}
	 */
	userId: PropTypes.number,
	/**
	 * List screen title
	 * {String}
	 */
	screenTitle: PropTypes.string,
	/**
	 * If the user is not yet available in the app state, the component will attempt to load a list of users.
	 * You can use this field to search for the specific user you want to load instead of loading a list of users.
	 * {String}
	 */
	searchTerm: PropTypes.string,
	/**
	 * Use `true` to hide the back button.
	 * By default, the button will use react-navigation's goBack() function.
	 * This can be changed using the `setBackButtonRenderer` hook.
	 * {Boolean}
	 */
	hideBackButton: PropTypes.bool,
	/**
	 * Use `true` to hide the screen title container
	 * {Boolean}
	 */
	hideNavigationHeader: PropTypes.bool,
	/**
	 * Filters to show in the screen.
	 * Note: The `invites` screen will be hidden if the `userId` used is not the logged-in user.
	 * {Array}
	 */
	filters: PropTypes.array,
	/**
	 * Use this to display your own loading component while the screen is loading
	 * {ReactComponent}
	 */
	LoadingComponent: PropTypes.elementType
};