-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
45ce16e
Fix: Add more space to bottom docked button
truph01 731fce3
Fix: IOU request step screen
truph01 0385749
Fix: Remove additional padding bottom if keyboard is shown
truph01 6f1fe83
Fix: Lint
truph01 b1d80d2
Fix: Create useExtraSafePaddingBottomStyle
truph01 01f07a2
Fix: Merge main
truph01 1a12356
Fix: extraPaddingBottomStyle logic
truph01 abeea96
Fix: Move extra padding bottom to FormAlertWithSubmitButton
truph01 1a62cc3
Fix: Remove unsed changes
truph01 d38e7cb
Fix: Lint
truph01 7154df6
Feat: Merge maiin
truph01 b4d5e09
Feat: Add typeto state
truph01 4561a85
Merge branch 'Expensify:main' into fix/44056
truph01 66d446f
merge main
truph01 bd01400
Feat: Rename useExtraSafePaddingBottomStyle to useSafePaddingBottomStyle
truph01 0f06221
Feat: Add comment to hooks and rename variable
truph01 b2844e0
Update comment src/hooks/useSafePaddingBottomStyle.ts
truph01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {useEffect, useMemo, useState} from 'react'; | ||
import {Keyboard} from 'react-native'; | ||
import useStyledSafeAreaInsets from './useStyledSafeAreaInsets'; | ||
import useThemeStyles from './useThemeStyles'; | ||
|
||
// This hook is useful for adding extra bottom padding to a component based on the device's safe area | ||
// If the device's safe area padding bottom is 0, the hook returns 0. Otherwise, it provides a padding bottom of 20. | ||
// Use this to ensure content visibility and layout consistency across different devices. | ||
const useSafePaddingBottomStyle = () => { | ||
const styles = useThemeStyles(); | ||
const [willKeyboardShow, setWillKeyboardShow] = useState<boolean>(false); | ||
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 useSafePaddingBottomStyle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some general documentation above about what this hook is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for being a stickler, but I'm finding this comment a bit hard to follow. In the future, when should someone use this hook? Maybe if you can just explain that to me in words in a comment here, I can help you craft a code comment that is a bit more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with you @puneetlath , @truph01 can you please follow up with this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@puneetlath
This hook, useSafePaddingBottomStyle, is useful for adding extra bottom padding to a component based on the device's safe area. If the device's safe area padding bottom is 0, the hook returns 0. Otherwise, it provides a padding bottom of 20. Use this to ensure content visibility and layout consistency across different devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's beautiful. Very clear! Let's make that the comment.