@lodev09/react-native-true-sheet 4.0.0-beta.2 → 4.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -4
- package/android/build.gradle +22 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +50 -16
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +303 -184
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentViewManager.kt +5 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +21 -110
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetOverlayView.kt +116 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetOverlayViewManager.kt +45 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +2 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetStateUpdater.kt +18 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +124 -50
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +369 -163
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +59 -12
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetBehavior.kt +126 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetView.kt +22 -9
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetCoordinatorLayout.kt +84 -5
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt +104 -39
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDimView.kt +3 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetOverlayRootView.kt +137 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetLifecycleEvents.kt +15 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/KeyboardUtils.kt +15 -2
- package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +0 -12
- package/android/src/main/java/com/lodev09/truesheet/utils/ViewUtils.kt +19 -7
- package/android/src/main/jni/TrueSheetSpec.h +1 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewComponentDescriptor.h +1 -9
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.cpp +110 -30
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.h +30 -7
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.cpp +2 -2
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.h +9 -8
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewComponentDescriptor.h +3 -5
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.cpp +9 -3
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.h +3 -6
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewState.cpp +1 -1
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewState.h +4 -6
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetInsets.cpp +1 -1
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetInsets.h +1 -1
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetLayoutUtils.h +43 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewComponentDescriptor.h +21 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewShadowNode.cpp +17 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewShadowNode.h +33 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewComponentDescriptor.h +3 -5
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.cpp +7 -40
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.h +3 -7
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.cpp +3 -5
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.h +4 -5
- package/ios/TrueSheetContainerView.h +27 -7
- package/ios/TrueSheetContainerView.mm +31 -11
- package/ios/TrueSheetContentView.h +43 -15
- package/ios/TrueSheetContentView.mm +211 -189
- package/ios/TrueSheetFooterView.h +6 -0
- package/ios/TrueSheetFooterView.mm +93 -17
- package/ios/TrueSheetModule.h +2 -7
- package/ios/TrueSheetModule.mm +7 -16
- package/ios/TrueSheetOverlayView.h +32 -0
- package/ios/TrueSheetOverlayView.mm +161 -0
- package/ios/TrueSheetView.mm +275 -56
- package/ios/TrueSheetViewController.h +31 -3
- package/ios/TrueSheetViewController.mm +393 -94
- package/ios/core/TrueSheetBlurView.h +0 -2
- package/ios/core/TrueSheetBlurView.mm +3 -36
- package/ios/core/TrueSheetDetentCalculator.h +7 -1
- package/ios/core/TrueSheetDetentCalculator.mm +27 -4
- package/ios/core/TrueSheetGrabberView.mm +13 -3
- package/ios/core/TrueSheetKeyboardObserver.mm +2 -0
- package/ios/core/TrueSheetOverlayContainerView.h +31 -0
- package/ios/core/TrueSheetOverlayContainerView.mm +35 -0
- package/ios/events/TrueSheetLifecycleEvents.h +2 -0
- package/ios/events/TrueSheetLifecycleEvents.mm +8 -0
- package/ios/tvos/TrueSheetStubs.mm +12 -0
- package/ios/utils/UIView+ScrollEdgeInteraction.h +1 -0
- package/ios/utils/UIView+ScrollEdgeInteraction.mm +24 -2
- package/lib/module/TrueSheet.js +175 -39
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.web.js +220 -243
- package/lib/module/TrueSheet.web.js.map +1 -1
- package/lib/module/TrueSheetBackground.js +15 -0
- package/lib/module/TrueSheetBackground.js.map +1 -0
- package/lib/module/TrueSheetOverlay.js +30 -0
- package/lib/module/TrueSheetOverlay.js.map +1 -0
- package/lib/module/TrueSheetOverlay.web.js +35 -0
- package/lib/module/TrueSheetOverlay.web.js.map +1 -0
- package/lib/module/TrueSheetPeek.web.js +20 -15
- package/lib/module/TrueSheetPeek.web.js.map +1 -1
- package/lib/module/detentBackgrounds.js +21 -0
- package/lib/module/detentBackgrounds.js.map +1 -0
- package/lib/module/fabric/TrueSheetContentViewNativeComponent.ts +1 -1
- package/lib/module/fabric/TrueSheetOverlayViewNativeComponent.ts +12 -0
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +15 -10
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks/index.js +18 -2
- package/lib/module/mocks/index.js.map +1 -1
- package/lib/module/mocks/navigationExpoRouter.js.map +1 -1
- package/lib/module/navigation/base-types.js +2 -0
- package/lib/module/navigation/base-types.js.map +1 -0
- package/lib/module/navigation/createTrueSheetRouter.js +0 -9
- package/lib/module/navigation/createTrueSheetRouter.js.map +1 -1
- package/lib/module/navigation/expo-router/base-types.js +2 -0
- package/lib/module/navigation/expo-router/base-types.js.map +1 -0
- package/lib/module/navigation/expo-router/index.js +10 -7
- package/lib/module/navigation/expo-router/index.js.map +1 -1
- package/lib/module/navigation/expo-router/types.js +4 -0
- package/lib/module/navigation/expo-router/types.js.map +1 -0
- package/lib/module/navigation/index.js.map +1 -1
- package/lib/module/navigation/screen/useSheetScreenState.js +1 -0
- package/lib/module/navigation/screen/useSheetScreenState.js.map +1 -1
- package/lib/module/web/constants.js +1 -1
- package/lib/module/web/constants.js.map +1 -1
- package/lib/module/web/layout.js +168 -0
- package/lib/module/web/layout.js.map +1 -0
- package/lib/module/web/vaul/constants.js +9 -0
- package/lib/module/web/vaul/constants.js.map +1 -1
- package/lib/module/web/vaul/context.js.map +1 -1
- package/lib/module/web/vaul/helpers.js +1 -0
- package/lib/module/web/vaul/helpers.js.map +1 -1
- package/lib/module/web/vaul/index.js +47 -7
- package/lib/module/web/vaul/index.js.map +1 -1
- package/lib/module/web/vaul/use-snap-points.js +21 -10
- package/lib/module/web/vaul/use-snap-points.js.map +1 -1
- package/lib/typescript/src/TrueSheet.d.ts +6 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +157 -34
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheetBackground.d.ts +3 -0
- package/lib/typescript/src/TrueSheetBackground.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetOverlay.d.ts +8 -0
- package/lib/typescript/src/TrueSheetOverlay.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetOverlay.web.d.ts +8 -0
- package/lib/typescript/src/TrueSheetOverlay.web.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetPeek.web.d.ts +8 -4
- package/lib/typescript/src/TrueSheetPeek.web.d.ts.map +1 -1
- package/lib/typescript/src/detentBackgrounds.d.ts +10 -0
- package/lib/typescript/src/detentBackgrounds.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetOverlayViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetOverlayViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +12 -7
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mocks/index.d.ts +4 -0
- package/lib/typescript/src/mocks/index.d.ts.map +1 -1
- package/lib/typescript/src/mocks/navigationExpoRouter.d.ts +3 -3
- package/lib/typescript/src/mocks/navigationExpoRouter.d.ts.map +1 -1
- package/lib/typescript/src/navigation/base-types.d.ts +9 -0
- package/lib/typescript/src/navigation/base-types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts +2 -13
- package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts.map +1 -1
- package/lib/typescript/src/navigation/expo-router/base-types.d.ts +8 -0
- package/lib/typescript/src/navigation/expo-router/base-types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/expo-router/index.d.ts +8 -6
- package/lib/typescript/src/navigation/expo-router/index.d.ts.map +1 -1
- package/lib/typescript/src/navigation/expo-router/types.d.ts +44 -0
- package/lib/typescript/src/navigation/expo-router/types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/index.d.ts +3 -4
- package/lib/typescript/src/navigation/index.d.ts.map +1 -1
- package/lib/typescript/src/navigation/screen/useSheetScreenState.d.ts +2 -1
- package/lib/typescript/src/navigation/screen/useSheetScreenState.d.ts.map +1 -1
- package/lib/typescript/src/navigation/types.d.ts +41 -5
- package/lib/typescript/src/navigation/types.d.ts.map +1 -1
- package/lib/typescript/src/web/constants.d.ts +1 -1
- package/lib/typescript/src/web/constants.d.ts.map +1 -1
- package/lib/typescript/src/web/layout.d.ts +19 -0
- package/lib/typescript/src/web/layout.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/constants.d.ts +3 -0
- package/lib/typescript/src/web/vaul/constants.d.ts.map +1 -1
- package/lib/typescript/src/web/vaul/context.d.ts +1 -0
- package/lib/typescript/src/web/vaul/context.d.ts.map +1 -1
- package/lib/typescript/src/web/vaul/helpers.d.ts +1 -0
- package/lib/typescript/src/web/vaul/helpers.d.ts.map +1 -1
- package/lib/typescript/src/web/vaul/index.d.ts +13 -1
- package/lib/typescript/src/web/vaul/index.d.ts.map +1 -1
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts +2 -1
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts.map +1 -1
- package/package.json +17 -8
- package/react-native.config.js +1 -0
- package/src/TrueSheet.tsx +208 -48
- package/src/TrueSheet.types.ts +166 -35
- package/src/TrueSheet.web.tsx +272 -290
- package/src/TrueSheetBackground.tsx +17 -0
- package/src/TrueSheetOverlay.tsx +24 -0
- package/src/TrueSheetOverlay.web.tsx +33 -0
- package/src/TrueSheetPeek.web.tsx +25 -23
- package/src/detentBackgrounds.ts +24 -0
- package/src/fabric/TrueSheetContentViewNativeComponent.ts +1 -1
- package/src/fabric/TrueSheetOverlayViewNativeComponent.ts +12 -0
- package/src/fabric/TrueSheetViewNativeComponent.ts +15 -10
- package/src/index.ts +1 -0
- package/src/mocks/index.ts +17 -2
- package/src/mocks/navigationExpoRouter.ts +6 -5
- package/src/navigation/base-types.ts +20 -0
- package/src/navigation/createTrueSheetRouter.ts +5 -33
- package/src/navigation/expo-router/base-types.ts +18 -0
- package/src/navigation/expo-router/index.ts +28 -30
- package/src/navigation/expo-router/types.ts +116 -0
- package/src/navigation/index.ts +6 -7
- package/src/navigation/screen/useSheetScreenState.ts +2 -0
- package/src/navigation/types.ts +75 -22
- package/src/web/constants.ts +1 -1
- package/src/web/layout.ts +196 -0
- package/src/web/vaul/constants.ts +9 -0
- package/src/web/vaul/context.ts +1 -0
- package/src/web/vaul/helpers.ts +5 -0
- package/src/web/vaul/index.tsx +75 -5
- package/src/web/vaul/use-snap-points.ts +32 -15
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
The true native bottom sheet experience for your React Native Apps. 💩
|
|
8
8
|
|
|
9
|
-
<img alt="React Native True Sheet - iPad" src="docs/
|
|
10
|
-
<img alt="React Native True Sheet - IOS" src="docs/
|
|
9
|
+
<img alt="React Native True Sheet - iPad" src="docs/public/img/preview-ipad.gif" width="744" /><br>
|
|
10
|
+
<img alt="React Native True Sheet - IOS" src="docs/public/img/preview-ios.gif" width="248" height="500" /><img alt="React Native True Sheet - Android" src="docs/public/img/preview-android.gif" width="248" height="500" /><img alt="React Native True Sheet - Web" src="docs/public/img/preview-web.gif" width="248" height="500" />
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
@@ -22,6 +22,25 @@ The true native bottom sheet experience for your React Native Apps. 💩
|
|
|
22
22
|
* 🧭 **React Navigation** - Built-in [sheet navigator](https://sheet.lodev09.com/guides/navigation) for seamless navigation integration
|
|
23
23
|
* 🌐 **Web Support** - Full [web support](https://sheet.lodev09.com/guides/web) out of the box
|
|
24
24
|
|
|
25
|
+
## 🎉 What's New in v4
|
|
26
|
+
|
|
27
|
+
> [!TIP]
|
|
28
|
+
> ✨ **v4 is in beta!** It rewrites the layout engine — the sheet now lays out synchronously per detent, so the container is sized to the sheet's visible height and tracks it in realtime while dragging.
|
|
29
|
+
|
|
30
|
+
* 📏 **Synchronous layout** - Content resizes in the same frame as the sheet, no more lag
|
|
31
|
+
* 📐 **`auto` detent with scrollables** - The sheet now sizes itself to a `ScrollView`/`FlatList`'s content height
|
|
32
|
+
* 📜 **`scrollableRef`** - Pass a `ScrollView`/`FlatList` ref to wire nested scrolling, keyboard insets, and `auto` detent sizing
|
|
33
|
+
* 🦶 **Relative footers** - Footers take up space below the content by default
|
|
34
|
+
* 🧭 **Expo Router** - First-class support via the `Sheet` layout from `/navigation/expo-router`
|
|
35
|
+
* 🍞 **`TrueSheetOverlay`** - Render toasts, dialogs, and other [overlays above your sheets](https://sheet.lodev09.com/guides/overlays) — no more `FullWindowOverlay`/`Modal` workarounds
|
|
36
|
+
* 🔍 **Element inspector** - React Native's dev menu inspector now works inside a presented sheet
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npx expo install @lodev09/react-native-true-sheet@beta
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
See the [Migration Guide](docs/docs/migration.mdx) to upgrade. **v3 is still supported** for React Native 0.81+ and remains the `latest` release on npm.
|
|
43
|
+
|
|
25
44
|
## Installation
|
|
26
45
|
|
|
27
46
|
> [!IMPORTANT]
|
|
@@ -30,7 +49,7 @@ The true native bottom sheet experience for your React Native Apps. 💩
|
|
|
30
49
|
|
|
31
50
|
### Prerequisites
|
|
32
51
|
|
|
33
|
-
- React Native 0.82+
|
|
52
|
+
- React Native 0.82+ (0.81+ on v3)
|
|
34
53
|
- New Architecture enabled
|
|
35
54
|
- Xcode 26.1+
|
|
36
55
|
|
|
@@ -55,6 +74,8 @@ yarn add @lodev09/react-native-true-sheet
|
|
|
55
74
|
cd ios && pod install
|
|
56
75
|
```
|
|
57
76
|
|
|
77
|
+
These install v3. For v4, append `@beta` — see [🎉 What's New in v4](#-whats-new-in-v4).
|
|
78
|
+
|
|
58
79
|
## Documentation
|
|
59
80
|
|
|
60
81
|
- [Example](example)
|
|
@@ -63,7 +84,7 @@ cd ios && pod install
|
|
|
63
84
|
- [React Navigation](https://sheet.lodev09.com/guides/navigation)
|
|
64
85
|
- [Troubleshooting](https://sheet.lodev09.com/troubleshooting)
|
|
65
86
|
- [Testing with Jest](https://sheet.lodev09.com/guides/jest)
|
|
66
|
-
- [Migrating to v3](https://sheet.lodev09.com/migration)
|
|
87
|
+
- [Migrating to v3](https://sheet.lodev09.com/migration-v3)
|
|
67
88
|
|
|
68
89
|
## Usage
|
|
69
90
|
|
package/android/build.gradle
CHANGED
|
@@ -17,7 +17,28 @@ buildscript {
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
apply plugin: "com.android.library"
|
|
20
|
-
|
|
20
|
+
// Android Gradle Plugin 9 ships built-in Kotlin support and applies the Kotlin
|
|
21
|
+
// plugin itself. Applying it a second time fails the configuration phase with
|
|
22
|
+
// "Cannot add extension with name 'kotlin'". Apply it only when AGP is not
|
|
23
|
+
// providing Kotlin: AGP 8 and older, or AGP 9 with android.builtInKotlin=false.
|
|
24
|
+
def shouldApplyKotlinPlugin() {
|
|
25
|
+
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
|
|
26
|
+
if (agpMajor <= 8) {
|
|
27
|
+
return true
|
|
28
|
+
}
|
|
29
|
+
// AGP 10 removes the opt-out: built-in Kotlin is always active there.
|
|
30
|
+
if (agpMajor >= 10) {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
def propertyVal = providers.gradleProperty("android.builtInKotlin").orNull
|
|
34
|
+
def builtInKotlinEnabled = propertyVal != null ? propertyVal.toBoolean() : true
|
|
35
|
+
return !builtInKotlinEnabled
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (shouldApplyKotlinPlugin()) {
|
|
39
|
+
apply plugin: "kotlin-android"
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
apply plugin: "com.facebook.react"
|
|
22
43
|
|
|
23
44
|
def getExtOrIntegerDefault(name) {
|
|
@@ -4,17 +4,15 @@ import android.annotation.SuppressLint
|
|
|
4
4
|
import android.view.View
|
|
5
5
|
import android.view.ViewGroup
|
|
6
6
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
-
import com.facebook.react.uimanager.events.EventDispatcher
|
|
8
|
-
import com.facebook.react.util.RNLog
|
|
9
7
|
import com.facebook.react.views.view.ReactViewGroup
|
|
10
8
|
|
|
11
9
|
interface TrueSheetContainerViewDelegate {
|
|
12
|
-
val eventDispatcher: EventDispatcher?
|
|
13
10
|
fun containerViewContentDidChangeSize(width: Int, height: Int)
|
|
14
11
|
fun containerViewContentDidScroll()
|
|
15
12
|
fun containerViewScrollViewDidChange()
|
|
16
13
|
fun containerViewHeaderDidChangeSize(width: Int, height: Int)
|
|
17
14
|
fun containerViewFooterDidChangeSize(width: Int, height: Int)
|
|
15
|
+
fun containerViewFooterDidLayout()
|
|
18
16
|
fun containerViewPeekDidChangeSize(width: Int, height: Int)
|
|
19
17
|
}
|
|
20
18
|
|
|
@@ -61,9 +59,19 @@ class TrueSheetContainerView(reactContext: ThemedReactContext) :
|
|
|
61
59
|
return bottom
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
var insetAdjustment: TrueSheetInsetAdjustment = TrueSheetInsetAdjustment.AUTOMATIC
|
|
65
|
-
var scrollViewBottomInset: Int = 0
|
|
66
62
|
var absoluteFooter: Boolean = false
|
|
63
|
+
set(value) {
|
|
64
|
+
if (field == value) return
|
|
65
|
+
field = value
|
|
66
|
+
contentView?.updateContentInset()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override var footerAvoidsKeyboard: Boolean = true
|
|
70
|
+
set(value) {
|
|
71
|
+
if (field == value) return
|
|
72
|
+
field = value
|
|
73
|
+
contentView?.updateContentInset()
|
|
74
|
+
}
|
|
67
75
|
|
|
68
76
|
/**
|
|
69
77
|
* Bottom safe-area inset the footer absorbs as padding — the footer
|
|
@@ -80,14 +88,22 @@ class TrueSheetContainerView(reactContext: ThemedReactContext) :
|
|
|
80
88
|
contentView?.scrollableOptions = value
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
|
|
91
|
+
// React tag of the user-provided scrollable within the content (see the scrollableRef prop)
|
|
92
|
+
var scrollableHandle: Int = -1
|
|
84
93
|
set(value) {
|
|
85
94
|
field = value
|
|
86
|
-
contentView?.
|
|
95
|
+
contentView?.scrollableHandle = value
|
|
87
96
|
}
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Bottom safe-area inset the plugged scrollable applies as content padding
|
|
100
|
+
* while it can scroll (see ScrollableOptions.contentInsetAdjustment)
|
|
101
|
+
*/
|
|
102
|
+
var scrollableBottomInset: Int = 0
|
|
103
|
+
set(value) {
|
|
104
|
+
field = value
|
|
105
|
+
contentView?.bottomInset = value
|
|
106
|
+
}
|
|
91
107
|
|
|
92
108
|
init {
|
|
93
109
|
// Allow footer to position outside container bounds
|
|
@@ -96,8 +112,7 @@ class TrueSheetContainerView(reactContext: ThemedReactContext) :
|
|
|
96
112
|
}
|
|
97
113
|
|
|
98
114
|
fun setupScrollable() {
|
|
99
|
-
|
|
100
|
-
contentView?.setupScrollable(bottomInset)
|
|
115
|
+
contentView?.setupScrollable()
|
|
101
116
|
}
|
|
102
117
|
|
|
103
118
|
fun setupKeyboardHandler() {
|
|
@@ -115,9 +130,13 @@ class TrueSheetContainerView(reactContext: ThemedReactContext) :
|
|
|
115
130
|
is TrueSheetContentView -> {
|
|
116
131
|
child.delegate = this
|
|
117
132
|
child.scrollableOptions = scrollableOptions
|
|
118
|
-
child.
|
|
133
|
+
child.scrollableHandle = scrollableHandle
|
|
134
|
+
child.bottomInset = scrollableBottomInset
|
|
119
135
|
contentView = child
|
|
120
136
|
|
|
137
|
+
// State lands before the view is attached, so pull the current value
|
|
138
|
+
contentHeight = child.naturalHeight
|
|
139
|
+
|
|
121
140
|
// Children mount bottom-up, so the content subtree is complete here.
|
|
122
141
|
// Late-mounted peek views attach themselves instead (see TrueSheetPeekView).
|
|
123
142
|
findPeekView(child)?.let { attachPeekView(it) }
|
|
@@ -177,10 +196,9 @@ class TrueSheetContainerView(reactContext: ThemedReactContext) :
|
|
|
177
196
|
fun attachPeekView(view: TrueSheetPeekView) {
|
|
178
197
|
if (peekView === view) return
|
|
179
198
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
199
|
+
// Last-attached wins. During a screen transition the incoming peek mounts
|
|
200
|
+
// before the outgoing one detaches, and the outgoing detach is a no-op.
|
|
201
|
+
peekView?.delegate = null
|
|
184
202
|
|
|
185
203
|
peekView = view
|
|
186
204
|
view.delegate = this
|
|
@@ -205,6 +223,15 @@ class TrueSheetContainerView(reactContext: ThemedReactContext) :
|
|
|
205
223
|
override val footerKeyboardOcclusion: Int
|
|
206
224
|
get() = if (absoluteFooter) footerView?.keyboardOcclusionHeight ?: 0 else -(footerView?.height ?: 0)
|
|
207
225
|
|
|
226
|
+
override val absoluteFooterHeight: Int
|
|
227
|
+
get() = if (absoluteFooter) footerView?.height ?: 0 else 0
|
|
228
|
+
|
|
229
|
+
override val absoluteFooterTop: Int
|
|
230
|
+
get() = footerView?.y?.toInt() ?: height
|
|
231
|
+
|
|
232
|
+
override val hasRelativeFooter: Boolean
|
|
233
|
+
get() = footerView != null && !absoluteFooter
|
|
234
|
+
|
|
208
235
|
override fun contentViewDidScroll() {
|
|
209
236
|
delegate?.containerViewContentDidScroll()
|
|
210
237
|
}
|
|
@@ -221,6 +248,13 @@ class TrueSheetContainerView(reactContext: ThemedReactContext) :
|
|
|
221
248
|
override fun footerViewDidChangeSize(width: Int, height: Int) {
|
|
222
249
|
footerHeight = height
|
|
223
250
|
delegate?.containerViewFooterDidChangeSize(width, height)
|
|
251
|
+
// A relative footer takes over the bottom inset — drop the scrollable's;
|
|
252
|
+
// an absolute one may pad the scrollable by its height
|
|
253
|
+
contentView?.updateContentInset()
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
override fun footerViewDidLayout() {
|
|
257
|
+
delegate?.containerViewFooterDidLayout()
|
|
224
258
|
}
|
|
225
259
|
|
|
226
260
|
override fun peekViewDidChangeSize(width: Int, height: Int) {
|