Source

containers/Custom/LessonSingleScreen.ts

  1. import {compose} from "recompose";
  2. import LessonSingle from "../LessonSingleScreen";
  3. import withLoadCourse from "../../components/hocs/withLoadCourse";
  4. import withActiveCallBacks from "../../navigators/react-navigation-addons/withActiveCallBacks";
  5. import {withNavigation} from "../../components/hocs/withNavigation";
  6. import PropTypes from "prop-types";
  7. /**
  8. * You can use this component to display your Lesson single screen in your custom screen.
  9. * @component
  10. * @example <caption> Use LessonSingleScreen without back and PrevNext buttons </caption>
  11. * //In custom_code/components/MyCustomScreen.js
  12. *
  13. * import React from 'react';
  14. * import {View, Text} from 'react-native';
  15. * import LessonSingleScreen from "@src/containers/Custom/LessonSingleScreen";
  16. *
  17. * const MyCustomScreen = (props) => {
  18. *
  19. * const courseId = 162; //Pass course id of the lesson
  20. * const lessonId = 164; //Pass id of lesson to load
  21. *
  22. * if (!props.isFocused)
  23. * return null;
  24. *
  25. * return (
  26. *
  27. * <View style={{flex: 1}}>
  28. *
  29. * <View style={{flex: 0.1, alignItems: 'center', justifyContent: 'center'}}>
  30. * <Text> Here is the Lesson for the Day! </Text>
  31. * </View>
  32. *
  33. * <View style={{flex: 0.9, marginBottom: 80}}>
  34. * <LessonSingleScreen courseId={courseId} lessonId={lessonId} hidePrevNext={true} hideBackToCourse={true} {...props} />
  35. * </View>
  36. *
  37. * </View>
  38. * )
  39. *
  40. *
  41. * }
  42. *
  43. * export default MyCustomScreen;
  44. *
  45. * //In custom_code/index.js...
  46. *
  47. * ...
  48. *
  49. * import MyCustomScreen from "./components/MyCustomScreen";
  50. *
  51. * export const applyCustomCode = externalCodeSetup => {
  52. *
  53. * externalCodeSetup.navigationApi.addNavigationRoute(
  54. * "book",
  55. * "BookScreen",
  56. * MyCustomScreen,
  57. * "All"
  58. * );
  59. * externalCodeSetup.navigationApi.addNavigationRoute(
  60. * "book",
  61. * "BookScreen",
  62. * MyCustomScreen,
  63. * "Main"
  64. * );
  65. * }
  66. *
  67. */
  68. const LessonSingleScreen = compose(
  69. withNavigation,
  70. withActiveCallBacks
  71. )(LessonSingle);
  72. export default withLoadCourse(LessonSingleScreen);
  73. LessonSingleScreen.propTypes = {
  74. /**
  75. * The id of the lesson to display
  76. * {Number}
  77. */
  78. lessonId: PropTypes.number.isRequired,
  79. /**
  80. * The id of the course where the lesson belongs
  81. * {Number}
  82. */
  83. courseId: PropTypes.number.isRequired,
  84. /**
  85. * Use `true` to hide Prev and Next buttons
  86. * {Boolean}
  87. */
  88. hidePrevNext: PropTypes.bool,
  89. /**
  90. * Use `true` to hide back button
  91. * {Boolean}
  92. */
  93. hideBackToCourse: PropTypes.bool
  94. };