@lodev09/react-native-true-sheet 3.5.1-beta.3 → 3.5.1-beta.5
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 +31 -28
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +358 -271
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +0 -5
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +7 -8
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetView.kt +158 -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/{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 +0 -2
- 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 +0 -2
- 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 -144
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDialogFragment.kt +0 -317
- 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)
|
|
@@ -144,7 +151,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
144
151
|
fun onDropInstance() {
|
|
145
152
|
reactContext.removeLifecycleEventListener(this)
|
|
146
153
|
TrueSheetModule.unregisterView(id)
|
|
147
|
-
|
|
154
|
+
TrueSheetStackManager.removeSheet(this)
|
|
148
155
|
|
|
149
156
|
if (viewController.isPresented) {
|
|
150
157
|
viewController.dismiss()
|
|
@@ -158,8 +165,8 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
158
165
|
*/
|
|
159
166
|
fun finalizeUpdates() {
|
|
160
167
|
if (viewController.isPresented) {
|
|
161
|
-
viewController.setupBackground()
|
|
162
|
-
viewController.setupGrabber()
|
|
168
|
+
viewController.sheetView?.setupBackground()
|
|
169
|
+
viewController.sheetView?.setupGrabber()
|
|
163
170
|
updateSheetIfNeeded()
|
|
164
171
|
}
|
|
165
172
|
}
|
|
@@ -219,10 +226,6 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
219
226
|
viewController.detents = newDetents
|
|
220
227
|
}
|
|
221
228
|
|
|
222
|
-
fun setEdgeToEdgeFullScreen(edgeToEdgeFullScreen: Boolean) {
|
|
223
|
-
viewController.edgeToEdgeFullScreen = edgeToEdgeFullScreen
|
|
224
|
-
}
|
|
225
|
-
|
|
226
229
|
fun setInsetAdjustment(insetAdjustment: String) {
|
|
227
230
|
viewController.insetAdjustment = insetAdjustment
|
|
228
231
|
}
|
|
@@ -252,7 +255,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
252
255
|
fun present(detentIndex: Int, animated: Boolean = true, promiseCallback: () -> Unit) {
|
|
253
256
|
if (!viewController.isPresented) {
|
|
254
257
|
// Register with observer to track sheet stack hierarchy
|
|
255
|
-
viewController.parentSheetView =
|
|
258
|
+
viewController.parentSheetView = TrueSheetStackManager.onSheetWillPresent(this, detentIndex)
|
|
256
259
|
}
|
|
257
260
|
viewController.presentPromise = promiseCallback
|
|
258
261
|
viewController.present(detentIndex, animated)
|
|
@@ -263,7 +266,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
263
266
|
// iOS-like behavior: calling dismiss on a presenting controller dismisses
|
|
264
267
|
// its presented controller (and everything above it), but NOT itself.
|
|
265
268
|
// See: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621505-dismiss
|
|
266
|
-
val sheetsAbove =
|
|
269
|
+
val sheetsAbove = TrueSheetStackManager.getSheetsAbove(this)
|
|
267
270
|
if (sheetsAbove.isNotEmpty()) {
|
|
268
271
|
for (sheet in sheetsAbove) {
|
|
269
272
|
sheet.viewController.dismiss(animated)
|
|
@@ -299,7 +302,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
299
302
|
viewController.post {
|
|
300
303
|
isSheetUpdatePending = false
|
|
301
304
|
viewController.setupSheetDetentsForSizeChange()
|
|
302
|
-
|
|
305
|
+
TrueSheetStackManager.onSheetSizeChanged(this)
|
|
303
306
|
}
|
|
304
307
|
}
|
|
305
308
|
|
|
@@ -311,17 +314,17 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
311
314
|
* Propagates additional translation to parent so the entire stack stays visually consistent.
|
|
312
315
|
*/
|
|
313
316
|
fun updateTranslationForChild(childSheetTop: Int) {
|
|
314
|
-
if (viewController.isExpanded) return
|
|
317
|
+
if (!viewController.isSheetVisible || viewController.isExpanded) return
|
|
315
318
|
|
|
316
|
-
val mySheetTop = viewController.
|
|
319
|
+
val mySheetTop = viewController.detentCalculator.getSheetTopForDetentIndex(viewController.currentDetentIndex)
|
|
317
320
|
val newTranslation = maxOf(0, childSheetTop - mySheetTop)
|
|
318
321
|
val additionalTranslation = newTranslation - viewController.currentTranslationY
|
|
319
322
|
|
|
320
|
-
viewController.
|
|
323
|
+
viewController.translateSheet(newTranslation)
|
|
321
324
|
|
|
322
325
|
// Propagate any additional translation up the stack
|
|
323
326
|
if (additionalTranslation > 0) {
|
|
324
|
-
|
|
327
|
+
TrueSheetStackManager.getParentSheet(this)?.addTranslation(additionalTranslation)
|
|
325
328
|
}
|
|
326
329
|
}
|
|
327
330
|
|
|
@@ -329,10 +332,10 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
329
332
|
* Recursively adds translation to this sheet and all parent sheets.
|
|
330
333
|
*/
|
|
331
334
|
private fun addTranslation(amount: Int) {
|
|
332
|
-
if (viewController.isExpanded) return
|
|
335
|
+
if (!viewController.isSheetVisible || viewController.isExpanded) return
|
|
333
336
|
|
|
334
|
-
viewController.
|
|
335
|
-
|
|
337
|
+
viewController.translateSheet(viewController.currentTranslationY + amount)
|
|
338
|
+
TrueSheetStackManager.getParentSheet(this)?.addTranslation(amount)
|
|
336
339
|
}
|
|
337
340
|
|
|
338
341
|
/**
|
|
@@ -340,11 +343,11 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
340
343
|
* This sheet resets to 0 (it's now topmost), but parent recalculates based on this sheet's position.
|
|
341
344
|
*/
|
|
342
345
|
fun resetTranslation() {
|
|
343
|
-
viewController.
|
|
346
|
+
viewController.translateSheet(0)
|
|
344
347
|
|
|
345
348
|
// Parent should recalculate its translation based on this sheet's position
|
|
346
|
-
val mySheetTop = viewController.
|
|
347
|
-
|
|
349
|
+
val mySheetTop = viewController.detentCalculator.getSheetTopForDetentIndex(viewController.currentDetentIndex)
|
|
350
|
+
TrueSheetStackManager.getParentSheet(this)?.updateTranslationForChild(mySheetTop)
|
|
348
351
|
}
|
|
349
352
|
|
|
350
353
|
// ==================== TrueSheetViewControllerDelegate ====================
|
|
@@ -376,7 +379,7 @@ class TrueSheetView(private val reactContext: ThemedReactContext) :
|
|
|
376
379
|
val surfaceId = UIManagerHelper.getSurfaceId(this)
|
|
377
380
|
eventDispatcher?.dispatchEvent(DidDismissEvent(surfaceId, id))
|
|
378
381
|
|
|
379
|
-
|
|
382
|
+
TrueSheetStackManager.onSheetDidDismiss(this, hadParent)
|
|
380
383
|
}
|
|
381
384
|
|
|
382
385
|
override fun viewControllerDidChangeDetent(index: Int, position: Float, detent: Float) {
|