-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathSampleAppComponentOverrides.tsx
More file actions
60 lines (55 loc) · 2.02 KB
/
SampleAppComponentOverrides.tsx
File metadata and controls
60 lines (55 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, { useMemo } from 'react';
import { Platform, StyleSheet, useColorScheme, View } from 'react-native';
import type { ComponentOverrides } from 'stream-chat-react-native';
import { BlurView } from '@react-native-community/blur';
import FastImage from '@d11/react-native-fast-image';
import {
useTheme,
} from 'stream-chat-react-native';
import { CustomAttachmentPickerContent } from './AttachmentPickerContent';
import { CustomChannelPreviewStatus } from './ChannelPreview';
import { MessageLocation } from './LocationSharing/MessageLocation';
import type { MessageOverlayBackdropConfigItem } from './SecretMenu';
const MessageOverlayBlurBackground: NonNullable<ComponentOverrides['MessageOverlayBackground']> =
() => {
const {
theme: { semantics },
} = useTheme();
const scheme = useColorScheme();
const isDark = scheme === 'dark';
const isIOS = Platform.OS === 'ios';
return (
<>
<BlurView
blurAmount={isIOS ? 10 : 6}
blurRadius={isIOS ? undefined : 6}
blurType={isDark ? 'dark' : 'light'}
downsampleFactor={isIOS ? undefined : 12}
pointerEvents='none'
reducedTransparencyFallbackColor='rgba(0, 0, 0, 0.8)'
style={StyleSheet.absoluteFill}
/>
<View
style={[StyleSheet.absoluteFill, { backgroundColor: semantics.backgroundCoreScrim }]}
/>
</>
);
};
const RenderNull = () => null;
export const useSampleAppComponentOverrides = (
messageOverlayBackdrop?: MessageOverlayBackdropConfigItem['value'],
) =>
useMemo<ComponentOverrides>(
() => ({
AttachmentPickerContent: CustomAttachmentPickerContent,
ChannelListHeaderNetworkDownIndicator: RenderNull,
ImageComponent: FastImage,
MessageLocation,
NetworkDownIndicator: RenderNull,
ChannelPreviewStatus: CustomChannelPreviewStatus,
...(messageOverlayBackdrop === 'blurview'
? { MessageOverlayBackground: MessageOverlayBlurBackground }
: {}),
}),
[messageOverlayBackdrop],
);