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
4 changes: 0 additions & 4 deletions examples/SampleApp/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ Geolocation.setRNConfiguration({
});

import type { LocalMessage, StreamChat, TextComposerMiddleware } from 'stream-chat';
import { Toast } from './src/components/ToastComponent/Toast';
import { useClientNotificationsToastHandler } from './src/hooks/useClientNotificationsToastHandler';
import AsyncStore from './src/utils/AsyncStore.ts';
import {
MessageInputFloatingConfigItem,
Expand Down Expand Up @@ -377,7 +375,6 @@ const DrawerNavigatorWrapper: React.FC<{
<AppOverlayProvider>
<UserSearchProvider>
<DrawerNavigator />
<Toast />
</UserSearchProvider>
</AppOverlayProvider>
</StreamChatProvider>
Expand All @@ -403,7 +400,6 @@ const UserSelector = () => (
// TODO: Split the stack into multiple stacks - ChannelStack, CreateChannelStack etc.
const HomeScreen = () => {
const { overlay } = useOverlayContext();
useClientNotificationsToastHandler();

return (
<Stack.Navigator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const CustomAttachmentPickerContent = (props: AttachmentPickerContentProp
} = useTheme();

const Icon = useCallback(
() => <ShareLocationIcon stroke={semantics.textTertiary} />,
() => <ShareLocationIcon width={32} height={32} stroke={semantics.textTertiary} />,
[semantics.textTertiary],
);

Expand Down
4 changes: 2 additions & 2 deletions examples/SampleApp/src/components/ScreenHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ export const ScreenHeader: React.FC<ScreenHeaderProps> = (props) => {
const {
theme: { semantics },
} = useTheme();
const { black, grey, white } = useLegacyColors();
const { black, grey } = useLegacyColors();
const insets = useSafeAreaInsets();

return (
<View
style={[
styles.safeAreaContainer,
{
backgroundColor: white,
backgroundColor: semantics.backgroundCoreElevation1,
borderBottomColor: semantics.borderCoreSubtle,
height: HEADER_CONTENT_HEIGHT + (inSafeArea ? 0 : insets.top),
},
Expand Down
12 changes: 10 additions & 2 deletions examples/SampleApp/src/icons/ShareLocationIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ import Svg, { Path } from 'react-native-svg';
import { ColorValue } from 'react-native';

// Icon for "Share Location" button, next to input box.
export const ShareLocationIcon = ({ stroke }: { stroke: ColorValue }) => {
export const ShareLocationIcon = ({
width,
height,
stroke,
}: {
stroke: ColorValue;
width: number;
height: number;
}) => {
return (
<Svg width={20} height={20} viewBox='0 0 24 24' fill='none'>
<Svg width={width} height={height} viewBox='0 0 24 24' fill='none'>
<Path
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'
fill={stroke}
Expand Down
26 changes: 19 additions & 7 deletions package/src/components/Attachment/Giphy/Giphy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Button } from '../../ui/';

export type GiphyPropsWithContext = Pick<
MessageContextValue,
'handleAction' | 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
'handleAction' | 'isMyMessage' | 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
> &
Pick<MessagesContextValue, 'additionalPressableProps' | 'giphyVersion'> & {
attachment: Attachment;
Expand All @@ -34,6 +34,7 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
attachment,
giphyVersion,
handleAction,
isMyMessage,
onLongPress,
onPress,
onPressIn,
Expand All @@ -53,7 +54,7 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
},
} = useTheme();

const styles = useStyles();
const styles = useStyles({ isMyMessage });

const uri = image_url || thumb_url;

Expand Down Expand Up @@ -122,7 +123,7 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
}
}}
testID='giphy-attachment'
style={styles.container}
style={[styles.container, container]}
{...additionalPressableProps}
>
<GiphyImage attachment={attachment} giphyVersion={giphyVersion} />
Expand All @@ -134,10 +135,12 @@ const areEqual = (prevProps: GiphyPropsWithContext, nextProps: GiphyPropsWithCon
const {
attachment: { actions: prevActions, image_url: prevImageUrl, thumb_url: prevThumbUrl },
giphyVersion: prevGiphyVersion,
isMyMessage: prevIsMyMessage,
} = prevProps;
const {
attachment: { actions: nextActions, image_url: nextImageUrl, thumb_url: nextThumbUrl },
giphyVersion: nextGiphyVersion,
isMyMessage: nextIsMyMessage,
} = nextProps;

const imageUrlEqual = prevImageUrl === nextImageUrl;
Expand Down Expand Up @@ -165,6 +168,11 @@ const areEqual = (prevProps: GiphyPropsWithContext, nextProps: GiphyPropsWithCon
return false;
}

const isMyMessageEqual = prevIsMyMessage === nextIsMyMessage;
if (!isMyMessageEqual) {
return false;
}

return true;
};

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

return (
Expand All @@ -187,6 +196,7 @@ export const Giphy = (props: GiphyProps) => {
additionalPressableProps,
giphyVersion,
handleAction,
isMyMessage,
onLongPress,
onPress,
onPressIn,
Expand All @@ -199,14 +209,16 @@ export const Giphy = (props: GiphyProps) => {

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

const useStyles = () => {
const useStyles = ({ isMyMessage }: Pick<GiphyPropsWithContext, 'isMyMessage'>) => {
const {
theme: { semantics },
} = useTheme();
return useMemo(() => {
return StyleSheet.create({
container: {
backgroundColor: semantics.chatBgOutgoing,
backgroundColor: isMyMessage
? semantics.chatBgAttachmentOutgoing
: semantics.chatBgAttachmentIncoming,
borderRadius: primitives.radiusLg,
maxWidth: 256, // TODO: Not sure how to fix this
overflow: 'hidden',
Expand Down Expand Up @@ -240,5 +252,5 @@ const useStyles = () => {
lineHeight: primitives.typographyLineHeightTight,
},
});
}, [semantics]);
}, [isMyMessage, semantics]);
};
34 changes: 33 additions & 1 deletion package/src/components/Attachment/__tests__/Giphy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { MessageProvider } from '../../../contexts/messageContext/MessageContext
import { MessagesProvider } from '../../../contexts/messagesContext/MessagesContext';
import { OverlayProvider } from '../../../contexts/overlayContext/OverlayProvider';

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

describe('Giphy', () => {
const lightTheme = mergeThemes({ scheme: 'light' });

const getAttachmentComponent = (props, messageContextValue = {}) => {
const message = generateMessage();
return (
Expand Down Expand Up @@ -115,6 +117,36 @@ describe('Giphy', () => {
});
});

it('uses the outgoing attachment background for outgoing giphys', async () => {
render(getAttachmentComponent({ attachment }, { isMyMessage: true }));

await waitFor(() => {
const style = screen.getByTestId('giphy-attachment').props.style;
expect(style).toEqual(
expect.arrayContaining([
expect.objectContaining({
backgroundColor: lightTheme.semantics.chatBgAttachmentOutgoing,
}),
]),
);
});
});

it('uses the incoming attachment background for incoming giphys', async () => {
render(getAttachmentComponent({ attachment }, { isMyMessage: false }));

await waitFor(() => {
const style = screen.getByTestId('giphy-attachment').props.style;
expect(style).toEqual(
expect.arrayContaining([
expect.objectContaining({
backgroundColor: lightTheme.semantics.chatBgAttachmentIncoming,
}),
]),
);
});
});

it('"giphy" attachment size should be customisable', async () => {
attachment.giphy = giphy;
render(getAttachmentComponent({ attachment, giphyVersion: 'fixed_height' }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const AttachmentCameraPicker = (
onPress={openCameraPicker}
height={height}
buttonText={t('Open Camera')}
description={t('Take a video and share')}
description={t(videoOnly ? 'Take a video and share' : 'Take a photo and share')}
/>
);
};
Expand All @@ -216,8 +216,8 @@ export const AttachmentFilePicker = (props: AttachmentPickerContentProps) => {
Icon={FilePickerIcon}
onPress={pickFile}
height={height}
buttonText={t('Pick document')}
description={t('Pick a document to share it with everyone')}
buttonText={t('Open Files')}
description={t('Select files to share')}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ const useStyles = () => {
paddingHorizontal: primitives.spacing2xl,
paddingBottom: primitives.spacing3xl,
},
infoContainer: { flex: 1, alignItems: 'center', justifyContent: 'center' },
infoContainer: {
flex: 1,
gap: primitives.spacingSm,
alignItems: 'center',
justifyContent: 'center',
},
actionContainer: {
gap: primitives.spacingMd,
alignItems: 'center',
justifyContent: 'center',
},
text: {
fontSize: primitives.typographyFontSizeMd,
color: semantics.textSecondary,
marginTop: 8,
marginHorizontal: 24,
textAlign: 'center',
maxWidth: 200,
},
Expand Down Expand Up @@ -54,13 +62,13 @@ export const AttachmentPickerGenericContent = (props: AttachmentPickerGenericCon
theme: {
semantics,
attachmentPicker: {
content: { container, text, infoContainer },
content: { actionContainer, container, text, infoContainer },
},
},
} = useTheme();

const ThemedIcon = useCallback(
() => <Icon width={22} height={22} stroke={semantics.textTertiary} />,
() => <Icon width={32} height={32} stroke={semantics.textTertiary} />,
[Icon, semantics.textTertiary],
);

Expand All @@ -76,15 +84,17 @@ export const AttachmentPickerGenericContent = (props: AttachmentPickerGenericCon
>
<View style={[styles.infoContainer, infoContainer]}>
<ThemedIcon />
<Text style={[styles.text, text]}>{description}</Text>
<View style={[styles.actionContainer, actionContainer]}>
<Text style={[styles.text, text]}>{description}</Text>
<Button
variant={'secondary'}
type={'outline'}
size={'md'}
label={buttonText}
onPress={onPress}
/>
</View>
</View>
<Button
variant={'secondary'}
type={'outline'}
size={'lg'}
label={buttonText}
onPress={onPress}
/>
</View>
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useCallback, useMemo } from 'react';
import { FlatList, StyleSheet } from 'react-native';
import { StyleSheet } from 'react-native';

import { FlatList } from 'react-native-gesture-handler';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const useStyles = () => {
flexDirection: 'row',
padding: primitives.spacingSm,
gap: primitives.spacingSm,
backgroundColor: semantics.backgroundCoreElevation1,
backgroundColor: 'transparent',
...header.container,
},
headerMeta: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export const ChannelPreviewMessage = (props: ChannelPreviewMessageProps) => {
return (
<View style={styles.container}>
<PollIcon height={16} width={16} stroke={semantics.textSecondary} />
<Text style={styles.subtitle}>{pollLabel}</Text>
<Text ellipsizeMode='tail' numberOfLines={1} style={styles.subtitle}>
{pollLabel}
</Text>
</View>
);
}
Expand Down
4 changes: 3 additions & 1 deletion package/src/components/ImageGallery/components/ImageGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
ImageGalleryAsset,
ImageGalleryState,
} from '../../../state-store/image-gallery-state-store';
import { primitives } from '../../../theme';
import { FileTypes } from '../../../types/types';
import { StreamBottomSheetModalFlatList } from '../../UIComponents/StreamBottomSheetModalFlatList';

Expand Down Expand Up @@ -108,8 +109,9 @@ const useStyles = () => {
return StyleSheet.create({
contentContainer: {
flexGrow: 1,
...contentContainer,
backgroundColor: semantics.backgroundCoreApp,
marginTop: primitives.spacingSm,
...contentContainer,
},
image: { margin: 1, ...gridImage },
});
Expand Down
12 changes: 7 additions & 5 deletions package/src/components/Indicators/LoadingIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import { useTranslationContext } from '../../contexts/translationContext/Transla
import { primitives } from '../../theme';
import { Spinner } from '../UIComponents/Spinner';

type LoadingIndicatorWrapperProps = { text: string };
type LoadingIndicatorWrapperProps = { text: string | undefined };

const LoadingIndicatorWrapper = ({ text }: LoadingIndicatorWrapperProps) => {
const styles = useStyles();

return (
<View style={styles.container}>
<Spinner height={20} width={20} />
<Text style={styles.loadingText} testID='loading'>
{text}
</Text>
{text ? (
<Text style={styles.loadingText} testID='loading'>
{text}
</Text>
) : null}
</View>
);
};
Expand Down Expand Up @@ -44,7 +46,7 @@ export const LoadingIndicator = (props: LoadingProps) => {
case 'message':
return <LoadingIndicatorWrapper text={t('Loading messages...')} />;
case 'threads':
return <LoadingIndicatorWrapper text={t('Loading threads...')} />;
return <LoadingIndicatorWrapper text={undefined} />;
default:
return <LoadingIndicatorWrapper text={t('Loading...')} />;
}
Expand Down
Loading
Loading