mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-06 10:50:13 +00:00
83 lines
2.5 KiB
TypeScript
83 lines
2.5 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {PortalHost} from '@gorhom/portal';
|
|
import React from 'react';
|
|
import {StyleSheet} from 'react-native';
|
|
|
|
import {KeyboardAwarePostDraftContainer} from '@components/keyboard_aware_post_draft_container';
|
|
import PostDraft from '@components/post_draft';
|
|
import ScheduledPostIndicator from '@components/scheduled_post_indicator';
|
|
import {Screens} from '@constants';
|
|
import {BOTTOM_TAB_HEIGHT} from '@constants/view';
|
|
import {KeyboardStateProvider} from '@context/keyboard_state';
|
|
import {useIsTablet} from '@hooks/device';
|
|
|
|
import ChannelPostList from './channel_post_list';
|
|
|
|
type ChannelContentProps = {
|
|
channelId: string;
|
|
marginTop: number;
|
|
scheduledPostCount: number;
|
|
containerHeight: number;
|
|
enabled?: boolean;
|
|
}
|
|
|
|
const CHANNEL_POST_DRAFT_TESTID = 'channel.post_draft';
|
|
|
|
// This follows the same pattern as draft_input.tsx: `${testID}.post.input`
|
|
const CHANNEL_POST_INPUT_NATIVE_ID = `${CHANNEL_POST_DRAFT_TESTID}.post.input`;
|
|
|
|
const PORTAL_NAME = 'channel_autocomplete';
|
|
|
|
const styles = StyleSheet.create({
|
|
flex: {
|
|
flex: 1,
|
|
},
|
|
});
|
|
|
|
const ChannelContent = ({
|
|
channelId,
|
|
marginTop,
|
|
scheduledPostCount,
|
|
containerHeight,
|
|
enabled = true,
|
|
}: ChannelContentProps) => {
|
|
const isTablet = useIsTablet();
|
|
const tabBarHeight = isTablet ? BOTTOM_TAB_HEIGHT : 0;
|
|
|
|
return (
|
|
<KeyboardStateProvider
|
|
tabBarHeight={tabBarHeight}
|
|
enabled={enabled}
|
|
>
|
|
<KeyboardAwarePostDraftContainer
|
|
textInputNativeID={CHANNEL_POST_INPUT_NATIVE_ID}
|
|
containerStyle={[styles.flex, {marginTop}]}
|
|
renderList={() => (
|
|
<ChannelPostList
|
|
channelId={channelId}
|
|
/>
|
|
)}
|
|
>
|
|
{scheduledPostCount > 0 &&
|
|
<ScheduledPostIndicator scheduledPostCount={scheduledPostCount}/>
|
|
}
|
|
<PostDraft
|
|
channelId={channelId}
|
|
testID={CHANNEL_POST_DRAFT_TESTID}
|
|
containerHeight={containerHeight}
|
|
isChannelScreen={true}
|
|
canShowPostPriority={true}
|
|
location={Screens.CHANNEL}
|
|
portalName={PORTAL_NAME}
|
|
/>
|
|
</KeyboardAwarePostDraftContainer>
|
|
<PortalHost name={PORTAL_NAME}/>
|
|
</KeyboardStateProvider>
|
|
);
|
|
};
|
|
|
|
export default ChannelContent;
|
|
|