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
9 changes: 5 additions & 4 deletions examples/SampleApp/src/components/BottomTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const styles = StyleSheet.create({
paddingVertical: 8,
},
tabListContainer: {
borderTopColor: 'rgba(0, 0, 0, 0.0677)',
borderTopWidth: 1,
flexDirection: 'row',
},
Expand Down Expand Up @@ -128,16 +127,18 @@ const Tab = (props: TabProps) => {

export const BottomTabs: React.FC<BottomTabBarProps> = (props) => {
const { navigation, state } = props;
useTheme();
const { white } = useLegacyColors();
const {
theme: { semantics },
} = useTheme();
const { bottom } = useSafeAreaInsets();

return (
<View
style={[
styles.tabListContainer,
{
backgroundColor: white,
backgroundColor: semantics.backgroundCoreElevation1,
borderTopColor: semantics.borderCoreSubtle,
paddingBottom: bottom,
},
]}
Expand Down
11 changes: 8 additions & 3 deletions package/src/components/Attachment/Attachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,14 @@ const useAudioAttachmentStyles = () => {
const {
theme: { semantics },
} = useTheme();
const { isMyMessage, messageHasOnlySingleAttachment } = useMessageContext();

const showBackgroundTransparent = messageHasOnlySingleAttachment;
const { isMyMessage, message, messageHasOnlySingleAttachment } = useMessageContext();

const messageHasSingleAttachment = message.attachments?.length === 1;
const messageHasCaption = !!message.text?.trim();
const messageIsQuotedReply = !!(message.quoted_message || message.quoted_message_id);
const showBackgroundTransparent =
messageHasOnlySingleAttachment ||
(messageIsQuotedReply && messageHasSingleAttachment && !messageHasCaption);

return useMemo(() => {
return StyleSheet.create({
Expand Down
104 changes: 100 additions & 4 deletions package/src/components/Attachment/__tests__/Attachment.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import type { MessageContextValue } from '../../../contexts/messageContext/Messa
import { MessageProvider } from '../../../contexts/messageContext/MessageContext';
import type { MessagesContextValue } from '../../../contexts/messagesContext/MessagesContext';
import { MessagesProvider } from '../../../contexts/messagesContext/MessagesContext';
import { ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
import { mergeThemes, ThemeProvider } from '../../../contexts/themeContext/ThemeContext';
import {
generateAudioAttachment,
generateFileAttachment,
generateImageAttachment,
generateVideoAttachment,
} from '../../../mock-builders/generator/attachment';
import { generateMessage } from '../../../mock-builders/generator/message';
import { FileTypes } from '../../../types/types';

import { ImageLoadingFailedIndicator } from '../../Attachment/ImageLoadingFailedIndicator';
import { ImageLoadingIndicator } from '../../Attachment/ImageLoadingIndicator';
Expand Down Expand Up @@ -48,8 +49,11 @@ jest.mock('../../../hooks/usePendingAttachmentUpload', () => ({
})),
}));

const getAttachmentComponent = (props: ComponentProps<typeof Attachment>) => {
const message = generateMessage();
const getAttachmentComponent = (
props: ComponentProps<typeof Attachment>,
messageContextValue: Partial<MessageContextValue> = {},
) => {
const message = messageContextValue.message ?? generateMessage();
return (
<ThemeProvider>
<AudioPlayerProvider value={{ allowConcurrentAudioPlayback: false }}>
Expand All @@ -63,7 +67,9 @@ const getAttachmentComponent = (props: ComponentProps<typeof Attachment>) => {
} as unknown as MessagesContextValue
}
>
<MessageProvider value={{ message } as unknown as MessageContextValue}>
<MessageProvider
value={{ message, ...messageContextValue } as unknown as MessageContextValue}
>
<Attachment {...props} />
</MessageProvider>
</MessagesProvider>
Expand All @@ -79,6 +85,8 @@ const getWaveformBarCount = (root: ReactTestInstance) =>
}).length;

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

it('should render File component for "audio" type attachment', async () => {
const attachment = generateAudioAttachment();
const { getByTestId } = render(getAttachmentComponent({ attachment }));
Expand Down Expand Up @@ -122,6 +130,94 @@ describe('Attachment', () => {
isSoundPackageAvailable.mockReturnValue(false);
});

it('uses a transparent audio player background for quoted replies without captions', async () => {
const { isSoundPackageAvailable } = require('../../../native');
isSoundPackageAvailable.mockReturnValue(true);
const attachment = generateAudioAttachment({
duration: 10,
waveform_data: [0.2, 0.6, 0.4],
});
const quotedMessage = generateMessage();
const message = generateMessage({
attachments: [attachment],
quoted_message: quotedMessage,
quoted_message_id: quotedMessage.id,
text: '',
});

const { getByLabelText } = render(
getAttachmentComponent(
{ attachment },
{ isMyMessage: false, message, messageHasOnlySingleAttachment: false },
),
);

await waitFor(() => {
const style = StyleSheet.flatten(getByLabelText('audio-attachment-preview').props.style);
expect(style.backgroundColor).toBe('transparent');
});
isSoundPackageAvailable.mockReturnValue(false);
});

it('keeps the audio player background for quoted replies with captions', async () => {
const { isSoundPackageAvailable } = require('../../../native');
isSoundPackageAvailable.mockReturnValue(true);
const attachment = generateAudioAttachment({
duration: 10,
type: FileTypes.VoiceRecording,
waveform_data: [0.2, 0.6, 0.4],
});
const quotedMessage = generateMessage();
const message = generateMessage({
attachments: [attachment],
quoted_message: quotedMessage,
quoted_message_id: quotedMessage.id,
text: 'caption',
});

const { getByLabelText } = render(
getAttachmentComponent(
{ attachment },
{ isMyMessage: false, message, messageHasOnlySingleAttachment: false },
),
);

await waitFor(() => {
const style = StyleSheet.flatten(getByLabelText('audio-attachment-preview').props.style);
expect(style.backgroundColor).toBe(lightTheme.semantics.chatBgAttachmentIncoming);
});
isSoundPackageAvailable.mockReturnValue(false);
});

it('keeps the audio player background for quoted replies with multiple attachments and no captions', async () => {
const { isSoundPackageAvailable } = require('../../../native');
isSoundPackageAvailable.mockReturnValue(true);
const attachment = generateAudioAttachment({
duration: 10,
waveform_data: [0.2, 0.6, 0.4],
});
const quotedMessage = generateMessage();
const message = generateMessage({
attachments: [attachment, generateAudioAttachment()],
quoted_message: quotedMessage,
quoted_message_id: quotedMessage.id,
text: '',
});

const { getByLabelText } = render(
getAttachmentComponent(
{ attachment },
{ isMyMessage: false, message, messageHasOnlySingleAttachment: false },
),
);

await waitFor(() => {
const style = StyleSheet.flatten(getByLabelText('audio-attachment-preview').props.style);
expect(style.backgroundColor).toBe(lightTheme.semantics.chatBgAttachmentIncoming);
});
isSoundPackageAvailable.mockReturnValue(false);
});

it('should render UrlPreview component if attachment has title_link or og_scrape_url', async () => {
const attachment = generateImageAttachment({
og_scrape_url: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const useStyles = () => {
container: {
backgroundColor: semantics.backgroundCoreElevation1,
borderTopWidth: 1,
borderTopColor: semantics.borderCoreDefault,
borderTopColor: semantics.borderCoreSubtle,
...footer.container,
},
centerContainer: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const useStyles = () => {
flexDirection: 'row',
justifyContent: 'space-between',
borderBottomWidth: 1,
borderBottomColor: semantics.borderCoreDefault,
borderBottomColor: semantics.borderCoreSubtle,
...header.innerContainer,
},
rightContainer: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const useStyles = () => {
flexDirection: 'row',
justifyContent: 'center',
paddingVertical: primitives.spacingXxs,
gap: primitives.spacingXs,
gap: primitives.spacingXxs,
},
name: {
flexShrink: 1,
Expand Down
2 changes: 1 addition & 1 deletion package/src/components/MessageInput/MessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ const MessageComposerWithContext = (props: MessageComposerPropsWithContext) => {
{
borderTopWidth: 1,
backgroundColor: semantics.backgroundCoreElevation1,
borderColor: semantics.borderCoreDefault,
borderTopColor: semantics.borderCoreSubtle,
// paddingBottom: BOTTOM_OFFSET,
paddingBottom:
selectedPicker && !isKeyboardVisible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const useStyles = () => {
return StyleSheet.create({
container: {
backgroundColor: semantics.backgroundCoreApp,
borderTopColor: semantics.borderCoreDefault,
borderTopColor: semantics.borderCoreSubtle,
height: 48,
...container,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
"borderColor": "rgba(26, 27, 37, 0.1)",
"borderWidth": 1,
},
undefined,
{
"borderColor": "#ffffff",
"borderRadius": 9999,
"borderWidth": 2,
},
]
}
testID="avatar-image"
Expand Down Expand Up @@ -143,7 +147,11 @@ exports[`TypingIndicator should match typing indicator snapshot 1`] = `
"borderColor": "rgba(26, 27, 37, 0.1)",
"borderWidth": 1,
},
undefined,
{
"borderColor": "#ffffff",
"borderRadius": 9999,
"borderWidth": 2,
},
]
}
testID="avatar-image"
Expand Down
7 changes: 4 additions & 3 deletions package/src/components/Poll/components/CreatePollHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StyleSheet, Text, View } from 'react-native';
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
import { Check, IconProps } from '../../../icons';
import { Cross } from '../../../icons/xmark-1';
import { ArrowLeft } from '../../../icons/arrow-left';
import { primitives } from '../../../theme';
import { Button } from '../../ui';
import { useCanCreatePoll } from '../hooks/useCanCreatePoll';
Expand Down Expand Up @@ -54,8 +54,9 @@ export const CreatePollHeader = ({
accessibilityLabelKey='a11y/Close poll creation'
variant='secondary'
onPress={onBackPressHandler}
type='solid'
LeadingIcon={Cross}
type='ghost'
size='md'
LeadingIcon={ArrowLeft}
iconOnly
/>

Expand Down
6 changes: 3 additions & 3 deletions package/src/components/Poll/components/PollModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
import { StyleSheet, Text, View } from 'react-native';

import { useTheme } from '../../../contexts';
import { Cross } from '../../../icons/xmark-1';
import { ArrowLeft } from '../../../icons/arrow-left';
import { primitives } from '../../../theme';
import { Button } from '../../ui';

Expand All @@ -27,10 +27,10 @@ export const PollModalHeader = ({ onPress, title }: PollModalHeaderProps) => {
<Button
accessibilityLabelKey='a11y/Close poll'
variant='secondary'
type='solid'
type='ghost'
size='md'
iconOnly
LeadingIcon={Cross}
LeadingIcon={ArrowLeft}
onPress={onPress}
testID='poll-results-close-button'
/>
Expand Down
Loading
Loading