@lodev09/react-native-true-sheet 3.5.1-beta.2 → 3.5.1-beta.4
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/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +2 -2
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +32 -28
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +378 -253
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +0 -5
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +36 -14
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetView.kt +150 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetCoordinatorLayout.kt +55 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt +18 -12
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDimView.kt +91 -2
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetKeyboardObserver.kt +21 -11
- package/android/src/main/java/com/lodev09/truesheet/core/{TrueSheetDialogObserver.kt → TrueSheetStackManager.kt} +7 -5
- package/ios/TrueSheetViewController.h +2 -3
- package/ios/TrueSheetViewController.mm +11 -4
- package/ios/core/TrueSheetDetentCalculator.h +2 -3
- package/ios/core/TrueSheetDetentCalculator.mm +7 -9
- package/lib/module/TrueSheet.js +1 -16
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +0 -1
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +0 -8
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +0 -1
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/navigation/types.d.ts +1 -1
- package/lib/typescript/src/navigation/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TrueSheet.tsx +1 -16
- package/src/TrueSheet.types.ts +0 -9
- package/src/fabric/TrueSheetViewNativeComponent.ts +0 -1
- package/src/navigation/types.ts +0 -1
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetAnimator.kt +0 -145
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDialogFragment.kt +0 -320
- package/android/src/main/res/anim/fast_fade_out.xml +0 -6
- package/android/src/main/res/values/styles.xml +0 -21
|
@@ -8,7 +8,7 @@ import com.facebook.react.bridge.ReactMethod
|
|
|
8
8
|
import com.facebook.react.module.annotations.ReactModule
|
|
9
9
|
import com.facebook.react.turbomodule.core.interfaces.TurboModule
|
|
10
10
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
11
|
-
import com.lodev09.truesheet.core.
|
|
11
|
+
import com.lodev09.truesheet.core.TrueSheetStackManager
|
|
12
12
|
import java.util.concurrent.ConcurrentHashMap
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -28,7 +28,7 @@ class TrueSheetModule(reactContext: ReactApplicationContext) :
|
|
|
28
28
|
synchronized(viewRegistry) {
|
|
29
29
|
viewRegistry.clear()
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
TrueSheetStackManager.clear()
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -15,12 +15,13 @@ import com.facebook.react.uimanager.events.EventDispatcher
|
|
|
15
15
|
import com.facebook.react.util.RNLog
|
|
16
16
|
import com.facebook.react.views.view.ReactViewGroup
|
|
17
17
|
import com.lodev09.truesheet.core.GrabberOptions
|
|
18
|
-
import com.lodev09.truesheet.core.
|
|
18
|
+
import com.lodev09.truesheet.core.TrueSheetStackManager
|
|
19
19
|
import com.lodev09.truesheet.events.*
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Main TrueSheet host view that manages the sheet
|
|
23
|
-
* This view is hidden (GONE) and delegates all rendering to TrueSheetViewController
|
|
22
|
+
* Main TrueSheet host view that manages the sheet and dispatches events to JavaScript.
|
|
23
|
+
* This view is hidden (GONE) and delegates all rendering to TrueSheetViewController
|
|
24
|
+
* using a CoordinatorLayout approach (no separate dialog window).
|
|
24
25
|
*/
|
|
25
26
|
@SuppressLint("ViewConstructor")
|
|
26
27
|
class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
@@ -45,6 +46,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
45
46
|
// Initial present configuration (set by ViewManager before mount)
|
|
46
47
|
var initialDetentIndex: Int = -1
|
|
47
48
|
var initialDetentAnimated: Boolean = true
|
|
49
|
+
private var hasInitialPresented: Boolean = false
|
|
48
50
|
|
|
49
51
|
var stateWrapper: StateWrapper? = null
|
|
50
52
|
set(value) {
|
|
@@ -101,10 +103,15 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
101
103
|
|
|
102
104
|
if (child is TrueSheetContainerView) {
|
|
103
105
|
child.delegate = this
|
|
104
|
-
viewController.
|
|
105
|
-
|
|
106
|
-
if (initialDetentIndex >= 0) {
|
|
107
|
-
|
|
106
|
+
viewController.createSheet()
|
|
107
|
+
|
|
108
|
+
if (initialDetentIndex >= 0 && !hasInitialPresented) {
|
|
109
|
+
hasInitialPresented = true
|
|
110
|
+
if (initialDetentAnimated) {
|
|
111
|
+
present(initialDetentIndex, true) { }
|
|
112
|
+
} else {
|
|
113
|
+
post { present(initialDetentIndex, false) { } }
|
|
114
|
+
}
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
val surfaceId = UIManagerHelper.getSurfaceId(this)
|
|
@@ -131,6 +138,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
131
138
|
// ==================== Lifecycle ====================
|
|
132
139
|
|
|
133
140
|
override fun onHostResume() {
|
|
141
|
+
viewController.reapplyHiddenState()
|
|
134
142
|
finalizeUpdates()
|
|
135
143
|
}
|
|
136
144
|
|
|
@@ -143,7 +151,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
143
151
|
fun onDropInstance() {
|
|
144
152
|
reactContext.removeLifecycleEventListener(this)
|
|
145
153
|
TrueSheetModule.unregisterView(id)
|
|
146
|
-
|
|
154
|
+
TrueSheetStackManager.removeSheet(this)
|
|
147
155
|
|
|
148
156
|
if (viewController.isPresented) {
|
|
149
157
|
viewController.dismiss()
|
|
@@ -157,8 +165,8 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
157
165
|
*/
|
|
158
166
|
fun finalizeUpdates() {
|
|
159
167
|
if (viewController.isPresented) {
|
|
160
|
-
viewController.setupBackground()
|
|
161
|
-
viewController.setupGrabber()
|
|
168
|
+
viewController.sheetView?.setupBackground()
|
|
169
|
+
viewController.sheetView?.setupGrabber()
|
|
162
170
|
updateSheetIfNeeded()
|
|
163
171
|
}
|
|
164
172
|
}
|
|
@@ -218,10 +226,6 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
218
226
|
viewController.detents = newDetents
|
|
219
227
|
}
|
|
220
228
|
|
|
221
|
-
fun setEdgeToEdgeFullScreen(edgeToEdgeFullScreen: Boolean) {
|
|
222
|
-
viewController.edgeToEdgeFullScreen = edgeToEdgeFullScreen
|
|
223
|
-
}
|
|
224
|
-
|
|
225
229
|
fun setInsetAdjustment(insetAdjustment: String) {
|
|
226
230
|
viewController.insetAdjustment = insetAdjustment
|
|
227
231
|
}
|
|
@@ -251,7 +255,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
251
255
|
fun present(detentIndex: Int, animated: Boolean = true, promiseCallback: () -> Unit) {
|
|
252
256
|
if (!viewController.isPresented) {
|
|
253
257
|
// Register with observer to track sheet stack hierarchy
|
|
254
|
-
viewController.parentSheetView =
|
|
258
|
+
viewController.parentSheetView = TrueSheetStackManager.onSheetWillPresent(this, detentIndex)
|
|
255
259
|
}
|
|
256
260
|
viewController.presentPromise = promiseCallback
|
|
257
261
|
viewController.present(detentIndex, animated)
|
|
@@ -262,7 +266,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
262
266
|
// iOS-like behavior: calling dismiss on a presenting controller dismisses
|
|
263
267
|
// its presented controller (and everything above it), but NOT itself.
|
|
264
268
|
// See: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621505-dismiss
|
|
265
|
-
val sheetsAbove =
|
|
269
|
+
val sheetsAbove = TrueSheetStackManager.getSheetsAbove(this)
|
|
266
270
|
if (sheetsAbove.isNotEmpty()) {
|
|
267
271
|
for (sheet in sheetsAbove) {
|
|
268
272
|
sheet.viewController.dismiss(animated)
|
|
@@ -298,7 +302,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
298
302
|
viewController.post {
|
|
299
303
|
isSheetUpdatePending = false
|
|
300
304
|
viewController.setupSheetDetentsForSizeChange()
|
|
301
|
-
|
|
305
|
+
TrueSheetStackManager.onSheetSizeChanged(this)
|
|
302
306
|
}
|
|
303
307
|
}
|
|
304
308
|
|
|
@@ -310,17 +314,17 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
310
314
|
* Propagates additional translation to parent so the entire stack stays visually consistent.
|
|
311
315
|
*/
|
|
312
316
|
fun updateTranslationForChild(childSheetTop: Int) {
|
|
313
|
-
if (viewController.isExpanded) return
|
|
317
|
+
if (!viewController.isSheetVisible || viewController.isExpanded) return
|
|
314
318
|
|
|
315
|
-
val mySheetTop = viewController.
|
|
319
|
+
val mySheetTop = viewController.detentCalculator.getSheetTopForDetentIndex(viewController.currentDetentIndex)
|
|
316
320
|
val newTranslation = maxOf(0, childSheetTop - mySheetTop)
|
|
317
321
|
val additionalTranslation = newTranslation - viewController.currentTranslationY
|
|
318
322
|
|
|
319
|
-
viewController.
|
|
323
|
+
viewController.translateSheet(newTranslation)
|
|
320
324
|
|
|
321
325
|
// Propagate any additional translation up the stack
|
|
322
326
|
if (additionalTranslation > 0) {
|
|
323
|
-
|
|
327
|
+
TrueSheetStackManager.getParentSheet(this)?.addTranslation(additionalTranslation)
|
|
324
328
|
}
|
|
325
329
|
}
|
|
326
330
|
|
|
@@ -328,10 +332,10 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
328
332
|
* Recursively adds translation to this sheet and all parent sheets.
|
|
329
333
|
*/
|
|
330
334
|
private fun addTranslation(amount: Int) {
|
|
331
|
-
if (viewController.isExpanded) return
|
|
335
|
+
if (!viewController.isSheetVisible || viewController.isExpanded) return
|
|
332
336
|
|
|
333
|
-
viewController.
|
|
334
|
-
|
|
337
|
+
viewController.translateSheet(viewController.currentTranslationY + amount)
|
|
338
|
+
TrueSheetStackManager.getParentSheet(this)?.addTranslation(amount)
|
|
335
339
|
}
|
|
336
340
|
|
|
337
341
|
/**
|
|
@@ -339,11 +343,11 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
339
343
|
* This sheet resets to 0 (it's now topmost), but parent recalculates based on this sheet's position.
|
|
340
344
|
*/
|
|
341
345
|
fun resetTranslation() {
|
|
342
|
-
viewController.
|
|
346
|
+
viewController.translateSheet(0)
|
|
343
347
|
|
|
344
348
|
// Parent should recalculate its translation based on this sheet's position
|
|
345
|
-
val mySheetTop = viewController.
|
|
346
|
-
|
|
349
|
+
val mySheetTop = viewController.detentCalculator.getSheetTopForDetentIndex(viewController.currentDetentIndex)
|
|
350
|
+
TrueSheetStackManager.getParentSheet(this)?.updateTranslationForChild(mySheetTop)
|
|
347
351
|
}
|
|
348
352
|
|
|
349
353
|
// ==================== TrueSheetViewControllerDelegate ====================
|
|
@@ -375,7 +379,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
375
379
|
val surfaceId = UIManagerHelper.getSurfaceId(this)
|
|
376
380
|
eventDispatcher?.dispatchEvent(DidDismissEvent(surfaceId, id))
|
|
377
381
|
|
|
378
|
-
|
|
382
|
+
TrueSheetStackManager.onSheetDidDismiss(this, hadParent)
|
|
379
383
|
}
|
|
380
384
|
|
|
381
385
|
override fun viewControllerDidChangeDetent(index: Int, position: Float, detent: Float) {
|