import React from 'react'; import { MainViewController } from './MainViewController'; import { ActionsPanel, SectionType } from './session/ActionsPanel'; import { LeftPaneMessageSection } from './session/LeftPaneMessageSection'; import { PropsData as ConversationListItemPropsType } from './ConversationListItem'; import { PropsData as SearchResultsProps } from './SearchResults'; import { SearchOptions } from '../types/Search'; import { LeftPaneSectionHeader } from './session/LeftPaneSectionHeader'; import { SessionIconButton, SessionIconSize, SessionIconType, } from './session/icon'; import { SessionIdEditable } from './session/SessionIdEditable'; import { UserSearchDropdown } from './session/UserSearchDropdown'; import { SessionButton, SessionButtonColor, SessionButtonType, } from './session/SessionButton'; import { ConversationType } from '../state/ducks/conversations'; import { LeftPaneContactSection } from './session/LeftPaneContactSection'; import { LeftPaneSettingSection } from './session/LeftPaneSettingSection'; // from https://github.com/bvaughn/react-virtualized/blob/fb3484ed5dcc41bffae8eab029126c0fb8f7abc0/source/List/types.js#L5 export type RowRendererParamsType = { index: number; isScrolling: boolean; isVisible: boolean; key: string; parent: Object; style: Object; }; interface State { selectedSection: SectionType; } interface Props { conversations: Array; friends: Array; searchResults?: SearchResultsProps; searchTerm: string; isSecondaryDevice: boolean; openConversationInternal: (id: string, messageId?: string) => void; updateSearchTerm: (searchTerm: string) => void; search: (query: string, options: SearchOptions) => void; clearSearch: () => void; } export class LeftPane extends React.Component { public state = { selectedSection: SectionType.Contact, }; public constructor(props: any) { super(props); this.handleSectionSelected = this.handleSectionSelected.bind(this); } // this static function is set here to be used by all subsections (message, contacts,...) to render their headers public static RENDER_HEADER( labels: Array, onTabSelected?: any, buttonLabel?: string, buttonClicked?: any, notificationCount?: number ): JSX.Element { return ( ); } public static RENDER_CLOSABLE_OVERLAY( isAddContactView: boolean, onChangeSessionID: any, onCloseClick: any, onButtonClick: any, searchTerm: string, searchResults?: any, updateSearch?: any ): JSX.Element { const title = isAddContactView ? window.i18n('addContact') : window.i18n('enterRecipient'); const buttonText = isAddContactView ? window.i18n('addContact') : window.i18n('message'); const ourSessionID = window.textsecure.storage.user.getNumber(); return (

{title}

{window.i18n('enterSessionID')}



{window.i18n('usersCanShareTheir...')}
{isAddContactView ||

{window.i18n('or')}

} {isAddContactView || ( )} {isAddContactView && (
{window.i18n('yourPublicKey')}
)} {isAddContactView && ( )}
); } public handleSectionSelected(section: SectionType) { this.setState({ selectedSection: section }); } public render(): JSX.Element { return (
{this.renderSection()}
); } private renderSection(): JSX.Element | undefined { switch (this.state.selectedSection) { case SectionType.Message: return this.renderMessageSection(); case SectionType.Contact: return this.renderContactSection(); case SectionType.Settings: return this.renderSettingSection(); default: return undefined; } } private renderMessageSection() { const { openConversationInternal, conversations, searchResults, searchTerm, isSecondaryDevice, updateSearchTerm, search, clearSearch, } = this.props; return ( ); // Render Message View Also! } private renderContactSection() { const { openConversationInternal, friends, conversations, searchResults, searchTerm, isSecondaryDevice, updateSearchTerm, search, clearSearch, } = this.props; return ( ); } private renderSettingSection() { return ; } }