Source

containers/Custom/TopicsScreen.ts

// @flow
import {mapProps, compose} from "recompose";
import TopicsFilter from "../../components/Topics/TopicsFilter";

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

const buildFilterProps = props => ({
	screenTitle: "topics:headerTitle",
	showSearch: true,
	...props
});

/**
 * You can use this component to display your Topics screen in your custom screen.
 * @component
 * @example
 * //In custom_code/components/MyCustomScreen.js...
 * import React from 'react';
 * import {View, Platform} from 'react-native';
 * import TopicsScreen from "@src/containers/Custom/TopicsScreen";
 * import {ifIphoneX} from "react-native-iphone-x-helper";
 * import {BARHEIGHT} from "@src/styles/global";
 *
 * const LIST_HEADER_HEIGHT = 116;
 * const SEARCH_BAR_TOP_PADDING = Platform.select({
 *   ios: ifIphoneX(10, BARHEIGHT + 10),
 *   android: 10
 * });
 *
 * let defaultTopSpace = LIST_HEADER_HEIGHT - SEARCH_BAR_TOP_PADDING; //computation for default top space
 * defaultTopSpace -= 60;
 *
 * const MyCustomScreen = (props) => (
 *   <View style={{ flex: 1 }}>
 *     <TopicsScreen {...props}
 *       headerHeight={200}
 *       searchFocusedListTopSpace={defaultTopSpace}
 *       searchFocusedAnimationDuration={1000}
 *     />
 *   </View>
 * )
 *
 *
 * export default MyCustomScreen;
 *
 * //In custom_code/index.js...
 * import MyCustomScreen from "./components/MyCustomScreen";
 * export const applyCustomCode = externalCodeSetup => {
 *  externalCodeSetup.navigationApi.replaceScreenComponent("topics", MyCustomScreen);
 * }
 */

export const TopicsScreen = compose(
	mapProps(buildFilterProps),
	withNavigation,
	withActiveCallBacks
)(TopicsFilter);

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