Skip to content

Commit 1435036

Browse files
committed
feat: message headers redesign
1 parent 529d286 commit 1435036

File tree

34 files changed

+631
-148
lines changed

34 files changed

+631
-148
lines changed

examples/SampleApp/src/components/Reminders/MessageReminderHeader.tsx

Lines changed: 0 additions & 92 deletions
This file was deleted.

examples/SampleApp/src/icons/Bell.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/SampleApp/src/screens/ChannelScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export const ChannelScreen: React.FC<ChannelScreenProps> = ({
176176
};
177177

178178
const onThreadSelect = useCallback(
179-
(thread: LocalMessage | null) => {
179+
(thread: LocalMessage | null, targetedMessageId?: string) => {
180180
if (!thread || !channel) {
181181
return;
182182
}
@@ -185,6 +185,7 @@ export const ChannelScreen: React.FC<ChannelScreenProps> = ({
185185
navigation.navigate('ThreadScreen', {
186186
channel,
187187
thread,
188+
targetedMessageId,
188189
});
189190
},
190191
[channel, navigation, setThread],
@@ -233,7 +234,6 @@ export const ChannelScreen: React.FC<ChannelScreenProps> = ({
233234
initialScrollToFirstUnreadMessage
234235
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : -300}
235236
messageActions={messageActions}
236-
MessageHeader={MessageHeader}
237237
MessageLocation={MessageLocation}
238238
messageId={messageId}
239239
NetworkDownIndicator={() => null}

examples/SampleApp/src/screens/ThreadScreen.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ import { useStateStore } from 'stream-chat-react-native';
1515

1616
import { ScreenHeader } from '../components/ScreenHeader';
1717

18-
import type { RouteProp } from '@react-navigation/native';
18+
import { type RouteProp } from '@react-navigation/native';
1919

2020
import type { StackNavigatorParamList } from '../types';
2121
import { LocalMessage, ThreadState, UserResponse } from 'stream-chat';
2222
import { useCreateDraftFocusEffect } from '../utils/useCreateDraftFocusEffect.tsx';
23-
import { MessageReminderHeader } from '../components/Reminders/MessageReminderHeader.tsx';
2423
import { channelMessageActions } from '../utils/messageActions.tsx';
2524
import { useStreamChatContext } from '../context/StreamChatContext.tsx';
2625
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
@@ -74,7 +73,7 @@ const ThreadHeader: React.FC<ThreadHeaderProps> = ({ thread }) => {
7473
export const ThreadScreen: React.FC<ThreadScreenProps> = ({
7574
navigation,
7675
route: {
77-
params: { channel, thread },
76+
params: { channel, thread, targetedMessageId },
7877
},
7978
}) => {
8079
const {
@@ -87,7 +86,6 @@ export const ThreadScreen: React.FC<ThreadScreenProps> = ({
8786
const { t } = useTranslationContext();
8887
const { setThread } = useStreamChatContext();
8988
const { messageInputFloating, messageListImplementation } = useAppContext();
90-
9189
const onPressMessage: NonNullable<React.ComponentProps<typeof Channel>['onPressMessage']> = (
9290
payload,
9391
) => {
@@ -118,6 +116,13 @@ export const ThreadScreen: React.FC<ThreadScreenProps> = ({
118116
setThread(null);
119117
}, [setThread]);
120118

119+
const onBackPressThread = useCallback(
120+
(messageId?: string) => {
121+
navigation.popTo('ChannelScreen', { messageId: messageId });
122+
},
123+
[navigation],
124+
);
125+
121126
return (
122127
<View style={[styles.container, { backgroundColor: white }]}>
123128
<Channel
@@ -128,14 +133,18 @@ export const ThreadScreen: React.FC<ThreadScreenProps> = ({
128133
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : -300}
129134
messageActions={messageActions}
130135
messageInputFloating={messageInputFloating}
131-
MessageHeader={MessageReminderHeader}
132136
MessageLocation={MessageLocation}
133137
onPressMessage={onPressMessage}
134138
thread={thread}
135139
threadList
140+
onBackPressThread={onBackPressThread}
141+
messageId={targetedMessageId}
136142
>
137143
<ThreadHeader thread={thread} />
138-
<Thread onThreadDismount={onThreadDismount} shouldUseFlashList={messageListImplementation === 'flashlist'} />
144+
<Thread
145+
onThreadDismount={onThreadDismount}
146+
shouldUseFlashList={messageListImplementation === 'flashlist'}
147+
/>
139148
</Channel>
140149
</View>
141150
);

examples/SampleApp/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type StackNavigatorParamList = {
4040
ThreadScreen: {
4141
channel: Channel;
4242
thread: LocalMessage | ThreadType;
43+
targetedMessageId?: string;
4344
};
4445
};
4546

examples/SampleApp/src/utils/messageActions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99
MessageActionsParams,
1010
Time,
1111
TranslationContextValue,
12+
Bell,
1213
} from 'stream-chat-react-native';
13-
import { Bell } from '../icons/Bell';
1414
import { Theme } from 'stream-chat-react-native';
1515

1616
export function channelMessageActions({
@@ -94,7 +94,7 @@ export function channelMessageActions({
9494
},
9595
actionType: reminder ? 'remove-reminder' : 'remind-me',
9696
title: reminder ? 'Remove Reminder' : 'Remind Me',
97-
icon: <Bell height={20} width={20} pathFill={semantics.textSecondary} />,
97+
icon: <Bell height={20} width={20} stroke={semantics.textSecondary} />,
9898
type: 'standard',
9999
});
100100
actions.push({

package/src/components/Channel/Channel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ export type ChannelPropsWithContext = Pick<ChannelContextValue, 'channel'> &
404404
>
405405
> &
406406
Partial<Pick<MessageContextValue, 'isMessageAIGenerated'>> &
407-
Partial<Pick<ThreadContextValue, 'allowThreadMessagesInChannel'>> & {
407+
Partial<Pick<ThreadContextValue, 'allowThreadMessagesInChannel' | 'onBackPressThread'>> & {
408408
shouldSyncChannel: boolean;
409409
thread: ThreadType;
410410
/**
@@ -704,6 +704,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
704704
onLongPressMessage,
705705
onPressInMessage,
706706
onPressMessage,
707+
onBackPressThread,
707708
openPollCreationDialog,
708709
overrideOwnCapabilities,
709710
PollContent,
@@ -1984,6 +1985,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
19841985

19851986
const threadContext = useCreateThreadContext({
19861987
allowThreadMessagesInChannel,
1988+
onBackPressThread,
19871989
closeThread,
19881990
loadMoreThread,
19891991
openThread,

package/src/components/Channel/hooks/useCreateThreadContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const selector = (nextValue: ThreadState) =>
1212

1313
export const useCreateThreadContext = ({
1414
allowThreadMessagesInChannel,
15+
onBackPressThread,
1516
closeThread,
1617
loadMoreThread,
1718
openThread,
@@ -39,6 +40,7 @@ export const useCreateThreadContext = ({
3940

4041
return {
4142
allowThreadMessagesInChannel,
43+
onBackPressThread,
4244
closeThread,
4345
loadMoreThread,
4446
openThread,

package/src/components/ChannelPreview/ChannelPreviewMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const ChannelPreviewMessage = (props: ChannelPreviewMessageProps) => {
7979
if (draftMessage) {
8080
return (
8181
<View style={styles.container}>
82-
<Text style={styles.draftText}>{t('Draft:')}</Text>
82+
<Text style={styles.draftText}>{t('Draft')}:</Text>
8383
{renderMessagePreview(draftMessage)}
8484
</View>
8585
);

package/src/components/Message/Message.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
773773
}
774774
}
775775
: null,
776+
onThreadSelect,
776777
otherAttachments: attachments.other,
777778
preventPress: overlayActive ? true : preventPress,
778779
reactions,

0 commit comments

Comments
 (0)