@@ -126,10 +126,11 @@ interface SceneWrapperProps {
126126 // True to make the scene scrolling (if avoidKeyboard is false):
127127 scroll ?: boolean
128128
129- // Optional KeyboardAccessoryView rendered as a sibling to the SceneWrapper content:
130- kavProps ?: {
129+ // Optional "dock" view rendered at the bottom of the scene, attached to the
130+ // keyboard, tabs, footer, etc, whatever is highest:
131+ dockProps ?: {
131132 children : React . ReactNode
132- alwaysVisible ?: boolean
133+ keyboardVisibleOnly ?: boolean
133134 contentContainerStyle ?: ViewStyle
134135 }
135136}
@@ -162,7 +163,7 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
162163 padding = 0 ,
163164 renderFooter,
164165 scroll = false ,
165- kavProps
166+ dockProps
166167 } = props
167168
168169 const notificationHeight = useSelector ( state => state . ui . notificationHeight )
@@ -179,47 +180,32 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
179180 }
180181 } )
181182
182- // Local keyboard visible state for KAV parity (iOS willShow vs Android didShow):
183- const [ isKeyboardVisibleFull , setKeyboardVisibleKav ] = useState ( false )
184- useEffect ( ( ) => {
185- const keyboardDidShowListener = Keyboard . addListener (
186- isIos ? 'keyboardWillShow' : 'keyboardDidShow' ,
187- ( ) => {
188- setKeyboardVisibleKav ( true )
189- }
190- )
191- const keyboardDidHideListener = Keyboard . addListener (
192- isIos ? 'keyboardWillHide' : 'keyboardDidHide' ,
193- ( ) => {
194- setKeyboardVisibleKav ( false )
195- }
196- )
197- return ( ) => {
198- keyboardDidShowListener . remove ( )
199- keyboardDidHideListener . remove ( )
200- }
201- } , [ isIos ] )
202-
183+ // Local keyboard opening/closing start/end state for dock parity between iOS
184+ // and Android. `keyboardWillShow`/`keyboardDidShow` mean different things on
185+ // each platform:
186+ const [ isKeyboardVisibleDock , setKeyboardVisibleDock ] = useState ( false )
203187 // Track closing/opening state explicitly for animation direction:
204188 const isClosingSv = useSharedValue ( false )
205189 useEffect ( ( ) => {
206- const showListener = Keyboard . addListener (
207- isIos ? 'keyboardWillShow ' : 'keyboardDidShow' ,
208- ( ) => {
209- isClosingSv . value = false
210- }
211- )
212- const hideListener = Keyboard . addListener (
213- isIos ? 'keyboardWillHide' : 'keyboardDidHide' ,
214- ( ) => {
215- isClosingSv . value = true
216- }
217- )
190+ const showEvent = isIos ? 'keyboardWillShow' : 'keyboardDidShow'
191+ const hideEvent = isIos ? 'keyboardWillHide ' : 'keyboardDidHide'
192+ const onShow = ( ) : void => {
193+ setKeyboardVisibleDock ( true )
194+ isClosingSv . value = false
195+ }
196+ const onHide = ( ) : void => {
197+ setKeyboardVisibleDock ( false )
198+ isClosingSv . value = true
199+ }
200+ const showListener = Keyboard . addListener ( showEvent , onShow )
201+ const hideListener = Keyboard . addListener ( hideEvent , onHide )
218202 return ( ) => {
219203 showListener . remove ( )
220204 hideListener . remove ( )
221205 }
222- } , [ isIos , isClosingSv ] )
206+ // No need to depend on `isClosingSv` since it's a shared value
207+ // eslint-disable-next-line react-hooks/exhaustive-deps
208+ } , [ isIos ] )
223209
224210 // Reset the footer ratio when focused
225211 // We can do this because multiple calls to resetFooterRatio isn't costly
@@ -341,9 +327,9 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
341327 return children
342328 } , [ children , sceneWrapperInfo ] )
343329
344- // Build Keyboard Accessory View element
345- const alwaysVisibleKav = kavProps ?. alwaysVisible === true
346- const kavBaseStyle = useMemo (
330+ // Build Dock View element
331+ const keyboardVisibleOnlyDoc = dockProps ?. keyboardVisibleOnly ?? true
332+ const dockBaseStyle = useMemo (
347333 ( ) => ( {
348334 position : 'absolute' as const ,
349335 left : 0 ,
@@ -359,7 +345,7 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
359345 insetBottomSv . value = insets . bottom
360346 collapsedInsetSv . value = collapsedInsetBottom
361347 } , [ collapsedInsetBottom , insets . bottom , collapsedInsetSv , insetBottomSv ] )
362- const kavAnimatedStyle = useAnimatedStyle ( ( ) => {
348+ const dockAnimatedStyle = useAnimatedStyle ( ( ) => {
363349 // keyboardHeightDiff.value is negative when open; invert to get height
364350 const keyboardHeight =
365351 keyboardHeightDiff . value < 0 ? - keyboardHeightDiff . value : 0
@@ -379,13 +365,17 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
379365
380366 return { bottom }
381367 } )
382- const shouldShowKav =
383- kavProps != null && ( alwaysVisibleKav || isKeyboardVisibleFull )
384- const kavElement = ! shouldShowKav ? null : (
368+ const shouldShowDock =
369+ dockProps != null && ( ! keyboardVisibleOnlyDoc || isKeyboardVisibleDock )
370+ const dockElement = ! shouldShowDock ? null : (
385371 < Reanimated . View
386- style = { [ kavBaseStyle , kavAnimatedStyle , kavProps ?. contentContainerStyle ] }
372+ style = { [
373+ dockBaseStyle ,
374+ dockAnimatedStyle ,
375+ dockProps ?. contentContainerStyle
376+ ] }
387377 >
388- { kavProps ?. children }
378+ { dockProps ?. children }
389379 </ Reanimated . View >
390380 )
391381
@@ -422,7 +412,7 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
422412 navigation = { navigation }
423413 />
424414 ) : null }
425- { kavElement }
415+ { dockElement }
426416 < FloatingNavFixer navigation = { navigation } />
427417 </ >
428418 )
@@ -465,7 +455,7 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
465455 navigation = { navigation }
466456 />
467457 ) : null }
468- { kavElement }
458+ { dockElement }
469459 < FloatingNavFixer navigation = { navigation } />
470460 </ >
471461 )
@@ -501,7 +491,7 @@ function SceneWrapperComponent(props: SceneWrapperProps): React.ReactElement {
501491 navigation = { navigation }
502492 />
503493 ) : null }
504- { kavElement }
494+ { dockElement }
505495 < FloatingNavFixer navigation = { navigation } />
506496 </ >
507497 )
0 commit comments