Skip to content

Commit

Permalink
refactor(layout): chat1 navigation options
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Yorsh committed Jun 18, 2019
1 parent ccff0a9 commit dbe6465
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/containers/layouts/messaging/chat1/chat1.container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,24 @@ export class Chat1Container extends React.Component<NavigationScreenProps, State
};

static navigationOptions: NavigationScreenConfig<any> = ({ navigation, screenProps }) => {
const user: Profile = navigation.getParam('interlocutor');
const date: string = navigation.getParam('lastSeen');
const interlocutor: Profile = user ? user : conversation5.interlocutor;
const lastSeen: string = date ? date : 'today';
const chatHeaderConfig: ChatHeaderNavigationStateParams = {
interlocutor: interlocutor,
lastSeen: lastSeen,

const headerProps: ChatHeaderNavigationStateParams = {
interlocutor: navigation.getParam('interlocutor', conversation5.interlocutor),
lastSeen: navigation.getParam('lastSeen', 'today'),
onBack: navigation.getParam('onBack'),
onProfile: navigation.getParam('onProfile'),
};

const renderHeader = (headerProps: NavigationScreenProps, config: ChatHeaderNavigationStateParams) => {
const header = (navigationProps: NavigationScreenProps) => {
return (
<ChatHeader
{...navigationProps}
{...headerProps}
lastSeen={config.lastSeen}
interlocutor={config.interlocutor}
onBack={config.onBack}
onProfile={config.onProfile}
/>
);
};

return {
...navigation,
...screenProps,
header: (headerProps: NavigationScreenProps): TopNavigationElement => {
return renderHeader(headerProps, chatHeaderConfig);
},
};
return { ...navigation, ...screenProps, header };
};

public componentWillMount(): void {
Expand Down

0 comments on commit dbe6465

Please sign in to comment.