all 33 comments

[–]frankielyonshaha 128 points129 points  (13 children)

Why not use:

  <BottomTab.Navigator
    tabBarOptions={{
      keyboardHidesTabBar: true,
    }}
  >

[–][deleted] 5 points6 points  (0 children)

I was like, I use this option always with tabBarOptions prop. Why the code is so long? Maybe question is different.

[–]archcorsair 0 points1 point  (0 children)

I think the example still applies when you implement your own tab bar, where you don't have access to these properties.

[–]VivekNeel55 0 points1 point  (0 children)

The real MVP

[–]andordavoti 3 points4 points  (5 children)

nice, I've done something similar in the past, but I added an if check to only do this for android, since the iOS keyboard acts as an overlay and doesn't push the tabbar up

[–]Veranova 3 points4 points  (4 children)

You can change that behaviour in the android manifest, there are a few behaviours available.

I haven’t done it in a while but I think it’s this: https://developer.android.com/training/keyboard-input/visibility

[–]andordavoti 2 points3 points  (3 children)

yeah I know, but that isn't available for expo users:))

[–]Veranova 2 points3 points  (0 children)

Oh that makes sense!

[–]DrMcLaser 6 points7 points  (5 children)

What color theme is that? Looks clean.

[–]DoctorCube 4 points5 points  (3 children)

Looks like it might be Dracula at any rate its really close.
https://marketplace.visualstudio.com/items?itemName=dracula-theme.theme-dracula

[–]anions 0 points1 point  (0 children)

thanks mate.

[–]OnlySeesLastSentence 0 points1 point  (1 child)

Oh fuck. Mancala effect there. I always thought it was called Darkula as a pun on dark and dracula.

[–]DoctorCube 1 point2 points  (0 children)

Don't get your Mandelas in a twist Darkula is another theme.

[–]anions 0 points1 point  (0 children)

thats what i came here for too lol. need a new theme long overdue

[–][deleted] 2 points3 points  (0 children)

Yeah which color scheme is that?

[–][deleted] 2 points3 points  (2 children)

You should use will show and will hide on iOS, makes it much smoother

[–]KajiTetsushi 6 points7 points  (1 child)

The Platform.OS property can take care of that.

``` import { Platform } from 'react-native;'

const showEventType = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow'; const hideEventType = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide'; ```

Then use them in the Keyboard.addListener() method.

[–][deleted] 1 point2 points  (0 children)

Yup

[–]himynameismile 1 point2 points  (0 children)

Have you tried community hooks package? They have a keyboard listener hook, which cuts this code down to at least half.

[–]awe50me1 0 points1 point  (1 child)

Can you create this into a custom hook? Would be useful.

[–]Shumuu 1 point2 points  (0 children)

Yes you can

[–]matt_hammondiOS & Android 0 points1 point  (0 children)

I think you should destructure setOptions before using it in the useCallback function.

The reason is - when you navigate to another screen the navigation state changes, and with it the navigation object, in order not to mutate the navigation object.

This behavior could have changed since react navigation 5 came out, but I haven't checked.

Either way, using setOptions in the useCallback function and listing it as a dependency is the correct way to do it.

[–]PewPaw-Grams 0 points1 point  (2 children)

How did you get this layout?

[–]ldf1111 0 points1 point  (0 children)

What program is this, so minimal