Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(modal): fixes around JitsiScreen footer (#17041)

Calinteodorb6d89b0939f2
diff --git a/react/features/base/modal/components/JitsiScreen.tsx b/react/features/base/modal/components/JitsiScreen.tsx
index 312c322655..3c2c12c74d 100644
--- a/react/features/base/modal/components/JitsiScreen.tsx
+++ b/react/features/base/modal/components/JitsiScreen.tsx
@@ -3,6 +3,8 @@ import { View } from 'react-native';
import { Edge, SafeAreaView } from 'react-native-safe-area-context';
import { StyleType } from '../../styles/functions.any';
+import BaseTheme from '../../ui/components/BaseTheme.native';
+import { useKeyboardVisible } from '../hooks.native';
import JitsiKeyboardAvoidingView from './JitsiKeyboardAvoidingView';
import styles from './styles';
@@ -34,6 +36,11 @@ interface IProps {
*/
footerComponent?: Function;
+ /**
+ * Extra bottom padding applied to the footer when keyboard is visible.
+ */
+ footerKeyboardSpacing?: number;
+
/**
* Is a text input rendered at the bottom of the screen?
*/
@@ -61,11 +68,14 @@ const JitsiScreen = ({
children,
disableForcedKeyboardDismiss = false,
footerComponent,
+ footerKeyboardSpacing = BaseTheme.spacing[4],
hasBottomTextInput = false,
hasExtraHeaderHeight = false,
safeAreaInsets = [ 'bottom', 'left', 'right' ],
style
}: IProps) => {
+ const keyboardVisible = useKeyboardVisible();
+
const renderContent = () => (
<JitsiKeyboardAvoidingView
addBottomPadding = { addBottomPadding }
@@ -78,7 +88,11 @@ const JitsiScreen = ({
edges = { safeAreaInsets }
style = { styles.safeArea }>
{ children }
- { footerComponent?.() }
+ { footerComponent && (
+ <View style = { keyboardVisible && { paddingBottom: footerKeyboardSpacing } }>
+ { footerComponent() }
+ </View>
+ ) }
</SafeAreaView>
</JitsiKeyboardAvoidingView>
);
diff --git a/react/features/base/modal/hooks.native.ts b/react/features/base/modal/hooks.native.ts
new file mode 100644
index 0000000000..062b36f761
--- /dev/null
+++ b/react/features/base/modal/hooks.native.ts
@@ -0,0 +1,26 @@
+import { useEffect, useState } from 'react';
+import { Keyboard, Platform } from 'react-native';
+
+const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
+const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
+
+/**
+ * A hook that tracks whether the native keyboard is visible.
+ *
+ * @returns {boolean} - Whether the keyboard is visible.
+ */
+export const useKeyboardVisible = (): boolean => {
+ const [ keyboardVisible, setKeyboardVisible ] = useState(false);
+
+ useEffect(() => {
+ const showSub = Keyboard.addListener(showEvent, () => setKeyboardVisible(true));
+ const hideSub = Keyboard.addListener(hideEvent, () => setKeyboardVisible(false));
+
+ return () => {
+ showSub.remove();
+ hideSub.remove();
+ };
+ }, []);
+
+ return keyboardVisible;
+};
diff --git a/react/features/chat/components/native/styles.ts b/react/features/chat/components/native/styles.ts
index 20fed0d74c..d86121f8b8 100644
--- a/react/features/chat/components/native/styles.ts
+++ b/react/features/chat/components/native/styles.ts
@@ -137,7 +137,7 @@ export default {
* A special padding to avoid issues on some devices (such as Android devices with custom suggestions bar).
*/
extraBarPadding: {
- paddingBottom: BaseTheme.spacing[8]
+ paddingBottom: BaseTheme.spacing[6]
},
inputBar: {
@@ -147,12 +147,12 @@ export default {
},
sendButton: {
- marginRight: BaseTheme.spacing[5],
+ marginRight: BaseTheme.spacing[4],
marginLeft: BaseTheme.spacing[2]
},
customInputContainer: {
- marginLeft: BaseTheme.spacing[5],
+ marginLeft: BaseTheme.spacing[4],
flex: 1
},
diff --git a/react/features/polls/components/native/PollCreate.tsx b/react/features/polls/components/native/PollCreate.tsx
index 25431ff220..d14f689780 100644
--- a/react/features/polls/components/native/PollCreate.tsx
+++ b/react/features/polls/components/native/PollCreate.tsx
@@ -1,8 +1,10 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
-import { FlatList, SafeAreaView, TextInput, View, ViewStyle } from 'react-native';
+import { FlatList, Platform, SafeAreaView, TextInput, View, ViewStyle } from 'react-native';
import { Divider } from 'react-native-paper';
import { useDispatch } from 'react-redux';
+import { useKeyboardVisible } from '../../../base/modal/hooks.native';
+import BaseTheme from '../../../base/ui/components/BaseTheme.native';
import Button from '../../../base/ui/components/native/Button';
import Input from '../../../base/ui/components/native/Input';
import { BUTTON_TYPES } from '../../../base/ui/constants.native';
@@ -30,6 +32,7 @@ const PollCreate = (props: AbstractProps) => {
const answerListRef = useRef<FlatList>(null);
const dispatch = useDispatch();
+ const keyboardVisible = Platform.OS === 'android' && useKeyboardVisible();
/*
* This ref stores the Array of answer input fields, allowing us to focus on them.
@@ -166,7 +169,11 @@ const PollCreate = (props: AbstractProps) => {
keyExtractor = { (item, index) => index.toString() }
ref = { answerListRef }
renderItem = { renderListItem } />
- <View style = { pollsStyles.pollCreateButtonsContainer as ViewStyle }>
+ <View
+ style = { [
+ pollsStyles.pollCreateButtonsContainer,
+ keyboardVisible && { marginBottom: BaseTheme.spacing[8] }
+ ] as ViewStyle[] }>
<Button
accessibilityLabel = 'polls.create.addOption'
disabled = { answers.length >= ANSWERS_LIMIT }
diff --git a/react/features/polls/components/native/styles.ts b/react/features/polls/components/native/styles.ts
index e8427cd6cb..7bcfbf489c 100644
--- a/react/features/polls/components/native/styles.ts
+++ b/react/features/polls/components/native/styles.ts
@@ -11,32 +11,32 @@ export const dialogStyles = createStyleSheet({
},
customContainer: {
- marginBottom: BaseTheme.spacing[3],
- marginHorizontal: BaseTheme.spacing[3],
+ marginBottom: BaseTheme.spacing[4],
+ marginHorizontal: BaseTheme.spacing[4],
marginTop: BaseTheme.spacing[2]
},
questionText: {
...BaseTheme.typography.bodyShortBold,
color: BaseTheme.palette.text01,
- marginLeft: BaseTheme.spacing[1]
+ marginLeft: BaseTheme.spacing[2]
},
questionOwnerText: {
...BaseTheme.typography.bodyShortBold,
color: BaseTheme.palette.text03,
- marginBottom: BaseTheme.spacing[2],
- marginLeft: BaseTheme.spacing[1]
+ marginBottom: BaseTheme.spacing[4],
+ marginLeft: BaseTheme.spacing[2]
},
optionContainer: {
flexDirection: 'column',
- marginTop: BaseTheme.spacing[3],
- marginHorizontal: BaseTheme.spacing[3]
+ marginTop: BaseTheme.spacing[4],
+ marginHorizontal: BaseTheme.spacing[4]
},
optionRemoveButton: {
- width: 128
+ width: 136
},
optionRemoveButtonText: {
@@ -50,8 +50,8 @@ export const dialogStyles = createStyleSheet({
color: BaseTheme.palette.text01,
fontSize: 14,
paddingBottom: BaseTheme.spacing[2],
- paddingLeft: BaseTheme.spacing[3],
- paddingRight: BaseTheme.spacing[3],
+ paddingLeft: BaseTheme.spacing[4],
+ paddingRight: BaseTheme.spacing[4],
paddingTop: BaseTheme.spacing[2]
}
});
@@ -91,8 +91,8 @@ export const resultsStyles = createStyleSheet({
},
answerContainer: {
- marginHorizontal: BaseTheme.spacing[1],
- marginVertical: BaseTheme.spacing[3],
+ marginHorizontal: BaseTheme.spacing[2],
+ marginVertical: BaseTheme.spacing[4],
maxWidth: '100%'
},
@@ -146,7 +146,7 @@ export const pollsStyles = createStyleSheet({
boxShadow: BaseTheme.shape.boxShadow,
borderWidth: 1,
padding: BaseTheme.spacing[2],
- margin: BaseTheme.spacing[3]
+ margin: BaseTheme.spacing[2]
},
pollCreateContainer: {
@@ -154,12 +154,11 @@ export const pollsStyles = createStyleSheet({
},
pollCreateSubContainer: {
- flex: 1,
- marginTop: BaseTheme.spacing[3]
+ flex: 1
},
pollCreateButtonsContainer: {
- marginHorizontal: BaseTheme.spacing[3]
+ marginHorizontal: BaseTheme.spacing[2]
},
pollSendLabel: {
@@ -191,12 +190,12 @@ export const pollsStyles = createStyleSheet({
},
pollCreateAddButton: {
- marginHorizontal: BaseTheme.spacing[1],
+ marginHorizontal: BaseTheme.spacing[2],
marginVertical: BaseTheme.spacing[2]
},
pollCreateButton: {
- marginHorizontal: BaseTheme.spacing[1],
+ marginHorizontal: BaseTheme.spacing[2],
flex: 1
},
@@ -205,7 +204,7 @@ export const pollsStyles = createStyleSheet({
},
createPollButton: {
- marginHorizontal: BaseTheme.spacing[5],
+ marginHorizontal: BaseTheme.spacing[4],
},
pollPane: {
@@ -221,12 +220,12 @@ export const pollsStyles = createStyleSheet({
bottomLinks: {
flexDirection: 'row',
justifyContent: 'space-between',
- marginHorizontal: BaseTheme.spacing[1]
+ marginHorizontal: BaseTheme.spacing[2]
},
fieldSeparator: {
borderBottomWidth: 1,
borderColor: BaseTheme.palette.ui05,
- marginTop: BaseTheme.spacing[3]
+ marginTop: BaseTheme.spacing[2]
}
});