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

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.
@@ -3,6 +3,7 @@ package com.lodev09.truesheet.core
3
3
  import android.animation.Animator
4
4
  import android.animation.AnimatorListenerAdapter
5
5
  import android.animation.ValueAnimator
6
+ import android.util.Log
6
7
  import android.view.animation.AccelerateInterpolator
7
8
  import android.view.animation.DecelerateInterpolator
8
9
  import android.widget.FrameLayout
@@ -29,6 +30,8 @@ class TrueSheetAnimator(private val provider: TrueSheetAnimatorProvider) {
29
30
  private var presentAnimator: ValueAnimator? = null
30
31
  private var dismissAnimator: ValueAnimator? = null
31
32
 
33
+ var isAnimating: Boolean = false
34
+
32
35
  /**
33
36
  * Animate the sheet presenting from bottom of screen to target position.
34
37
  * @param toTop The target top position of the sheet
@@ -57,14 +60,20 @@ class TrueSheetAnimator(private val provider: TrueSheetAnimatorProvider) {
57
60
  }
58
61
 
59
62
  addListener(object : AnimatorListenerAdapter() {
63
+ override fun onAnimationStart(animation: Animator) {
64
+ isAnimating = true
65
+ }
66
+
60
67
  override fun onAnimationEnd(animation: Animator) {
61
68
  bottomSheet.translationY = 0f
62
69
  presentAnimator = null
70
+ isAnimating = false
63
71
  onEnd()
64
72
  }
65
73
 
66
74
  override fun onAnimationCancel(animation: Animator) {
67
75
  presentAnimator = null
76
+ isAnimating = false
68
77
  onEnd()
69
78
  }
70
79
  })
@@ -101,13 +110,19 @@ class TrueSheetAnimator(private val provider: TrueSheetAnimatorProvider) {
101
110
  }
102
111
 
103
112
  addListener(object : AnimatorListenerAdapter() {
113
+ override fun onAnimationStart(animation: Animator) {
114
+ isAnimating = true
115
+ }
116
+
104
117
  override fun onAnimationEnd(animation: Animator) {
105
118
  dismissAnimator = null
119
+ isAnimating = false
106
120
  onEnd()
107
121
  }
108
122
 
109
123
  override fun onAnimationCancel(animation: Animator) {
110
124
  dismissAnimator = null
125
+ isAnimating = false
111
126
  onEnd()
112
127
  }
113
128
  })
@@ -125,10 +140,4 @@ class TrueSheetAnimator(private val provider: TrueSheetAnimatorProvider) {
125
140
  dismissAnimator?.cancel()
126
141
  dismissAnimator = null
127
142
  }
128
-
129
- /**
130
- * Check if any animation is currently running.
131
- */
132
- val isAnimating: Boolean
133
- get() = presentAnimator?.isRunning == true || dismissAnimator?.isRunning == true
134
143
  }
@@ -106,4 +106,14 @@ object TrueSheetDialogObserver {
106
106
  return presentedSheetStack[index - 1]
107
107
  }
108
108
  }
109
+
110
+ /**
111
+ * Returns true if the given sheet is the topmost presented sheet.
112
+ */
113
+ @JvmStatic
114
+ fun isTopmostSheet(sheetView: TrueSheetView): Boolean {
115
+ synchronized(presentedSheetStack) {
116
+ return presentedSheetStack.lastOrNull() == sheetView
117
+ }
118
+ }
109
119
  }
@@ -48,12 +48,12 @@ class TrueSheetDimView(private val reactContext: ThemedReactContext) : View(reac
48
48
  targetView = null
49
49
  }
50
50
 
51
- fun interpolateAlpha(sheetTop: Int, dimmedDetentIndex: Int, getSheetTopForDetentIndex: (Int) -> Int) {
51
+ fun calculateAlpha(sheetTop: Int, dimmedDetentIndex: Int, getSheetTopForDetentIndex: (Int) -> Int): Float {
52
52
  val realHeight = ScreenUtils.getRealScreenHeight(reactContext)
53
53
  val dimmedDetentTop = getSheetTopForDetentIndex(dimmedDetentIndex)
54
54
  val belowDimmedTop = if (dimmedDetentIndex > 0) getSheetTopForDetentIndex(dimmedDetentIndex - 1) else realHeight
55
55
 
56
- alpha = when {
56
+ return when {
57
57
  sheetTop <= dimmedDetentTop -> MAX_ALPHA
58
58
 
59
59
  sheetTop >= belowDimmedTop -> 0f
@@ -64,4 +64,8 @@ class TrueSheetDimView(private val reactContext: ThemedReactContext) : View(reac
64
64
  }
65
65
  }
66
66
  }
67
+
68
+ fun interpolateAlpha(sheetTop: Int, dimmedDetentIndex: Int, getSheetTopForDetentIndex: (Int) -> Int) {
69
+ alpha = calculateAlpha(sheetTop, dimmedDetentIndex, getSheetTopForDetentIndex)
70
+ }
67
71
  }
@@ -1,11 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <resources>
3
- <!-- No animation style - animations handled programmatically -->
4
- <style name="TrueSheetNoAnimation" parent="Animation.AppCompat.Dialog">
5
- <item name="android:windowEnterAnimation">@null</item>
6
- <item name="android:windowExitAnimation">@null</item>
7
- </style>
8
-
9
3
  <!-- Fast fade out animation for hiding sheet when rn-screen is presented -->
10
4
  <style name="TrueSheetFastFadeOut" parent="Animation.AppCompat.Dialog">
11
5
  <item name="android:windowEnterAnimation">@null</item>
@@ -14,7 +8,7 @@
14
8
 
15
9
  <!-- Default BottomSheetDialog style with programmatic animations -->
16
10
  <style name="TrueSheetDialog" parent="Theme.Design.Light.BottomSheetDialog">
17
- <item name="android:windowAnimationStyle">@style/TrueSheetNoAnimation</item>
11
+ <item name="android:windowAnimationStyle">@null</item>
18
12
  </style>
19
13
 
20
14
  <!-- BottomSheetDialog style with edge-to-edge and programmatic animations -->
@@ -22,6 +16,6 @@
22
16
  <item name="android:windowIsFloating">false</item>
23
17
  <item name="enableEdgeToEdge">true</item>
24
18
  <item name="android:navigationBarColor">@android:color/transparent</item>
25
- <item name="android:windowAnimationStyle">@style/TrueSheetNoAnimation</item>
19
+ <item name="android:windowAnimationStyle">@null</item>
26
20
  </style>
27
21
  </resources>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-true-sheet",
3
- "version": "3.5.0-beta.1",
3
+ "version": "3.5.1-beta.0",
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",