// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React, {RefObject, useState} from 'react'; import {Platform, View} from 'react-native'; import {KeyboardTrackingView, KeyboardTrackingViewRef} from 'react-native-keyboard-tracking-view'; import Autocomplete from '@components/autocomplete'; import {View as ViewConstants} from '@constants'; import {useIsTablet} from '@hooks/device'; import Archived from './archived'; import DraftHandler from './draft_handler'; import ReadOnly from './read_only'; type Props = { testID?: string; accessoriesContainerID?: string; canPost: boolean; channelId: string; channelIsArchived?: boolean; channelIsReadOnly: boolean; deactivatedChannel: boolean; files?: FileInfo[]; isSearch?: boolean; message?: string; rootId?: string; scrollViewNativeID?: string; keyboardTracker: RefObject; } const {KEYBOARD_TRACKING_OFFSET} = ViewConstants; function PostDraft({ testID, accessoriesContainerID, canPost, channelId, channelIsArchived, channelIsReadOnly, deactivatedChannel, files, isSearch, message = '', rootId = '', scrollViewNativeID, keyboardTracker, }: Props) { const [value, setValue] = useState(message); const [cursorPosition, setCursorPosition] = useState(message.length); const [postInputTop, setPostInputTop] = useState(0); const isTablet = useIsTablet(); if (channelIsArchived || deactivatedChannel) { const archivedTestID = `${testID}.archived`; return ( ); } if (channelIsReadOnly || !canPost) { const readOnlyTestID = `${testID}.read_only`; return ( ); } const draftHandler = ( ); const autoComplete = ( ); if (Platform.OS === 'android') { return ( <> {draftHandler} {autoComplete} ); } return ( <> {draftHandler} {autoComplete} ); } export default PostDraft;