Skip to content

Commit 781cd93

Browse files
authored
Merge pull request #2989 from GetStream/develop
Next Release
2 parents 91302d6 + 7ef7eac commit 781cd93

File tree

15 files changed

+302
-143
lines changed

15 files changed

+302
-143
lines changed

examples/ExpoMessaging/yarn.lock

+27-4
Original file line numberDiff line numberDiff line change
@@ -2107,6 +2107,14 @@
21072107
"@gorhom/portal" "1.0.14"
21082108
invariant "^2.2.4"
21092109

2110+
"@gorhom/bottom-sheet@^5.1.1":
2111+
version "5.1.1"
2112+
resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-5.1.1.tgz#43ecb9e7b4d4ca4b4cefdf3b6b497f7715f350bc"
2113+
integrity sha512-Y8FiuRmeZYaP+ZGQ0axDwWrrKqVp4ByYRs1D2fTJTxHMt081MHHRQsqmZ3SK7AFp3cSID+vTqnD8w/KAASpy+w==
2114+
dependencies:
2115+
"@gorhom/portal" "1.0.14"
2116+
invariant "^2.2.4"
2117+
21102118
"@gorhom/portal@1.0.14":
21112119
version "1.0.14"
21122120
resolved "https://registry.yarnpkg.com/@gorhom/portal/-/portal-1.0.14.tgz#1953edb76aaba80fb24021dc774550194a18e111"
@@ -7358,10 +7366,10 @@ stream-buffers@2.2.x, stream-buffers@~2.2.0:
73587366
version "0.0.0"
73597367
uid ""
73607368

7361-
stream-chat-react-native-core@6.6.4:
7362-
version "6.6.4"
7363-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-6.6.4.tgz#f15c518148640efa30975abf4ae5cda648d8b1ed"
7364-
integrity sha512-YT3SY/QHwKboEKbvpe7xermyDsvwNAxe7pbV9VZzvayu066/vTk17uYw1RCGFcLQQsnKNJj8ZFt8j0ZLql4exQ==
7369+
stream-chat-react-native-core@6.6.5:
7370+
version "6.6.5"
7371+
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-6.6.5.tgz#ac34a1bd2ec3b950b3bc8bc122ec826d6dd51113"
7372+
integrity sha512-SZyr/TlOoW+j7t4X/CXBhvQ8LN8AgFg4vR6UfcP151fYvf4uwMrzmMN1T/IBsUBr30Kjmr54ik/dH0Z+tnLX2w==
73657373
dependencies:
73667374
"@gorhom/bottom-sheet" "^5.0.6"
73677375
dayjs "1.10.5"
@@ -7396,6 +7404,21 @@ stream-chat@^8.56.1:
73967404
jsonwebtoken "~9.0.0"
73977405
ws "^7.5.10"
73987406

7407+
stream-chat@^8.57.5:
7408+
version "8.57.5"
7409+
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.57.5.tgz#1b49b7504371e19a539465e2ae5dc86aa3269637"
7410+
integrity sha512-ndcbH/zGzUIAhZLGn1owVV8MeNvVfWITIlhAhfmnsV7RLoo/eiGFEuP4aNoG1YRos/g9xJQ7TEmKpz8xYqo13w==
7411+
dependencies:
7412+
"@babel/runtime" "^7.16.3"
7413+
"@types/jsonwebtoken" "~9.0.0"
7414+
"@types/ws" "^7.4.0"
7415+
axios "^1.6.0"
7416+
base64-js "^1.5.1"
7417+
form-data "^4.0.0"
7418+
isomorphic-ws "^4.0.1"
7419+
jsonwebtoken "~9.0.0"
7420+
ws "^7.5.10"
7421+
73997422
stream-slice@^0.1.2:
74007423
version "0.1.2"
74017424
resolved "https://registry.yarnpkg.com/stream-slice/-/stream-slice-0.1.2.tgz#2dc4f4e1b936fb13f3eb39a2def1932798d07a4b"

examples/SampleApp/ios/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,7 @@ PODS:
21552155
- libwebp (~> 1.0)
21562156
- SDWebImage/Core (~> 5.10)
21572157
- SocketRocket (0.7.1)
2158-
- stream-chat-react-native (6.6.2):
2158+
- stream-chat-react-native (6.6.5):
21592159
- DoubleConversion
21602160
- glog
21612161
- hermes-engine
@@ -2579,7 +2579,7 @@ SPEC CHECKSUMS:
25792579
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
25802580
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
25812581
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
2582-
stream-chat-react-native: 3a55bdcec6938301d40f771c84c08ea9c7ba2250
2582+
stream-chat-react-native: d04ab7e1a2623a5444277bdc84c2c0a7b2533909
25832583
Yoga: 28b8cda182ee3092ff80203da66dcb3ffc8cf401
25842584

25852585
PODFILE CHECKSUM: 4f662370295f8f9cee909f1a4c59a614999a209d

examples/SampleApp/ios/SampleApp.xcodeproj/project.pbxproj

+8-2
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,10 @@
688688
"-DFOLLY_USE_LIBCPP=1",
689689
"-DFOLLY_CFG_NO_COROUTINES=1",
690690
);
691-
OTHER_LDFLAGS = "$(inherited) ";
691+
OTHER_LDFLAGS = (
692+
"$(inherited)",
693+
" ",
694+
);
692695
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
693696
SDKROOT = iphoneos;
694697
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
@@ -820,7 +823,10 @@
820823
"-DFOLLY_USE_LIBCPP=1",
821824
"-DFOLLY_CFG_NO_COROUTINES=1",
822825
);
823-
OTHER_LDFLAGS = "$(inherited) ";
826+
OTHER_LDFLAGS = (
827+
"$(inherited)",
828+
" ",
829+
);
824830
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
825831
SDKROOT = iphoneos;
826832
USE_HERMES = true;

examples/SampleApp/src/components/SecretMenu.tsx

+150-26
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,163 @@
11
import React, { useCallback, useEffect, useMemo, useState } from 'react';
2-
import Animated, { useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
3-
import { LayoutChangeEvent, Text, TouchableOpacity, View, Platform, StyleSheet } from 'react-native';
4-
import { Close, Notification, Check, Delete, useTheme } from 'stream-chat-react-native';
2+
import Animated, {
3+
useAnimatedStyle,
4+
useSharedValue,
5+
withSpring,
6+
withTiming,
7+
} from 'react-native-reanimated';
8+
import {
9+
LayoutChangeEvent,
10+
Text,
11+
TouchableOpacity,
12+
View,
13+
Platform,
14+
StyleSheet,
15+
} from 'react-native';
16+
import { Close, Notification, Delete, useTheme } from 'stream-chat-react-native';
517
import { styles as menuDrawerStyles } from './MenuDrawer.tsx';
618
import AsyncStore from '../utils/AsyncStore.ts';
719
import { StreamChat } from 'stream-chat';
20+
import { LabeledTextInput } from '../screens/AdvancedUserSelectorScreen.tsx';
821

9-
export const SlideInView = ({ visible, children }: { visible: boolean; children: React.ReactNode }) => {
22+
export const SlideInView = ({
23+
visible,
24+
children,
25+
}: {
26+
visible: boolean;
27+
children: React.ReactNode;
28+
}) => {
1029
const animatedHeight = useSharedValue(0);
1130

1231
const onLayout = (event: LayoutChangeEvent) => {
1332
const { height } = event.nativeEvent.layout;
1433
animatedHeight.value = height;
1534
};
1635

17-
const animatedStyle = useAnimatedStyle(() => ({
18-
height: withSpring(visible ? animatedHeight.value : 0, { damping: 10 }),
19-
opacity: withTiming(visible ? 1 : 0, { duration: 500 }),
20-
}), [visible]);
36+
const animatedStyle = useAnimatedStyle(
37+
() => ({
38+
height: withSpring(visible ? animatedHeight.value : 0, { damping: 10 }),
39+
opacity: withTiming(visible ? 1 : 0, { duration: 500 }),
40+
}),
41+
[visible],
42+
);
2143

2244
return (
2345
<Animated.View style={animatedStyle}>
24-
{visible ? <View onLayout={onLayout} style={{ position: 'absolute', width: '100%' }}>
25-
{children}
26-
</View> : null}
46+
{visible ? (
47+
<View onLayout={onLayout} style={{ position: 'absolute', width: '100%' }}>
48+
{children}
49+
</View>
50+
) : null}
2751
</Animated.View>
2852
);
2953
};
3054

3155
const isAndroid = Platform.OS === 'android';
3256

33-
export const SecretMenu = ({ close, visible, chatClient }: { close: () => void, visible: boolean, chatClient: StreamChat }) => {
57+
type NotificationConfigItem = { label: string; name: string; id: string };
58+
59+
const SecretMenuNotificationConfigItem = ({
60+
notificationConfigItem,
61+
storeProvider,
62+
isSelected,
63+
}: {
64+
notificationConfigItem: NotificationConfigItem;
65+
storeProvider: (item: NotificationConfigItem) => void;
66+
isSelected: boolean;
67+
}) => {
68+
const [providerNameOverride, setProviderNameOverride] = useState<string>('');
69+
const [lastSubmittedOverride, setLastSubmittedOverride] = useState<string | null>(null);
70+
71+
const asyncStorageKey = useMemo(
72+
() => `@stream-rn-sampleapp-push-provider-${notificationConfigItem.id}-override`,
73+
[notificationConfigItem],
74+
);
75+
76+
useEffect(() => {
77+
const getProviderNameOverride = async () => {
78+
const nameOverride = await AsyncStore.getItem(asyncStorageKey, '');
79+
setLastSubmittedOverride(nameOverride ?? '');
80+
};
81+
getProviderNameOverride();
82+
}, [asyncStorageKey]);
83+
84+
const storeProviderNameOverride = useCallback(async () => {
85+
await AsyncStore.setItem(asyncStorageKey, providerNameOverride);
86+
setLastSubmittedOverride(providerNameOverride);
87+
}, [asyncStorageKey, providerNameOverride]);
88+
89+
return (
90+
<View
91+
style={[styles.notificationItemContainer, { borderColor: isSelected ? 'green' : 'gray' }]}
92+
>
93+
<TouchableOpacity
94+
style={{ flexDirection: 'row' }}
95+
onPress={() => storeProvider(notificationConfigItem)}
96+
>
97+
<Text style={styles.notificationItem}>{notificationConfigItem.label}</Text>
98+
<Text
99+
numberOfLines={1}
100+
style={{ opacity: 0.7, fontSize: 14, marginLeft: 4, maxWidth: 145 }}
101+
>
102+
{lastSubmittedOverride && lastSubmittedOverride.length > 0
103+
? lastSubmittedOverride
104+
: notificationConfigItem.name}
105+
</Text>
106+
</TouchableOpacity>
107+
{isSelected ? (
108+
<>
109+
<LabeledTextInput
110+
onChangeText={setProviderNameOverride}
111+
label={'PN Provider name override'}
112+
value={providerNameOverride}
113+
/>
114+
<TouchableOpacity style={styles.submitButton} onPress={storeProviderNameOverride}>
115+
<Text style={{ color: 'white', fontSize: 12 }}>Submit</Text>
116+
</TouchableOpacity>
117+
</>
118+
) : null}
119+
</View>
120+
);
121+
};
122+
123+
export const SecretMenu = ({
124+
close,
125+
visible,
126+
chatClient,
127+
}: {
128+
close: () => void;
129+
visible: boolean;
130+
chatClient: StreamChat;
131+
}) => {
34132
const [selectedProvider, setSelectedProvider] = useState<string | null>(null);
35133
const {
36134
theme: {
37135
colors: { black, grey },
38136
},
39137
} = useTheme();
40138

41-
const notificationConfigItems = useMemo(() => [{ label: 'Firebase', name: 'rn-fcm', id: 'firebase' }, { label: 'APNs', name: 'APN', id: 'apn' }], []);
139+
const notificationConfigItems = useMemo(
140+
() => [
141+
{ label: 'Firebase', name: 'rn-fcm', id: 'firebase' },
142+
...(isAndroid ? [] : [{ label: 'APNs', name: 'APN', id: 'apn' }]),
143+
],
144+
[],
145+
);
42146

43147
useEffect(() => {
44148
const getSelectedProvider = async () => {
45-
const provider = await AsyncStore.getItem('@stream-rn-sampleapp-push-provider', notificationConfigItems[0]);
149+
const provider = await AsyncStore.getItem(
150+
'@stream-rn-sampleapp-push-provider',
151+
notificationConfigItems[0],
152+
);
46153
setSelectedProvider(provider?.id ?? 'firebase');
47154
};
48155
getSelectedProvider();
49156
}, [notificationConfigItems]);
50157

51-
const storeProvider = useCallback(async (item: { label: string, name: string, id: string }) => {
52-
await AsyncStore.setItem('@stream-rn-sampleapp-push-provider', item);
53-
setSelectedProvider(item.id);
158+
const storeProvider = useCallback(async (item: NotificationConfigItem) => {
159+
await AsyncStore.setItem('@stream-rn-sampleapp-push-provider', item);
160+
setSelectedProvider(item.id);
54161
}, []);
55162

56163
const removeAllDevices = useCallback(async () => {
@@ -65,7 +172,7 @@ export const SecretMenu = ({ close, visible, chatClient }: { close: () => void,
65172
<View
66173
style={[
67174
menuDrawerStyles.menuItem,
68-
{ opacity: isAndroid ? 0.3 : 1, alignItems: 'flex-start' },
175+
{ alignItems: 'flex-start' },
69176
]}
70177
>
71178
<Notification height={24} pathFill={grey} width={24} />
@@ -81,14 +188,16 @@ export const SecretMenu = ({ close, visible, chatClient }: { close: () => void,
81188
>
82189
Notification Provider
83190
</Text>
84-
{isAndroid ? null : <View style={{ marginLeft: 16 }}>
191+
<View style={{ marginLeft: 16 }}>
85192
{notificationConfigItems.map((item) => (
86-
<TouchableOpacity key={item.id} style={{ paddingTop: 8, flexDirection: 'row' }} onPress={() => storeProvider(item)}>
87-
<Text style={styles.notificationItem}>{item.label}</Text>
88-
{item.id === selectedProvider ? <Check height={16} pathFill={'green'} width={16} style={{ marginLeft: 12 }} /> : null}
89-
</TouchableOpacity>
193+
<SecretMenuNotificationConfigItem
194+
key={item.id}
195+
notificationConfigItem={item}
196+
storeProvider={storeProvider}
197+
isSelected={item.id === selectedProvider}
198+
/>
90199
))}
91-
</View>}
200+
</View>
92201
</View>
93202
</View>
94203
<TouchableOpacity onPress={removeAllDevices} style={menuDrawerStyles.menuItem}>
@@ -126,9 +235,24 @@ export const SecretMenu = ({ close, visible, chatClient }: { close: () => void,
126235

127236
export const styles = StyleSheet.create({
128237
separator: { height: 1, width: '100%', opacity: 0.2 },
129-
notificationContainer: {},
238+
notificationItemContainer: {
239+
paddingTop: 8,
240+
marginTop: 12,
241+
borderRadius: 15,
242+
borderWidth: 2,
243+
padding: 8,
244+
width: 225,
245+
},
130246
notificationItem: {
131-
fontSize: 13,
247+
fontSize: 15,
132248
fontWeight: '500',
133249
},
250+
submitButton: {
251+
flex: 1,
252+
marginTop: 8,
253+
borderRadius: 5,
254+
backgroundColor: 'lightskyblue',
255+
padding: 8,
256+
alignItems: 'center',
257+
},
134258
});

0 commit comments

Comments
 (0)