feat(chat) keyboard covering input on android fix

This commit is contained in:
Calin Chitu 2021-12-08 16:35:20 +02:00 committed by Calinteodor
parent 661a3d34be
commit 5dbf4845fb
3 changed files with 20 additions and 3 deletions

View File

@ -4,7 +4,8 @@ import { useHeaderHeight } from '@react-navigation/stack';
import React, { useEffect, useState } from 'react';
import {
KeyboardAvoidingView,
Platform
Platform,
StatusBar
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
@ -22,6 +23,11 @@ type Props = {
*/
contentContainerStyle?: StyleType,
/**
* Is a text input rendered at the bottom of the screen?
*/
hasBottomTextInput: boolean,
/**
* Is the screen rendering a tab navigator?
*/
@ -38,6 +44,7 @@ const JitsiKeyboardAvoidingView = (
children,
contentContainerStyle,
hasTabNavigator,
hasBottomTextInput,
style
}: Props) => {
const headerHeight = useHeaderHeight();
@ -54,8 +61,10 @@ const JitsiKeyboardAvoidingView = (
const tabNavigatorPadding
= hasTabNavigator ? headerHeight : 0;
const noNotchDevicePadding = bottomPadding || 10;
const iosVerticalOffset = headerHeight + noNotchDevicePadding + tabNavigatorPadding;
const androidVerticalOffset = headerHeight;
const iosVerticalOffset
= headerHeight + noNotchDevicePadding + tabNavigatorPadding;
const androidVerticalOffset = hasBottomTextInput
? headerHeight + StatusBar.currentHeight : headerHeight;
return (
<KeyboardAvoidingView

View File

@ -27,6 +27,11 @@ type Props = {
*/
footerComponent?: Function,
/**
* Is a text input rendered at the bottom of the screen?
*/
hasBottomTextInput?: boolean,
/**
* Is the screen rendering a tab navigator?
*/
@ -43,12 +48,14 @@ const JitsiScreen = ({
children,
footerComponent,
hasTabNavigator = false,
hasBottomTextInput = false,
style
}: Props) => (
<View
style = { styles.jitsiScreenContainer }>
<JitsiKeyboardAvoidingView
contentContainerStyle = { contentContainerStyle }
hasBottomTextInput = { hasBottomTextInput }
hasTabNavigator = { hasTabNavigator }
style = { style }>
<SafeAreaView

View File

@ -53,6 +53,7 @@ class Chat extends AbstractChat<Props> {
return (
<JitsiScreen
hasBottomTextInput = { true }
hasTabNavigator = { true }
style = { styles.chatContainer }>
<MessageContainer messages = { _messages } />