@lodev09/react-native-true-sheet 3.5.1-beta.1 → 3.5.1-beta.2

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.
@@ -310,7 +310,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
310
310
  * Propagates additional translation to parent so the entire stack stays visually consistent.
311
311
  */
312
312
  fun updateTranslationForChild(childSheetTop: Int) {
313
- if (!viewController.isDialogVisible || viewController.isExpanded) return
313
+ if (viewController.isExpanded) return
314
314
 
315
315
  val mySheetTop = viewController.getExpectedSheetTop(viewController.currentDetentIndex)
316
316
  val newTranslation = maxOf(0, childSheetTop - mySheetTop)
@@ -328,12 +328,24 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
328
328
  * Recursively adds translation to this sheet and all parent sheets.
329
329
  */
330
330
  private fun addTranslation(amount: Int) {
331
- if (!viewController.isDialogVisible || viewController.isExpanded) return
331
+ if (viewController.isExpanded) return
332
332
 
333
333
  viewController.translateDialog(viewController.currentTranslationY + amount)
334
334
  TrueSheetDialogObserver.getParentSheet(this)?.addTranslation(amount)
335
335
  }
336
336
 
337
+ /**
338
+ * Resets this sheet's translation and updates parent sheets.
339
+ * This sheet resets to 0 (it's now topmost), but parent recalculates based on this sheet's position.
340
+ */
341
+ fun resetTranslation() {
342
+ viewController.translateDialog(0)
343
+
344
+ // Parent should recalculate its translation based on this sheet's position
345
+ val mySheetTop = viewController.getExpectedSheetTop(viewController.currentDetentIndex)
346
+ TrueSheetDialogObserver.getParentSheet(this)?.updateTranslationForChild(mySheetTop)
347
+ }
348
+
337
349
  // ==================== TrueSheetViewControllerDelegate ====================
338
350
 
339
351
  override fun viewControllerWillPresent(index: Int, position: Float, detent: Float) {
@@ -526,7 +526,6 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
526
526
 
527
527
  // Execute pending transactions to ensure fragment is added
528
528
  activity.supportFragmentManager.executePendingTransactions()
529
- bottomSheetView?.translationY = realScreenHeight.toFloat()
530
529
  bottomSheetView?.visibility = INVISIBLE
531
530
  }
532
531
  }
@@ -40,7 +40,7 @@ object TrueSheetDialogObserver {
40
40
  synchronized(presentedSheetStack) {
41
41
  presentedSheetStack.remove(sheetView)
42
42
  if (hadParent) {
43
- presentedSheetStack.lastOrNull()?.viewController?.translateDialog(0)
43
+ presentedSheetStack.lastOrNull()?.resetTranslation()
44
44
  }
45
45
  }
46
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-true-sheet",
3
- "version": "3.5.1-beta.1",
3
+ "version": "3.5.1-beta.2",
4
4
  "description": "The true native bottom sheet experience for your React Native Apps.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",