Skip to content

Commit 66ee8e4

Browse files
authored
fix: design qa bugfixes (#3543)
## 🎯 Goal <!-- Describe why we are making this change --> ## πŸ›  Implementation details <!-- Provide a description of the implementation --> ## 🎨 UI Changes <!-- Add relevant screenshots --> <details> <summary>iOS</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> <details> <summary>Android</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> ## πŸ§ͺ Testing <!-- Explain how this change can be tested (or why it can't be tested) --> ## β˜‘οΈ Checklist - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [ ] PR targets the `develop` branch - [ ] Documentation is updated - [ ] New code is tested in main example apps, including all possible scenarios - [ ] SampleApp iOS and Android - [ ] Expo iOS and Android
1 parent fdbfd73 commit 66ee8e4

File tree

39 files changed

+317
-109
lines changed

39 files changed

+317
-109
lines changed

β€Žexamples/SampleApp/App.tsxβ€Ž

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ Geolocation.setRNConfiguration({
5959
});
6060

6161
import type { LocalMessage, StreamChat, TextComposerMiddleware } from 'stream-chat';
62-
import { Toast } from './src/components/ToastComponent/Toast';
63-
import { useClientNotificationsToastHandler } from './src/hooks/useClientNotificationsToastHandler';
6462
import AsyncStore from './src/utils/AsyncStore.ts';
6563
import {
6664
MessageInputFloatingConfigItem,
@@ -377,7 +375,6 @@ const DrawerNavigatorWrapper: React.FC<{
377375
<AppOverlayProvider>
378376
<UserSearchProvider>
379377
<DrawerNavigator />
380-
<Toast />
381378
</UserSearchProvider>
382379
</AppOverlayProvider>
383380
</StreamChatProvider>
@@ -403,7 +400,6 @@ const UserSelector = () => (
403400
// TODO: Split the stack into multiple stacks - ChannelStack, CreateChannelStack etc.
404401
const HomeScreen = () => {
405402
const { overlay } = useOverlayContext();
406-
useClientNotificationsToastHandler();
407403

408404
return (
409405
<Stack.Navigator

β€Žexamples/SampleApp/src/components/AttachmentPickerContent.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const CustomAttachmentPickerContent = (props: AttachmentPickerContentProp
2020
} = useTheme();
2121

2222
const Icon = useCallback(
23-
() => <ShareLocationIcon stroke={semantics.textTertiary} />,
23+
() => <ShareLocationIcon width={32} height={32} stroke={semantics.textTertiary} />,
2424
[semantics.textTertiary],
2525
);
2626

β€Žexamples/SampleApp/src/components/ScreenHeader.tsxβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ export const ScreenHeader: React.FC<ScreenHeaderProps> = (props) => {
122122
const {
123123
theme: { semantics },
124124
} = useTheme();
125-
const { black, grey, white } = useLegacyColors();
125+
const { black, grey } = useLegacyColors();
126126
const insets = useSafeAreaInsets();
127127

128128
return (
129129
<View
130130
style={[
131131
styles.safeAreaContainer,
132132
{
133-
backgroundColor: white,
133+
backgroundColor: semantics.backgroundCoreElevation1,
134134
borderBottomColor: semantics.borderCoreSubtle,
135135
height: HEADER_CONTENT_HEIGHT + (inSafeArea ? 0 : insets.top),
136136
},

β€Žexamples/SampleApp/src/icons/ShareLocationIcon.tsxβ€Ž

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ import Svg, { Path } from 'react-native-svg';
22
import { ColorValue } from 'react-native';
33

44
// Icon for "Share Location" button, next to input box.
5-
export const ShareLocationIcon = ({ stroke }: { stroke: ColorValue }) => {
5+
export const ShareLocationIcon = ({
6+
width,
7+
height,
8+
stroke,
9+
}: {
10+
stroke: ColorValue;
11+
width: number;
12+
height: number;
13+
}) => {
614
return (
7-
<Svg width={20} height={20} viewBox='0 0 24 24' fill='none'>
15+
<Svg width={width} height={height} viewBox='0 0 24 24' fill='none'>
816
<Path
917
d='M12 12c-1.654 0-3-1.345-3-3 0-1.654 1.346-3 3-3s3 1.346 3 3c0 1.655-1.346 3-3 3zm0-4a1.001 1.001 0 101 1c0-.551-.449-1-1-1z'
1018
fill={stroke}

β€Žpackage/src/components/Attachment/Giphy/Giphy.tsxβ€Ž

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Button } from '../../ui/';
2222

2323
export type GiphyPropsWithContext = Pick<
2424
MessageContextValue,
25-
'handleAction' | 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
25+
'handleAction' | 'isMyMessage' | 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
2626
> &
2727
Pick<MessagesContextValue, 'additionalPressableProps' | 'giphyVersion'> & {
2828
attachment: Attachment;
@@ -34,6 +34,7 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
3434
attachment,
3535
giphyVersion,
3636
handleAction,
37+
isMyMessage,
3738
onLongPress,
3839
onPress,
3940
onPressIn,
@@ -53,7 +54,7 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
5354
},
5455
} = useTheme();
5556

56-
const styles = useStyles();
57+
const styles = useStyles({ isMyMessage });
5758

5859
const uri = image_url || thumb_url;
5960

@@ -122,7 +123,7 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
122123
}
123124
}}
124125
testID='giphy-attachment'
125-
style={styles.container}
126+
style={[styles.container, container]}
126127
{...additionalPressableProps}
127128
>
128129
<GiphyImage attachment={attachment} giphyVersion={giphyVersion} />
@@ -134,10 +135,12 @@ const areEqual = (prevProps: GiphyPropsWithContext, nextProps: GiphyPropsWithCon
134135
const {
135136
attachment: { actions: prevActions, image_url: prevImageUrl, thumb_url: prevThumbUrl },
136137
giphyVersion: prevGiphyVersion,
138+
isMyMessage: prevIsMyMessage,
137139
} = prevProps;
138140
const {
139141
attachment: { actions: nextActions, image_url: nextImageUrl, thumb_url: nextThumbUrl },
140142
giphyVersion: nextGiphyVersion,
143+
isMyMessage: nextIsMyMessage,
141144
} = nextProps;
142145

143146
const imageUrlEqual = prevImageUrl === nextImageUrl;
@@ -165,6 +168,11 @@ const areEqual = (prevProps: GiphyPropsWithContext, nextProps: GiphyPropsWithCon
165168
return false;
166169
}
167170

171+
const isMyMessageEqual = prevIsMyMessage === nextIsMyMessage;
172+
if (!isMyMessageEqual) {
173+
return false;
174+
}
175+
168176
return true;
169177
};
170178

@@ -178,7 +186,8 @@ export type GiphyProps = Partial<GiphyPropsWithContext> & {
178186
* UI component for card in attachments.
179187
*/
180188
export const Giphy = (props: GiphyProps) => {
181-
const { handleAction, onLongPress, onPress, onPressIn, preventPress } = useMessageContext();
189+
const { handleAction, isMyMessage, onLongPress, onPress, onPressIn, preventPress } =
190+
useMessageContext();
182191
const { additionalPressableProps, giphyVersion } = useMessagesContext();
183192

184193
return (
@@ -187,6 +196,7 @@ export const Giphy = (props: GiphyProps) => {
187196
additionalPressableProps,
188197
giphyVersion,
189198
handleAction,
199+
isMyMessage,
190200
onLongPress,
191201
onPress,
192202
onPressIn,
@@ -199,14 +209,16 @@ export const Giphy = (props: GiphyProps) => {
199209

200210
Giphy.displayName = 'Giphy{messageItemView{giphy}}';
201211

202-
const useStyles = () => {
212+
const useStyles = ({ isMyMessage }: Pick<GiphyPropsWithContext, 'isMyMessage'>) => {
203213
const {
204214
theme: { semantics },
205215
} = useTheme();
206216
return useMemo(() => {
207217
return StyleSheet.create({
208218
container: {
209-
backgroundColor: semantics.chatBgOutgoing,
219+
backgroundColor: isMyMessage
220+
? semantics.chatBgAttachmentOutgoing
221+
: semantics.chatBgAttachmentIncoming,
210222
borderRadius: primitives.radiusLg,
211223
maxWidth: 256, // TODO: Not sure how to fix this
212224
overflow: 'hidden',
@@ -240,5 +252,5 @@ const useStyles = () => {
240252
lineHeight: primitives.typographyLineHeightTight,
241253
},
242254
});
243-
}, [semantics]);
255+
}, [isMyMessage, semantics]);
244256
};

β€Žpackage/src/components/Attachment/__tests__/Giphy.test.jsβ€Ž

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { MessageProvider } from '../../../contexts/messageContext/MessageContext
1414
import { MessagesProvider } from '../../../contexts/messagesContext/MessagesContext';
1515
import { OverlayProvider } from '../../../contexts/overlayContext/OverlayProvider';
1616

17-
import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
17+
import { mergeThemes, ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
1818
import { getOrCreateChannelApi } from '../../../mock-builders/api/getOrCreateChannel';
1919
import { useMockedApis } from '../../../mock-builders/api/useMockedApis';
2020
import { generateGiphyAttachment } from '../../../mock-builders/generator/attachment';
@@ -36,6 +36,8 @@ const streami18n = new Streami18n({
3636
});
3737

3838
describe('Giphy', () => {
39+
const lightTheme = mergeThemes({ scheme: 'light' });
40+
3941
const getAttachmentComponent = (props, messageContextValue = {}) => {
4042
const message = generateMessage();
4143
return (
@@ -115,6 +117,36 @@ describe('Giphy', () => {
115117
});
116118
});
117119

120+
it('uses the outgoing attachment background for outgoing giphys', async () => {
121+
render(getAttachmentComponent({ attachment }, { isMyMessage: true }));
122+
123+
await waitFor(() => {
124+
const style = screen.getByTestId('giphy-attachment').props.style;
125+
expect(style).toEqual(
126+
expect.arrayContaining([
127+
expect.objectContaining({
128+
backgroundColor: lightTheme.semantics.chatBgAttachmentOutgoing,
129+
}),
130+
]),
131+
);
132+
});
133+
});
134+
135+
it('uses the incoming attachment background for incoming giphys', async () => {
136+
render(getAttachmentComponent({ attachment }, { isMyMessage: false }));
137+
138+
await waitFor(() => {
139+
const style = screen.getByTestId('giphy-attachment').props.style;
140+
expect(style).toEqual(
141+
expect.arrayContaining([
142+
expect.objectContaining({
143+
backgroundColor: lightTheme.semantics.chatBgAttachmentIncoming,
144+
}),
145+
]),
146+
);
147+
});
148+
});
149+
118150
it('"giphy" attachment size should be customisable', async () => {
119151
attachment.giphy = giphy;
120152
render(getAttachmentComponent({ attachment, giphyVersion: 'fixed_height' }));

β€Žpackage/src/components/AttachmentPicker/components/AttachmentPickerContent.tsxβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export const AttachmentCameraPicker = (
201201
onPress={openCameraPicker}
202202
height={height}
203203
buttonText={t('Open Camera')}
204-
description={t('Take a video and share')}
204+
description={t(videoOnly ? 'Take a video and share' : 'Take a photo and share')}
205205
/>
206206
);
207207
};
@@ -216,8 +216,8 @@ export const AttachmentFilePicker = (props: AttachmentPickerContentProps) => {
216216
Icon={FilePickerIcon}
217217
onPress={pickFile}
218218
height={height}
219-
buttonText={t('Pick document')}
220-
description={t('Pick a document to share it with everyone')}
219+
buttonText={t('Open Files')}
220+
description={t('Select files to share')}
221221
/>
222222
);
223223
};

β€Žpackage/src/components/AttachmentPicker/components/AttachmentPickerGenericContent.tsxβ€Ž

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@ const useStyles = () => {
2121
paddingHorizontal: primitives.spacing2xl,
2222
paddingBottom: primitives.spacing3xl,
2323
},
24-
infoContainer: { flex: 1, alignItems: 'center', justifyContent: 'center' },
24+
infoContainer: {
25+
flex: 1,
26+
gap: primitives.spacingSm,
27+
alignItems: 'center',
28+
justifyContent: 'center',
29+
},
30+
actionContainer: {
31+
gap: primitives.spacingMd,
32+
alignItems: 'center',
33+
justifyContent: 'center',
34+
},
2535
text: {
2636
fontSize: primitives.typographyFontSizeMd,
2737
color: semantics.textSecondary,
28-
marginTop: 8,
29-
marginHorizontal: 24,
3038
textAlign: 'center',
3139
maxWidth: 200,
3240
},
@@ -54,13 +62,13 @@ export const AttachmentPickerGenericContent = (props: AttachmentPickerGenericCon
5462
theme: {
5563
semantics,
5664
attachmentPicker: {
57-
content: { container, text, infoContainer },
65+
content: { actionContainer, container, text, infoContainer },
5866
},
5967
},
6068
} = useTheme();
6169

6270
const ThemedIcon = useCallback(
63-
() => <Icon width={22} height={22} stroke={semantics.textTertiary} />,
71+
() => <Icon width={32} height={32} stroke={semantics.textTertiary} />,
6472
[Icon, semantics.textTertiary],
6573
);
6674

@@ -76,15 +84,17 @@ export const AttachmentPickerGenericContent = (props: AttachmentPickerGenericCon
7684
>
7785
<View style={[styles.infoContainer, infoContainer]}>
7886
<ThemedIcon />
79-
<Text style={[styles.text, text]}>{description}</Text>
87+
<View style={[styles.actionContainer, actionContainer]}>
88+
<Text style={[styles.text, text]}>{description}</Text>
89+
<Button
90+
variant={'secondary'}
91+
type={'outline'}
92+
size={'md'}
93+
label={buttonText}
94+
onPress={onPress}
95+
/>
96+
</View>
8097
</View>
81-
<Button
82-
variant={'secondary'}
83-
type={'outline'}
84-
size={'lg'}
85-
label={buttonText}
86-
onPress={onPress}
87-
/>
8898
</View>
8999
);
90100
};

β€Žpackage/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsxβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useCallback, useMemo } from 'react';
2-
import { FlatList, StyleSheet } from 'react-native';
2+
import { StyleSheet } from 'react-native';
3+
4+
import { FlatList } from 'react-native-gesture-handler';
35

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

β€Žpackage/src/components/ChannelPreview/ChannelDetailsBottomSheet.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const useStyles = () => {
141141
flexDirection: 'row',
142142
padding: primitives.spacingSm,
143143
gap: primitives.spacingSm,
144-
backgroundColor: semantics.backgroundCoreElevation1,
144+
backgroundColor: 'transparent',
145145
...header.container,
146146
},
147147
headerMeta: {

0 commit comments

Comments
Β (0)