Source

containers/Custom/LearnTopicSingleScreen.ts

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

/**
 * You can use this component to display your LearnTopic single screen in your custom screen.
 * @component
 * @example <caption> Use LearnTopicSingle in custom navigation route "book" </caption>
 * //In custom_code/components/MyCustomScreen.js
 *
 * import React from 'react';
 * import {View} from 'react-native';
 * import LearnTopicSingleScreen from "@src/containers/Custom/LearnTopicSingleScreen";
 *
 * const MyCustomScreen = (props) => {
 *
 *   const courseId = 162; //Pass course id of the lesson
 *   const lessonId = 164; //Pass id of lesson to load
 *   const topicId = 224; //Pass id of topic to load
 *
 *
 *   return (
 *
 *      <View style={{flex: 1}}>
 *
 *         <View style={{flex: 0.9, marginBottom: 80}}>
 *            <LearnTopicSingleScreen courseId={courseId} lessonId={lessonId} hidePrevNext={true} hideBackToCourse={true} topicId={topicId} {...props} />
 *         </View>
 *
 *      </View>
 *   )
 *
 *
 * }
 *
 * 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 LearnTopicSingleScreen = compose(
	withNavigation,
	withActiveCallBacks
)(LearnTopicSingle);

export default withLoadCourse(LearnTopicSingleScreen);

LearnTopicSingleScreen.propTypes = {
	/**
	 * The id of the topic to display
	 * {Number}
	 */
	topicId: PropTypes.number.isRequired,
	/**
	 * The id of the lesson where the topic belongs
	 * {Number}
	 */
	lessonId: PropTypes.number.isRequired,
	/**
	 * The id of the course where the lesson belongs
	 * {Number}
	 */
	courseId: PropTypes.number.isRequired,
	/**
	 * Use `true` to hide Prev and Next buttons
	 * {Boolean}
	 */
	hidePrevNext: PropTypes.bool,
	/**
	 * Use `true` to hide back button
	 * {Boolean}
	 */
	hideBackToCourse: PropTypes.bool,
	/**
	 * Use this to display your own loading component while the screen is loading
	 * {ReactComponent}
	 */
	LoadingComponent: PropTypes.elementType
};