Source

containers/Custom/DocumentsScreen.ts

import {mapProps, compose} from "recompose";
import {connect} from "react-redux";
import DocumentsFilter from "../../components/Documents/DocumentsFilter";
import withDeeplinkClickHandler from "../../components/hocs/withDeeplinkClickHandler";
import {memberHasPermission, Permissions} from "../../reducers/permissions";

import withActiveCallBacks from "../../navigators/react-navigation-addons/withActiveCallBacks";
import {withNavigation} from "../../components/hocs/withNavigation";
import PropTypes from "prop-types";
const screenTitle = "documents:headerTitle";

const buildFilterProps = props => {
	return {
		showGroupFilter: true,
		navigation: props.navigation,
		screenTitle,
		showSearch: true,
		folderId: 0,
		...props
	};
};

const mapPropsHoc = mapProps(buildFilterProps);

const mapState = state => ({
	canCreateDoc:
		memberHasPermission(state)(Permissions.canCreateDocument) !== false
});

/**
 * You can use this component to showcase your Documents screen in your custom screen.
 * @component
 * @example
 *
 * //In custom_screen/components/MyCustomScreen.js ...
 *
 * import React from 'react';
 * import { View, Text } from 'react-native';
 * import FastImage from "react-native-fast-image";
 * import { DEVICE_WIDTH } from "@src/styles/global";
 *
 * import DocumentsScreen from "@src/containers/Custom/DocumentsScreen";
 *
 * const MyCustomScreen = (props) => {
 *
 *  return (
 *    <View style={{ flex: 1 }}>
 *
 *      <View style={{ marginTop: 50, alignSelf: "center" }}>
 *
 *        <FastImage style={{ width: DEVICE_WIDTH, height: 110, marginBottom: 10 }} source={{ uri: "https://link-to-image.png" }} />
 *
 *      </View>
 *
 *      <View style={{ flex: 1 }}>
 *        <DocumentsScreen {...props} showSearch={false} hideFilters={true} screenTitle="My Docs" hideNavigationHeader={true} headerHeight={80}/>
 *      </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"
 *  );
 *
 * }
 *
 */
export const DocumentsScreen = compose(
	connect(mapState),
	withDeeplinkClickHandler,
	withNavigation,
	withActiveCallBacks,
	mapPropsHoc
)(DocumentsFilter);

DocumentsScreen.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 DocumentsScreen;