1
1
import React , { useEffect , useMemo , useState } from 'react' ;
2
2
import {
3
- Keyboard ,
4
3
KeyboardAvoidingView ,
5
4
Platform ,
6
5
StyleProp ,
@@ -95,12 +94,7 @@ export type ChannelInputProps = {
95
94
} ;
96
95
97
96
const AUTO_FOCUS = Platform . select ( { ios : false , android : true , default : false } ) ;
98
- const isAndroidApi35Plus = Platform . OS === 'android' && Platform . Version >= 35 ;
99
- const KEYBOARD_AVOID_VIEW_BEHAVIOR = Platform . select ( {
100
- ios : 'padding' as const ,
101
- android : isAndroidApi35Plus ? ( 'padding' as const ) : undefined ,
102
- default : undefined ,
103
- } ) ;
97
+ const KEYBOARD_AVOID_VIEW_BEHAVIOR = Platform . select ( { ios : 'padding' as const , default : undefined } ) ;
104
98
105
99
// FIXME(iOS): Dynamic style does not work properly when typing the CJK. (https://github.com/facebook/react-native/issues/26107)
106
100
// To workaround temporarily, change the key for re-mount the component.
@@ -115,16 +109,6 @@ const ChannelInput = (props: ChannelInputProps) => {
115
109
116
110
const safeArea = useSafeAreaPadding ( [ 'top' , 'left' , 'right' , 'bottom' ] ) ;
117
111
118
- // Android API 35+ keyboard avoidance handling
119
- /**
120
- * Android API 35+ introduced edge-to-edge layouts, which changed how keyboard avoidance should be handled.
121
- * For API 35+, the system manages insets automatically, so we use the provided keyboardAvoidOffset directly.
122
- * For older Android versions, we manually subtract the safe area bottom padding to avoid overlapping with system UI.
123
- * See: https://developer.android.com/develop/ui/views/layout/edge-to-edge
124
- */
125
- const keyboardVerticalOffset = isAndroidApi35Plus
126
- ? keyboardAvoidOffset
127
- : - safeArea . paddingBottom + keyboardAvoidOffset ;
128
112
const { colors, typography } = useUIKitTheme ( ) ;
129
113
const { sbOptions, mentionManager } = useSendbirdChat ( ) ;
130
114
@@ -161,30 +145,16 @@ const ChannelInput = (props: ChannelInputProps) => {
161
145
onChangeText ( replace ( text , searchStringRange . start , searchStringRange . end , mentionedMessageText ) , { user, range } ) ;
162
146
} ;
163
147
164
- const [ keyboardShown , setKeyboardShown ] = useState ( false ) ;
165
-
166
- useEffect ( ( ) => {
167
- const keyboardDidShow = ( ) => setKeyboardShown ( true ) ;
168
- const keyboardDidHide = ( ) => setKeyboardShown ( false ) ;
169
-
170
- const showSubscription = Keyboard . addListener ( 'keyboardDidShow' , keyboardDidShow ) ;
171
- const hideSubscription = Keyboard . addListener ( 'keyboardDidHide' , keyboardDidHide ) ;
172
-
173
- return ( ) => {
174
- showSubscription . remove ( ) ;
175
- hideSubscription . remove ( ) ;
176
- } ;
177
- } , [ ] ) ;
178
-
179
- const shouldShowSafeAreaBottom = ! isAndroidApi35Plus || ( isAndroidApi35Plus && ! keyboardShown ) ;
180
-
181
148
if ( ! props . shouldRenderInput ) {
182
149
return < SafeAreaBottom height = { safeArea . paddingBottom } /> ;
183
150
}
184
151
185
152
return (
186
153
< >
187
- < KeyboardAvoidingView keyboardVerticalOffset = { keyboardVerticalOffset } behavior = { KEYBOARD_AVOID_VIEW_BEHAVIOR } >
154
+ < KeyboardAvoidingView
155
+ keyboardVerticalOffset = { - safeArea . paddingBottom + keyboardAvoidOffset }
156
+ behavior = { KEYBOARD_AVOID_VIEW_BEHAVIOR }
157
+ >
188
158
< View
189
159
style = { {
190
160
paddingStart : safeArea . paddingStart ,
@@ -224,7 +194,7 @@ const ChannelInput = (props: ChannelInputProps) => {
224
194
/>
225
195
) }
226
196
</ View >
227
- { shouldShowSafeAreaBottom && < SafeAreaBottom height = { safeArea . paddingBottom } /> }
197
+ < SafeAreaBottom height = { safeArea . paddingBottom } />
228
198
</ View >
229
199
</ KeyboardAvoidingView >
230
200
{ mentionAvailable && props . SuggestedMentionList && (
0 commit comments