-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
feat(iOS): add support for medium detent #1649
Conversation
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.
Some notes for reviewers below.
I would gladly hear some comments on prop naming.
+ (RNSScreenDetentType)RNSScreenDetentTypeFromAllowedDetents: | ||
(facebook::react::RNSScreenSheetAllowedDetents)allowedDetents; | ||
|
||
+ (RNSScreenDetentType)RNSScreenDetentTypeFromLargestUndimmedDetent: | ||
(facebook::react::RNSScreenSheetLargestUndimmedDetent)detent; | ||
|
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.
Codegen generates two different types of enums despite the fact, that only single type is used in JS component spec, thus 2 distinct conversion methods are required.
// This must be called after setter for stackPresentation | ||
[self updatePresentationStyle]; |
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.
This it the case, because retrieving sheetPresentationController
from view controller requires modalPresentationStyle
to be set to one of UIModalPresentationPageSheet or UIModalPresentationFormSheet. We do not support UIModalPresentationPageSheet, nevertheless this is done inside stackPresentation
setter.
On Paper this effect is achieved by calling this method in didSetProps:
method.
sheetAllowedDetents = 'large', | ||
sheetLargestUndimmedDetent = 'all', | ||
isSheetGrabberVisible = false, | ||
sheetCornerRadius = -1.0, |
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.
I wonder whether these default values will work with react-navigation
, because I remember some shenanigans with default value for gestureResponseDistance
prop.
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.
react-navigation
will have to add this code by itself since they have their own NativeStackView
.
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.
LGTM! I left some comments, please answer them before merging.
sheetAllowedDetents = 'large', | ||
sheetLargestUndimmedDetent = 'all', | ||
isSheetGrabberVisible = false, | ||
sheetCornerRadius = -1.0, |
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.
react-navigation
will have to add this code by itself since they have their own NativeStackView
.
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.
Amazing job on this PR so far 🎉
Some general remarks:
Android has a similar concept to iOS detents with bottom sheets. If we ever add a support for this in screens
(and I think we should) we definitely should have a unified API for both iOS detents and Android bottom sheets at the same time.
For API I kinda like the @gorhom 's API with snapPoints
naming and due to the popularity of react-native-bottom-sheet
it's something react-native developers are familiar with: https://gorhom.github.io/react-native-bottom-sheet/props#snappoints
To your implementation:
besides passing a few predefined detents iOS 16 also allows to pass a custom detent, I would love to see this implemented as well - customizing and resizing sheets in UIKit. Of course it can be in a separate PR but it's something we should keep in mind.
Cheers ✌️
I'll address naming issues when API for Android will be ready (yes, it is planned), because I do not know yet what terminology / conventions Android uses exactly. Thank you for suggestions though, I will most likely go into that direction.
I'm aware of possibility of specifying custom detent sizes, although it comes with few extra steps. I'll do it separate PR for sure, as this one gets too big. I'm going to merge this PR and iterate over the new API in followups. |
It appears that when using 3.19.0 with react-navigation, |
Hi @gorbypark, This PR was not included in version It will most likely be released with next minor version. |
Aha! Sorry for jumping the gun, I've been tracking this PR for a while since I'm interested in the feature! When I saw the weird half-height formSheet and a new release just a few days ago, I just assumed it had been merged! I guess I have to do some more investigation as to what's going on with my formSheet. Thanks! |
@kkafar this is awesome that we will finally have native sheets. Excited to see them on Android too. Is there any branch I can watch? Let me know if you need any help with implementation or testing 🙏 . By the way I noticed something on iOS that seems like a bug, when you collapse the sheet fast, there is a jumping in the bottom (seeing the content behind from the bottom): bottomJump.mov |
## Description Earlier when calling `updatePresentationStyle` in `RNSScreen` we have relied on order of method calls and kept our fingers crossed that the order would not be violated with future changes. Now we leverage `finalizeUpdates:` method from `RCTComponentViewProtocol` which is called after all updates are applied to the component. For broader context see #1649 (comments). ## Changes Moved call to `updatePresentationStyle` from `updateProps` to `finalizeUpdates`. ## Test code and steps to reproduce See `Test1649` (everything should work as before) ## Checklist - [x] Ensured that CI passes (iOS e2e is a known issue)
Description
Add support for
sheetPresentationController
by exposing new props. These changes work on both architectures (Fabric & Paper).Known issues:
Nevertheless after the review process I'm gonna merge this PR as it is getting to big and address these issues in separate PRs.
Changes
Added
sheetAllowedDetens
propstackPresentation
is set toformSheet
.large
.Added
sheetCornerRadius
propstackPresentation
is set toformSheet
.Added
sheetLargestUndimmedDetent
propstackPresentation
is set toformSheet
.large
- the view underneath won't be dimmed at any detent levelmedium
- the view underneath will be dimmed only when detent level islarge
all
- the view underneath will be dimmed for any detent levelall
.Added
sheetGrabberVisible
propstackPresentation
is set toformSheet
.false
.Added
sheetExpandsWhenScrolledToEdge
propstackPresentation
is set toformSheet
.true
.Added noop implementations for Android
Updated view manager interfaces for Paper
Screenshots / GIFs
Test code and steps to reproduce
Test1649
inTestsExample
&FabricTestExample
Checklist