-
-
Notifications
You must be signed in to change notification settings - Fork 921
feat: added dynamic sizing #1513
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
06f1aae
feat: added dynamic sizing
gorhom b7fa9d1
chore: updated dynamic sizing example
gorhom 50cade7
chore: removed commented code
gorhom 8e4fb9a
chore: added deprecated tag to useBottomSheetDynamicSnapPoints
gorhom b481106
chore: added extra description for snap points prop
gorhom 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import { | |
| useScrollHandler, | ||
| useScrollableSetter, | ||
| useBottomSheetInternal, | ||
| useStableCallback, | ||
| } from '../../hooks'; | ||
| import { | ||
| GESTURE_SOURCE, | ||
|
|
@@ -41,6 +42,7 @@ export function createBottomSheetScrollableComponent<T, P>( | |
| onScroll, | ||
| onScrollBeginDrag, | ||
| onScrollEndDrag, | ||
| onContentSizeChange, | ||
| ...rest | ||
| }: any = props; | ||
|
|
||
|
|
@@ -61,6 +63,7 @@ export function createBottomSheetScrollableComponent<T, P>( | |
| enableContentPanningGesture, | ||
| animatedFooterHeight, | ||
| animatedScrollableState, | ||
| animatedContentHeight, | ||
| } = useBottomSheetInternal(); | ||
| //#endregion | ||
|
|
||
|
|
@@ -77,6 +80,18 @@ export function createBottomSheetScrollableComponent<T, P>( | |
| ); | ||
| //#endregion | ||
|
|
||
| //#region callbacks | ||
| const handleContentSizeChange = useStableCallback( | ||
| (contentWidth: number, contentHeight: number) => { | ||
| animatedContentHeight.value = contentHeight; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this mean that I can't have additional content inside my bottom sheet if I'm using a scrollable component? The height of the sheet will be set to the height of the scrollable component instead of using the height of all the content in the sheet.. |
||
|
|
||
| if (onContentSizeChange) { | ||
| onContentSizeChange(contentWidth, contentHeight); | ||
| } | ||
| } | ||
| ); | ||
| //#endregion | ||
|
|
||
| //#region styles | ||
| const containerAnimatedStyle = useAnimatedStyle( | ||
| () => ({ | ||
|
|
@@ -124,6 +139,7 @@ export function createBottomSheetScrollableComponent<T, P>( | |
| overScrollMode={overScrollMode} | ||
| keyboardDismissMode={keyboardDismissMode} | ||
| onScroll={scrollHandler} | ||
| onContentSizeChange={handleContentSizeChange} | ||
| style={containerStyle} | ||
| /> | ||
| </NativeViewGestureHandler> | ||
|
|
@@ -174,6 +190,7 @@ export function createBottomSheetScrollableComponent<T, P>( | |
| progressViewOffset={progressViewOffset} | ||
| refreshControl={refreshControl} | ||
| onScroll={scrollHandler} | ||
| onContentSizeChange={handleContentSizeChange} | ||
| style={containerStyle} | ||
| /> | ||
| </NativeViewGestureHandler> | ||
|
|
||
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.
Is there anything we can do with the type annotation to tell users that this is only not required when the enableDynamicSizing prop is true?
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.
mmm not sure how could we achieve that, but if customers did not provide snap points and dynamic sizing prop, it will throw an exception https://github.com/gorhom/react-native-bottom-sheet/pull/1513/files#diff-620b7ea703632ea948b10134aaea17e0efd09781b64f587ecab4395812f9a3ccR26
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.
Just in the JSDoc comment above I was thinking. Should show in most IDEs when you hover over the prop or while you're typing
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.
@Eli-Nathan i have added an extra description in the latest commit