Source

containers/Custom/MessagesScreen.tsx

// @flow
import {mapProps, compose} from "recompose";
import React from "react";
import {CommonActions} from "@react-navigation/native";
import IconButton from "../../components/IconButton";
import MessagesList from "../../components/Messages/MessagesList";
import withDeeplinkClickHandler from "../../components/hocs/withDeeplinkClickHandler";

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

const screenTitle = "messages:headerTitle";

const buildFilterProps = props => ({
	navigation: props.navigation,
	screenTitle: screenTitle,
	showSearch: true,
	headerProps: {
		headerRight: (
			<IconButton
				icon={{fontIconName: "pencil", weight: 200}} //pencil,round-filled
				// icon={require("../../assets/img/new-circle.png")} //pencil,round-filled
				pressHandler={() => {
					props.messagesSetThread(null, false);
					props.navigation.dispatch(
						CommonActions.navigate({
							name: "MessagesCreatePostScreen"
						})
					);
				}}
				tintColor={props.screenProps.colors.headerIconColor}
				style={{
					height: 24
				}}
				rtlStyleFix="handled"
				withUnderlay={false}
				renderText={null}
				TouchableComponent={null}
				hitSlop={null}
				underlayColor="#000"
			/>
		)
	},
	...props
});

const mapPropsHoc = mapProps(buildFilterProps);
import {messagesSetThread} from "../../actions/messages";
import {connect} from "react-redux";
import {withScreenProps} from "../../components/hocs/withScreenProps";

function mapDispatchToProps(dispatch, ownProps) {
	return {
		messagesSetThread: (id, unread) => dispatch(messagesSetThread(id, unread))
	};
}

/**
 * You can use this component to display your Messages screen in your custom screen.
 *
 * @component
 * @example
 * //In custom_code/components/MyCustomScreen.js...
 *
 * import React from 'react';
 * import { View } from 'react-native';
 * import MessagesScreen from "@src/containers/Custom/MessagesScreen";
 *
 * const MyCustomScreen = (props) => {
 *
 *  return (
 *    <View style={{ flex: 1 }}>
 *        <MessagesScreen {...props} screenTitle="My Messages" hideNavigationHeader={true} />
 *    </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 MessagesScreen = compose(
	withDeeplinkClickHandler,
	withNavigation,
	withActiveCallBacks,
	withScreenProps,
	connect(
		null,
		mapDispatchToProps
	),
	mapPropsHoc
)(MessagesList);

MessagesScreen.propTypes = {
	/**
	 * List screen title. Default comes from translation files in BuddyBoss site
	 * {String}
	 */
	screenTitle: PropTypes.string,
	/**
	 * Use `false` to hide search box
	 * {Boolean}
	 */
	showSearch: PropTypes.bool,
	/**
	 * Use `true` to hide title of the screen
	 * {Boolean}
	 */
	hideTitle: PropTypes.bool,
	/**
	 * Use `true` to hide the screen title container when scrolling
	 * {Boolean}
	 */
	hideNavigationHeader: PropTypes.bool,
	/**
	 * Define header height
	 * {Number}
	 */
	headerHeight: PropTypes.number
};

export default MessagesScreen;