r/reactnative • u/Chawki_ Android • Sep 20 '20
Programmatically Hide Bottom tab when keyboard open.
4
u/andordavoti Sep 20 '20
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
4
u/Veranova Sep 20 '20
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
3
u/andordavoti Sep 20 '20
yeah I know, but that isn't available for expo users:))
4
u/brentvatne Expo Team Sep 20 '20
2
3
1
3
3
Sep 20 '20
You should use will show and will hide on iOS, makes it much smoother
6
u/KajiTetsushi Sep 20 '20
The
Platform.OSproperty 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.2
2
u/himynameismile Sep 20 '20
Have you tried community hooks package? They have a keyboard listener hook, which cuts this code down to at least half.
1
u/matt_hammond iOS & Android Sep 20 '20
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.
1
0
7
Sep 20 '20
[removed] — view removed comment
5
u/DoctorCube Sep 20 '20
Looks like it might be Dracula at any rate its really close.
https://marketplace.visualstudio.com/items?itemName=dracula-theme.theme-dracula1
1
u/OnlySeesLastSentence Sep 20 '20
Oh fuck. Mancala intentionaljoke effect there. I always thought it was called Darkula as a pun on dark and dracula.
2
1
129
u/frankielyonshaha Sep 20 '20
Why not use: