Skip to content

Commit b33e177

Browse files
committed
feat: add optional blur view in the ctx menu
1 parent 3f7ddf0 commit b33e177

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

examples/SampleApp/App.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import { useClientNotificationsToastHandler } from './src/hooks/useClientNotific
6363
import AsyncStore from './src/utils/AsyncStore.ts';
6464
import {
6565
MessageInputFloatingConfigItem,
66+
MessageOverlayBackdropConfigItem,
6667
MessageListImplementationConfigItem,
6768
MessageListModeConfigItem,
6869
MessageListPruningConfigItem,
@@ -141,6 +142,9 @@ const App = () => {
141142
const [messageInputFloating, setMessageInputFloating] = useState<
142143
MessageInputFloatingConfigItem['value'] | undefined
143144
>(undefined);
145+
const [messageOverlayBackdrop, setMessageOverlayBackdrop] = useState<
146+
MessageOverlayBackdropConfigItem['value'] | undefined
147+
>(undefined);
144148
const colorScheme = useColorScheme();
145149
const streamChatTheme = useStreamChatTheme();
146150
const streami18n = new Streami18n();
@@ -200,6 +204,10 @@ const App = () => {
200204
'@stream-rn-sampleapp-messageinput-floating',
201205
{ value: false },
202206
);
207+
const messageOverlayBackdropStoredValue = await AsyncStore.getItem(
208+
'@stream-rn-sampleapp-message-overlay-backdrop',
209+
{ value: 'default' },
210+
);
203211
setMessageListImplementation(
204212
messageListImplementationStoredValue?.id as MessageListImplementationConfigItem['id'],
205213
);
@@ -210,6 +218,9 @@ const App = () => {
210218
setMessageInputFloating(
211219
messageInputFloatingStoredValue?.value as MessageInputFloatingConfigItem['value'],
212220
);
221+
setMessageOverlayBackdrop(
222+
messageOverlayBackdropStoredValue?.value as MessageOverlayBackdropConfigItem['value'],
223+
);
213224
};
214225
getMessageListConfig();
215226
return () => {
@@ -258,7 +269,9 @@ const App = () => {
258269
>
259270
<GestureHandlerRootView style={{ flex: 1 }}>
260271
<OverlayProvider
261-
MessageOverlayBackground={MessageOverlayBlurBackground}
272+
MessageOverlayBackground={
273+
messageOverlayBackdrop === 'blurview' ? MessageOverlayBlurBackground : undefined
274+
}
262275
value={{ style: streamChatTheme }}
263276
i18nInstance={streami18n}
264277
>

examples/SampleApp/src/components/SecretMenu.tsx

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export type MessageListImplementationConfigItem = { label: string; id: 'flatlist
2929
export type MessageListModeConfigItem = { label: string; mode: 'default' | 'livestream' };
3030
export type MessageListPruningConfigItem = { label: string; value: 100 | 500 | 1000 | undefined };
3131
export type MessageInputFloatingConfigItem = { label: string; value: boolean };
32+
export type MessageOverlayBackdropConfigItem = {
33+
label: string;
34+
value: 'default' | 'blurview';
35+
};
3236

3337
const messageListImplementationConfigItems: MessageListImplementationConfigItem[] = [
3438
{ label: 'FlatList', id: 'flatlist' },
@@ -52,6 +56,11 @@ const messageInputFloatingConfigItems: MessageInputFloatingConfigItem[] = [
5256
{ label: 'Floating', value: true },
5357
];
5458

59+
const messageOverlayBackdropConfigItems: MessageOverlayBackdropConfigItem[] = [
60+
{ label: 'Default', value: 'default' },
61+
{ label: 'BlurView', value: 'blurview' },
62+
];
63+
5564
export const SlideInView = ({
5665
visible,
5766
children,
@@ -220,6 +229,23 @@ const SecretMenuMessageListPruningConfigItem = ({
220229
</TouchableOpacity>
221230
);
222231

232+
const SecretMenuMessageOverlayBackdropConfigItem = ({
233+
isSelected,
234+
messageOverlayBackdropConfigItem,
235+
storeMessageOverlayBackdrop,
236+
}: {
237+
isSelected: boolean;
238+
messageOverlayBackdropConfigItem: MessageOverlayBackdropConfigItem;
239+
storeMessageOverlayBackdrop: (item: MessageOverlayBackdropConfigItem) => void;
240+
}) => (
241+
<TouchableOpacity
242+
style={[styles.notificationItemContainer, { borderColor: isSelected ? 'green' : 'gray' }]}
243+
onPress={() => storeMessageOverlayBackdrop(messageOverlayBackdropConfigItem)}
244+
>
245+
<Text style={styles.notificationItem}>{messageOverlayBackdropConfigItem.label}</Text>
246+
</TouchableOpacity>
247+
);
248+
223249
/*
224250
* TODO: Please rewrite this entire component.
225251
*/
@@ -245,6 +271,9 @@ export const SecretMenu = ({
245271
>(null);
246272
const [selectedMessageInputFloating, setSelectedMessageInputFloating] =
247273
useState<MessageInputFloatingConfigItem['value']>(false);
274+
const [selectedMessageOverlayBackdrop, setSelectedMessageOverlayBackdrop] = useState<
275+
MessageOverlayBackdropConfigItem['value'] | null
276+
>(null);
248277
const {
249278
theme: {
250279
colors: { black, grey },
@@ -281,6 +310,10 @@ export const SecretMenu = ({
281310
'@stream-rn-sampleapp-messageinput-floating',
282311
messageInputFloatingConfigItems[0],
283312
);
313+
const messageOverlayBackdrop = await AsyncStore.getItem(
314+
'@stream-rn-sampleapp-message-overlay-backdrop',
315+
messageOverlayBackdropConfigItems[0],
316+
);
284317
setSelectedProvider(notificationProvider?.id ?? notificationConfigItems[0].id);
285318
setSelectedMessageListImplementation(
286319
messageListImplementation?.id ?? messageListImplementationConfigItems[0].id,
@@ -290,6 +323,9 @@ export const SecretMenu = ({
290323
setSelectedMessageInputFloating(
291324
messageInputFloating?.value ?? messageInputFloatingConfigItems[0].value,
292325
);
326+
setSelectedMessageOverlayBackdrop(
327+
messageOverlayBackdrop?.value ?? messageOverlayBackdropConfigItems[0].value,
328+
);
293329
};
294330
getSelectedConfig();
295331
}, [notificationConfigItems]);
@@ -322,6 +358,14 @@ export const SecretMenu = ({
322358
setSelectedMessageInputFloating(item.value);
323359
}, []);
324360

361+
const storeMessageOverlayBackdrop = useCallback(
362+
async (item: MessageOverlayBackdropConfigItem) => {
363+
await AsyncStore.setItem('@stream-rn-sampleapp-message-overlay-backdrop', item);
364+
setSelectedMessageOverlayBackdrop(item.value);
365+
},
366+
[],
367+
);
368+
325369
const removeAllDevices = useCallback(async () => {
326370
const { devices } = await chatClient.getDevices(chatClient.userID);
327371
for (const device of devices ?? []) {
@@ -390,6 +434,22 @@ export const SecretMenu = ({
390434
</View>
391435
</View>
392436
</View>
437+
<View style={[menuDrawerStyles.menuItem, { alignItems: 'flex-start' }]}>
438+
<Folder height={20} pathFill={grey} width={20} />
439+
<View>
440+
<Text style={[menuDrawerStyles.menuTitle]}>Message Overlay Backdrop</Text>
441+
<View style={{ marginLeft: 16 }}>
442+
{messageOverlayBackdropConfigItems.map((item) => (
443+
<SecretMenuMessageOverlayBackdropConfigItem
444+
key={item.value}
445+
isSelected={item.value === selectedMessageOverlayBackdrop}
446+
messageOverlayBackdropConfigItem={item}
447+
storeMessageOverlayBackdrop={storeMessageOverlayBackdrop}
448+
/>
449+
))}
450+
</View>
451+
</View>
452+
</View>
393453
<View style={[menuDrawerStyles.menuItem, { alignItems: 'flex-start' }]}>
394454
<Edit height={20} pathFill={grey} width={20} />
395455
<View>

0 commit comments

Comments
 (0)