Source

containers/Custom/LessonSingleScreen.ts

import {compose} from "recompose";
import LessonSingle from "../LessonSingleScreen";
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 Lesson single screen in your custom screen.
 * @component
 * @example <caption> Use LessonSingleScreen without back and PrevNext buttons </caption>
 * //In custom_code/components/MyCustomScreen.js
 *
 * import React from 'react';
 * import {View, Text} from 'react-native';
 * import LessonSingleScreen from "@src/containers/Custom/LessonSingleScreen";
 *
 * const MyCustomScreen = (props) => {
 *
 *   const courseId = 162; //Pass course id of the lesson
 *   const lessonId = 164; //Pass id of lesson to load
 *
 *   if (!props.isFocused)
 *      return null;
 *
 *    return (
 *
 *      <View style={{flex: 1}}>
 *
 *         <View style={{flex: 0.1, alignItems: 'center', justifyContent: 'center'}}>
 *            <Text> Here is the Lesson for the Day! </Text>
 *         </View>
 *
 *         <View style={{flex: 0.9, marginBottom: 80}}>
 *            <LessonSingleScreen courseId={courseId} lessonId={lessonId} hidePrevNext={true} hideBackToCourse={true} {...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 LessonSingleScreen = compose(
	withNavigation,
	withActiveCallBacks
)(LessonSingle);

export default withLoadCourse(LessonSingleScreen);

LessonSingleScreen.propTypes = {
	/**
	 * The id of the lesson to display
	 * {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
};