Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions package/src/components/MessageInput/MessageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,33 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
);
return (
<MicPositionProvider value={micPositionContextValue}>
<Animated.View layout={LinearTransition.duration(200)}>
{messageInputFloating ? (
<View
style={{
paddingBottom:
selectedPicker && !isKeyboardVisible
? attachmentPickerBottomSheetHeight - bottomInset + 16
: 16,
}}
/>
) : null}
<Animated.View
style={
messageInputFloating
? [
styles.floatingWrapper,
{
bottom:
selectedPicker && !isKeyboardVisible
? attachmentPickerBottomSheetHeight - bottomInset + BOTTOM_OFFSET
: BOTTOM_OFFSET,
},
floatingWrapper,
]
: null
}
layout={LinearTransition.duration(200)}
>
<PortalWhileClosingView
portalHostName='overlay-composer'
portalName='message-input-composer'
Expand All @@ -370,18 +396,11 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
layout: { height: newHeight },
},
}) => {
messageInputHeightStore.setHeight(
messageInputFloating ? newHeight + BOTTOM_OFFSET : newHeight,
);
messageInputHeightStore.setHeight(newHeight);
}}
style={
messageInputFloating
? [
styles.wrapper,
styles.floatingWrapper,
{ bottom: BOTTOM_OFFSET },
floatingWrapper,
]
? [styles.wrapper]
: [
styles.wrapper,
{
Expand Down Expand Up @@ -468,12 +487,11 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
) : (
<MessageComposerTrailingView />
)}

<View
style={[styles.suggestionsListContainer, { bottom: height }, suggestionListContainer]}
>
<AutoCompleteSuggestionList />
</View>
</View>
<View
style={[styles.suggestionsListContainer, { bottom: height }, suggestionListContainer]}
>
<AutoCompleteSuggestionList />
</View>
</PortalWhileClosingView>
</Animated.View>
Expand Down
19 changes: 4 additions & 15 deletions package/src/components/MessageInput/MessageInputLeadingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,25 @@ import { StyleSheet } from 'react-native';

import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated';

import { AttachmentManagerState } from 'stream-chat';

import { textComposerStateSelector } from './utils/messageComposerSelectors';

import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer';
import { useStateStore } from '../../hooks/useStateStore';
import { primitives } from '../../theme';
import { GiphyChip } from '../ui/GiphyChip';

const hasAttachmentsSelector = (nextState: AttachmentManagerState) => ({
hasAttachments: nextState.attachments?.length > 0,
});

export const MessageInputLeadingView = () => {
const messageComposer = useMessageComposer();
const { textComposer } = messageComposer;
// TODO: V9: This needs to come from the LLC.
const { hasAttachments } = useStateStore(
messageComposer.attachmentManager.state,
hasAttachmentsSelector,
);
const { textComposer, attachmentManager } = messageComposer;
const { command } = useStateStore(textComposer.state, textComposerStateSelector);

useEffect(() => {
if (hasAttachments) {
if (attachmentManager.state.getLatestValue().attachments.length > 0) {
textComposer.clearCommand();
}
}, [textComposer, hasAttachments]);
}, [textComposer, attachmentManager]);

return command && !hasAttachments ? (
return command ? (
<Animated.View
entering={ZoomIn.duration(200)}
exiting={ZoomOut.duration(200)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,7 @@ exports[`Thread should match thread snapshot 1`] = `
</View>
<View
layout={BaseAnimationMock {}}
style={null}
>
<View
name="message-input-composer"
Expand Down Expand Up @@ -2321,22 +2322,22 @@ exports[`Thread should match thread snapshot 1`] = `
</View>
</View>
</View>
<View
style={
[
{
"backgroundColor": "#ffffff",
"position": "absolute",
"width": "100%",
},
{
"bottom": 0,
},
{},
]
}
/>
</View>
<View
style={
[
{
"backgroundColor": "#ffffff",
"position": "absolute",
"width": "100%",
},
{
"bottom": 0,
},
{},
]
}
/>
</View>
</View>
</View>
Expand Down