-
-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '@kkafar/fabric-pressables' of github.com:software-mansi…
…on/react-native-screens into @kkafar/fabric-pressables
- Loading branch information
Showing
158 changed files
with
18,944 additions
and
530 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Publish Screens landing page | ||
env: | ||
YARN_ENABLE_HARDENED_MODE: 0 | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: docs/** | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
if: github.repository == 'software-mansion/react-native-screens' | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: docs-check-${{ github.ref }} | ||
cancel-in-progress: true | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
|
||
- name: Generate landing page content | ||
run: >- | ||
git config --local user.email "[email protected]" | ||
&& git config --local user.name "GitHub Action" | ||
&& cd docs | ||
&& yarn | ||
&& yarn build | ||
- name: Publish generated content to GitHub Pages | ||
uses: JamesIves/github-pages-deploy-action@releases/v3 | ||
with: | ||
FOLDER: docs/build | ||
BRANCH: gh-pages | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
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
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
67 changes: 67 additions & 0 deletions
67
android/src/main/java/com/swmansion/rnscreens/InsetsObserverProxy.kt
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,67 @@ | ||
package com.swmansion.rnscreens | ||
|
||
import android.view.View | ||
import androidx.core.view.OnApplyWindowInsetsListener | ||
import androidx.core.view.ViewCompat | ||
import androidx.core.view.WindowInsetsCompat | ||
import java.lang.ref.WeakReference | ||
|
||
object InsetsObserverProxy : OnApplyWindowInsetsListener { | ||
private val listeners: ArrayList<OnApplyWindowInsetsListener> = arrayListOf() | ||
private var eventSourceView: WeakReference<View> = WeakReference(null) | ||
|
||
// Please note semantics of this property. This is not `isRegistered`, because somebody, could unregister | ||
// us, without our knowledge, e.g. reanimated or different 3rd party library. This holds only information | ||
// whether this observer has been initially registered. | ||
private var hasBeenRegistered: Boolean = false | ||
|
||
private var shouldForwardInsetsToView = true | ||
|
||
override fun onApplyWindowInsets( | ||
v: View, | ||
insets: WindowInsetsCompat, | ||
): WindowInsetsCompat { | ||
var rollingInsets = | ||
if (shouldForwardInsetsToView) { | ||
WindowInsetsCompat.toWindowInsetsCompat( | ||
v.onApplyWindowInsets(insets.toWindowInsets()), | ||
v, | ||
) | ||
} else { | ||
insets | ||
} | ||
|
||
listeners.forEach { | ||
rollingInsets = it.onApplyWindowInsets(v, insets) | ||
} | ||
return rollingInsets | ||
} | ||
|
||
fun addOnApplyWindowInsetsListener(listener: OnApplyWindowInsetsListener) { | ||
listeners.add(listener) | ||
} | ||
|
||
fun removeOnApplyWindowInsetsListener(listener: OnApplyWindowInsetsListener) { | ||
listeners.remove(listener) | ||
} | ||
|
||
fun registerOnView(view: View) { | ||
if (!hasBeenRegistered) { | ||
ViewCompat.setOnApplyWindowInsetsListener(view, this) | ||
eventSourceView = WeakReference(view) | ||
hasBeenRegistered = true | ||
} else if (getObservedView() != view) { | ||
throw IllegalStateException( | ||
"[RNScreens] Attempt to register InsetsObserverProxy on $view while it has been already registered on ${getObservedView()}", | ||
) | ||
} | ||
} | ||
|
||
fun unregister() { | ||
eventSourceView.get()?.takeIf { hasBeenRegistered }?.let { | ||
ViewCompat.setOnApplyWindowInsetsListener(it, null) | ||
} | ||
} | ||
|
||
private fun getObservedView(): View? = eventSourceView.get() | ||
} |
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.