Source

containers/Custom/MembersScreen.ts

// @flow
import {mapProps, compose} from "recompose";
import {connect} from "react-redux";
import MembersFilter from "../../components/Members/MembersFilter";
import {Settings, isPlatformSettingEnabled} from "../../reducers/config";
import withActiveCallBacks from "../../navigators/react-navigation-addons/withActiveCallBacks";
import PropTypes from "prop-types";
import {withNavigation} from "../../components/hocs/withNavigation";

const screenTitle = "members:headerTitle";

const buildFilterProps = props => ({
	navigation: props.navigation,
	screenTitle: screenTitle,
	showAdvancedSearch: true,
	showSearch: true,
	...props
});

const mapStateToProps = state => {
	return {
		showAdvancedSearch: isPlatformSettingEnabled(state)(
			Settings.ENABLE_PROFILE_SEARCH
		)
	};
};

/**
 * You can use this component to showcase your Members screen in your custom screen.
 * @component
 * @example <caption> Create custom search for members list screen</caption>
 *
 * //In custom_code/components/MyCustomScreen.js...
 *
 * import React from 'react';
 * import { View, Text, TextInput, Button } from 'react-native';
 * import MembersScreen from "@src/containers/Custom/MembersScreen";
 *
 * const MyCustomScreen = (props) => {
 *
 *  const searchMembers = () => {
 *    // Call custom function for searching members
 *  }
 *
 *  return (
 *    <View style={{ flex: 1 }}>
 *
 *      <View style={{flex: 0.2, backgroundColor: "#fff"}}>
 *
 *       <Text style={{fontSize: 30, marginTop: 90, marginLeft: 30}}> Members </Text>
 *        <TextInput />
 *        <Button title="Search" onPress={() => searchMembers} />
 *      </View>
 *
 *      <View style={{flex: 0.8}}>
 *        <MembersScreen {...props} screenTitle="My Members" hideFilters={false} showSearch={false} hideTitle={false} hideNavigationHeader={false}/>
 *      </View>
 *    </View>)
 * }
 *
 *
 * export default MyCustomScreen;
 *
 * //In custom_code/index.js...
 *
 * import MyCustomScreen from "./components/MyCustomScreen";
 *
 * export const applyCustomCode = externalCodeSetup => {
 *  externalCodeSetup.navigationApi.replaceScreenComponent("MembersScreen", MyCustomScreen);
 * }
 */

export const MembersScreen = compose(
	connect(mapStateToProps),
	mapProps(buildFilterProps),
	withNavigation,
	withActiveCallBacks
)(MembersFilter);

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