Skip to content

Commit 94dfed8

Browse files
committed
revert bottom-sheet changes, fix theme
1 parent 9d857dc commit 94dfed8

File tree

4 files changed

+49
-32
lines changed

4 files changed

+49
-32
lines changed

sample-apps/react-native/dogfood/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ PODS:
17771777
- ReactCommon/turbomodule/core
17781778
- SocketRocket
17791779
- Yoga
1780-
- react-native-image-picker (7.2.3):
1780+
- react-native-image-picker (8.2.1):
17811781
- boost
17821782
- DoubleConversion
17831783
- fast_float
@@ -3412,7 +3412,7 @@ SPEC CHECKSUMS:
34123412
React-Mapbuffer: e4a65db5f4df53369f39558c0cf2f480f6d3d6c7
34133413
React-microtasksnativemodule: 86334c5c06315e0bccb7b6e6f2c905e92f98b615
34143414
react-native-blob-util: 7f71e0af02279ef38a2ba43e8c2fcb79cf927732
3415-
react-native-image-picker: a340c7cd3566cedd56aacd5e61b6b492e9fe2139
3415+
react-native-image-picker: 6051cfd030121b880a58f1cc0e5e33e9887804e4
34163416
react-native-mmkv: 7b9c7469fa0a7e463f9411ad3e4fe273bd5ff030
34173417
react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187
34183418
react-native-safe-area-context: ee1e8e2a7abf737a8d4d9d1a5686a7f2e7466236

sample-apps/react-native/dogfood/src/hooks/useTheme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const getChatStyle = (colorScheme: ColorSchemeName): DeepPartial<Theme> => ({
2424
grey_whisper: '#1C1E22',
2525
grey_dark: '#F7F7F8',
2626
icon_background: '#FFFFFF',
27+
light_blue: '#005FFF',
2728
modal_shadow: '#000000',
2829
overlay: '#FFFFFFCC', // CC = 80% opacity
2930
shadow_icon: '#00000080', // 80 = 50% opacity

sample-apps/react-native/dogfood/src/screens/LiveStream/BottomSheetChatWrapper.tsx

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import {
1313
BottomSheetModal,
1414
BottomSheetModalProvider,
1515
BottomSheetView,
16+
useBottomSheetInternal,
1617
} from '@gorhom/bottom-sheet';
1718
import {
19+
Platform,
1820
StyleSheet,
1921
Text,
2022
TouchableOpacity,
@@ -143,9 +145,9 @@ const BottomSheetChatWrapper = React.forwardRef<
143145
}, [callId, chatClient]);
144146

145147
// This function is to bring back the bottom sheet to the initial snap point for iOS when the focus is outside message input
146-
// const focusOutsideMessageInput = () => {
147-
// bottomSheetModalRef.current?.snapToIndex(0);
148-
// };
148+
const focusOutsideMessageInput = () => {
149+
bottomSheetModalRef.current?.snapToIndex(0);
150+
};
149151

150152
useImperativeHandle(ref, () => ({
151153
open: () => {
@@ -195,7 +197,7 @@ const BottomSheetChatWrapper = React.forwardRef<
195197
>
196198
<LivestreamChat
197199
channel={chatChannel}
198-
// focusOutsideMessageInput={focusOutsideMessageInput}
200+
focusOutsideMessageInput={focusOutsideMessageInput}
199201
/>
200202
</BottomSheetView>
201203
</BottomSheetModal>
@@ -207,28 +209,45 @@ BottomSheetChatWrapper.displayName = 'BottomSheetChatWrapper';
207209

208210
type LivestreamChatProps = {
209211
channel: ChannelType;
210-
// focusOutsideMessageInput: () => void;
212+
focusOutsideMessageInput: () => void;
211213
};
212214

213-
const LivestreamChat = ({ channel }: LivestreamChatProps) => {
215+
const LivestreamChat = ({
216+
channel,
217+
focusOutsideMessageInput,
218+
}: LivestreamChatProps) => {
219+
const { shouldHandleKeyboardEvents } = useBottomSheetInternal();
220+
221+
/**
222+
* Done as per the text input behaviour from BottomSheetTextInput(https://github.com/gorhom/react-native-bottom-sheet/blob/master/src/components/bottomSheetTextInput/BottomSheetTextInput.tsx)
223+
* to solve the issue around keyboard hiding the text input in the chat inside bottom sheet.
224+
* The tip in https://ui.gorhom.dev/components/bottom-sheet/keyboard-handling/ is followed.
225+
*/
226+
useEffect(() => {
227+
return () => {
228+
// Reset the flag on unmount
229+
shouldHandleKeyboardEvents.value = false;
230+
};
231+
}, [shouldHandleKeyboardEvents]);
232+
214233
return (
215234
<View style={styles.chatContainer}>
216235
<Channel
217-
// // On Android, the default behaviour is as expected so we do not need to apply the fix to the text input to work with keyboard.
218-
// additionalTextInputProps={
219-
// Platform.OS === 'ios'
220-
// ? {
221-
// // Done as per https://ui.gorhom.dev/components/bottom-sheet/keyboard-handling/ to solve keyboard hiding the text input in the chat inside bottom sheet.
222-
// onBlur: () => {
223-
// shouldHandleKeyboardEvents.value = false;
224-
// focusOutsideMessageInput();
225-
// },
226-
// onFocus: () => {
227-
// shouldHandleKeyboardEvents.value = true;
228-
// },
229-
// }
230-
// : {}
231-
// }
236+
// On Android, the default behaviour is as expected so we do not need to apply the fix to the text input to work with keyboard.
237+
additionalTextInputProps={
238+
Platform.OS === 'ios'
239+
? {
240+
// Done as per https://ui.gorhom.dev/components/bottom-sheet/keyboard-handling/ to solve keyboard hiding the text input in the chat inside bottom sheet.
241+
onBlur: () => {
242+
shouldHandleKeyboardEvents.value = false;
243+
focusOutsideMessageInput();
244+
},
245+
onFocus: () => {
246+
shouldHandleKeyboardEvents.value = true;
247+
},
248+
}
249+
: {}
250+
}
232251
// Hides the sticky date header component on the top of the MessageList
233252
hideStickyDateHeader={true}
234253
channel={channel}

sample-apps/react-native/dogfood/src/screens/Meeting/ChatScreen.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { AuthenticationProgress } from '../../components/AuthenticatingProgress'
1717
import { Channel as ChannelType } from 'stream-chat';
1818
import { MeetingStackParamList } from '../../../types';
1919
import { NativeStackScreenProps } from '@react-navigation/native-stack';
20-
import { useI18n, useTheme } from '@stream-io/video-react-native-sdk';
20+
import { useTheme } from '@stream-io/video-react-native-sdk';
2121
import {
2222
useAppGlobalStoreSetState,
2323
useAppGlobalStoreValue,
@@ -33,7 +33,6 @@ const ChannelHeader = () => {
3333
const chatLabelNoted = useAppGlobalStoreValue(
3434
(store) => store.chatLabelNoted,
3535
);
36-
const { t } = useI18n();
3736
const appStoreSetState = useAppGlobalStoreSetState();
3837
const [isNoted, setIsNoted] = useState<boolean>(!!chatLabelNoted);
3938

@@ -44,10 +43,8 @@ const ChannelHeader = () => {
4443
return (
4544
<View style={styles.header}>
4645
<Text style={styles.headerText}>
47-
ℹ️{' '}
48-
{t(
49-
'Messages are currently visible to anyone with the link and valid session.',
50-
)}
46+
ℹ️ Messages are currently visible to anyone with the link and valid
47+
session.
5148
</Text>
5249
<Pressable
5350
style={styles.notedButton}
@@ -56,7 +53,7 @@ const ChannelHeader = () => {
5653
appStoreSetState({ chatLabelNoted: true });
5754
}}
5855
>
59-
<Text style={styles.notedButtonText}>{t('Noted')}</Text>
56+
<Text style={styles.notedButtonText}>Noted</Text>
6057
</Pressable>
6158
</View>
6259
);
@@ -81,8 +78,8 @@ export const ChatScreen = ({ route }: ChatScreenProps) => {
8178

8279
return (
8380
<SafeAreaView>
84-
<StatusBar barStyle={'light-content'} />
85-
<Channel channel={channel}>
81+
<StatusBar barStyle="default" />
82+
<Channel channel={channel} keyboardVerticalOffset={120}>
8683
<ChannelHeader />
8784
<MessageList />
8885
<MessageInput />

0 commit comments

Comments
 (0)