-
-
Notifications
You must be signed in to change notification settings - Fork 512
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 custom detents & Android form sheets #2045
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.
We comin' home 😄 💪 💪
android/src/main/java/com/swmansion/rnscreens/InsetsObserverProxy.kt
Outdated
Show resolved
Hide resolved
android/src/main/java/com/swmansion/rnscreens/InsetsObserverProxy.kt
Outdated
Show resolved
Hide resolved
Looking forward to the new release |
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.
Few remarks for future me.
I'm merging this PR & releasing the changes as beta version of the library to gather community feedback & bug reports.
@tboba @alduzy @maciekstosio @maksg I'll break our standard merging procedure by not first merging API changes to react-navigation
. Please be aware of that - we will have a custom patch for RN for 1,5 week until I'm back and tidying things up.
import androidx.core.view.WindowInsetsCompat | ||
import java.lang.ref.WeakReference | ||
|
||
object InsetsObserverProxy : OnApplyWindowInsetsListener { |
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 class is needed, because sheets do need to listen for keyboard appearance. Each sheet does need to register a listener to decor view, while Android allows for only single listener! Thus I've introduced a proxy, who can aggregate listeners and fan out the events.
override fun canDispatchLifecycleEvent(event: ScreenFragment.ScreenLifecycleEvent): Boolean { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun updateLastEventDispatched(event: ScreenFragment.ScreenLifecycleEvent) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun dispatchLifecycleEvent( | ||
event: ScreenFragment.ScreenLifecycleEvent, | ||
fragmentWrapper: ScreenFragmentWrapper, | ||
) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun dispatchLifecycleEventInChildContainers(event: ScreenFragment.ScreenLifecycleEvent) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun dispatchHeaderBackButtonClickedEvent() { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun dispatchTransitionProgressEvent( | ||
alpha: Float, | ||
closing: Boolean, | ||
) { | ||
TODO("Not yet implemented") | ||
} |
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.
These are here, because they are present in ScreenWrapper
interface. Once they are moved out from here, we can safely remove them & reintroduce one by one as needed.
For every one interested: I've released 4.0.0-beta.0 #2045 Testing & any feedback is very very welcome. Thanks! |
So I tried it run the main branch, formsheet route on Pixel 8 pro looks like this for me (i made background of the screen red): screen-20240811-161216.mp4 |
Description
This PR introduces series of features & changes:
Screen
component (namely types of values accepted),fitToContents
formSheet
presentation styleformSheet
, however the sheet is mounted under separate window.a. controlling style of the
Screen
component (necessary workaround for issue with flickering on iOS,b. controlling whether the screen fragment of particular screen should be unmounted or not on Android when the screen is on JS stack but not visible (necessary to achieve "staying form sheet" when navigating back to a screen with presented form sheet),
c. listening for
sheetDetentChange
events, in case of Android stable & dragging states are reported, in case of iOS only stable statesd. todo: describe rest
Changes
Known issues
After recent commits - iOS compilation on FabricScrollView
interactions with Android'sCoordinatorLayout
facebook/react-native#44099, no other workaround found. There is one approach suggested by grahammendick, however yet untested.Test code and steps to reproduce
I've used & extended
Test1649
to present all capabilities of new API.Checklist