Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add more space to bottom docked button #44761

Merged
merged 17 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/FormAlertWithSubmitButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {View} from 'react-native';
import useExtraSafePaddingBottomStyle from '@hooks/useExtraSafePaddingBottomStyle';
import useThemeStyles from '@hooks/useThemeStyles';
import Button from './Button';
import FormAlertWrapper from './FormAlertWrapper';
Expand Down Expand Up @@ -79,10 +80,11 @@ function FormAlertWithSubmitButton({
}: FormAlertWithSubmitButtonProps) {
const styles = useThemeStyles();
const style = [!footerContent ? {} : styles.mb3, buttonStyles];
const extraSafePaddingBottomStyle = useExtraSafePaddingBottomStyle();

return (
<FormAlertWrapper
containerStyles={[styles.justifyContentEnd, containerStyles]}
containerStyles={[styles.justifyContentEnd, extraSafePaddingBottomStyle, containerStyles]}
isAlertVisible={isAlertVisible}
isMessageHtml={isMessageHtml}
message={message}
Expand Down
34 changes: 34 additions & 0 deletions src/hooks/useExtraSafePaddingBottomStyle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {useEffect, useMemo, useState} from 'react';
import {Keyboard} from 'react-native';
import useStyledSafeAreaInsets from './useStyledSafeAreaInsets';
import useThemeStyles from './useThemeStyles';

const useExtraSafePaddingBottomStyle = () => {
const styles = useThemeStyles();
const [willKeyboardShow, setWillKeyboardShow] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you typecast the boolean type of the variable and also rename the variable to something more readable like:

isKeyboardVisible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the type for it. But I don't think we should rename the state, because as I mentioned above, willKeyboardShow is used to fix the issue didKeyboardShow encountered: There is a delay when the keyboard is visible by the user and the when didKeyboardShow is set to true. So it is not just isKeyboardVisible.

useEffect(() => {
const keyboardWillShowListener = Keyboard.addListener('keyboardWillShow', () => {
setWillKeyboardShow(true);
});
const keyboardWillHideListener = Keyboard.addListener('keyboardWillHide', () => {
setWillKeyboardShow(false);
});
return () => {
keyboardWillShowListener.remove();
keyboardWillHideListener.remove();
};
}, []);

const {paddingBottom} = useStyledSafeAreaInsets();

const extraPaddingBottomStyle = useMemo(() => {
// Do not add extra padding at the bottom if the keyboard is open or if there is no safe area bottom padding style.
if (willKeyboardShow || !paddingBottom) {
return {};
}
return styles.pb5;
}, [willKeyboardShow, paddingBottom, styles.pb5]);
return extraPaddingBottomStyle;
};

export default useExtraSafePaddingBottomStyle;
1 change: 1 addition & 0 deletions src/pages/iou/request/step/IOURequestStepDate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function IOURequestStepDate({
shouldShowNotFoundPage={shouldShowNotFound}
shouldShowWrapper
testID={IOURequestStepDate.displayName}
includeSafeAreaPaddingBottom={false}
>
<FormProvider
style={[styles.flexGrow1, styles.ph5]}
Expand Down
Loading