Source

containers/Custom/CoursesScreen.ts

import {mapProps, compose} from "recompose";
import withLearndashLabels from "../../components/hocs/withLearnDashTranslations";
import CoursesFilter from "../../components/Courses/CoursesFilter";

import withActiveCallBacks from "../../navigators/react-navigation-addons/withActiveCallBacks";
import {withNavigation} from "../../components/hocs/withNavigation";
import PropTypes from "prop-types";

const buildFilterProps = props => ({
	navigation: props.navigation,
	screenTitle: props.labels.courses,
	showSearch: true,
	subFilters: props.subFilters,
	...props
});

/**
 * You can use this component to display your Courses screen in your custom screen.
 * @component
 * @example <caption> Replace the courses screen with a screen that contains the courses list and achieved certificates </caption>
 *
 * //In custom_code/components/MyCustomScreen.js...
 *
 * import React from 'react';
 * import { View, Text } from 'react-native';
 *
 * import {useScreenProps} from "@src/navigators/v5/ScreenPropsProvider";
 * import CoursesScreen from "@src/containers/Custom/CoursesScreen";
 * import CoursesCertificateScreen from "@src/containers/Custom/CoursesCertificateScreen";
 * const MyCustomScreen = (props) => {
 *
 *   const {auth} = useScreenProps(["auth"]);
 *
 *  return <View style={{ flex: 1 }}>
 *
 *    <View style={{ flex: 0.7 }}>
 *      <CoursesScreen {...props} showSearch={false} hideFilters={true} screenTitle="My Courses" hideNavigationHeader={true} hideTitle={true} headerHeight={50}/>
 *    </View>
 *
 *    <Text style={{padding: 10}}> Hello {auth.user.user_nicename}! Below are your achieved certificates</Text>
 *
 *    <View style={{ flex: 0.3 }}>
 *      <CoursesCertificateScreen {...props} hideNavigationHeader={true}/>
 *    </View>
 *
 *  </View>
 * }
 *
 *
 * export default MyCustomScreen;
 *
 * //In custom_code/index.js...
 *
 * ...
 *
 * import MyCustomScreen from "./components/MyCustomScreen";
 *
 * export const applyCustomCode = externalCodeSetup => {
 *  //Replace the courses screen
 *  externalCodeSetup.navigationApi.replaceScreenComponent("courses_all", MyCustomScreen);
 * }
 *
 */

export const CoursesScreen = compose(
	withLearndashLabels,
	withNavigation,
	withActiveCallBacks,
	mapProps(buildFilterProps)
)(CoursesFilter);

CoursesScreen.propTypes = {
	/**
	 * Define header height
	 * {Number}
	 */
	headerHeight: PropTypes.number,
	/**
	 * Use `true` to hide filters in the screen
	 * {Boolean}
	 */
	hideFilters: PropTypes.bool,
	/**
	 * Use `true` to hide the screen title container when scrolling
	 * {Boolean}
	 */
	hideNavigationHeader: PropTypes.bool,
	/**
	 * Use `true` to hide title of the screen
	 * {Boolean}
	 */
	hideTitle: PropTypes.bool,
	/**
	 * List screen title. Default comes from translation files in BuddyBoss site
	 * {String}
	 */
	screenTitle: PropTypes.string,
	/**
	 * Adjust the duration of the Search animation.
	 * A higher value means a longer duration of the animation.
	 * {Number}
	 */
	searchFocusedAnimationDuration: PropTypes.number,
	/**
	 * Amount of space which the header moves up when Search input is focused.
	 * A greater value means that the header will move higher.
	 * {Number}
	 */
	searchFocusedListTopSpace: PropTypes.number,
	/**
	 * Use `false` to hide search box
	 * {Boolean}
	 */
	showSearch: PropTypes.bool
};

export default CoursesScreen;