Skip to content

Commit 5e19b1a

Browse files
committed
fix: sheet bg gap on sheet upward drag
1 parent b357b6f commit 5e19b1a

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

app/src/main/java/to/bitkit/ui/components/SheetHost.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import androidx.compose.foundation.clickable
1414
import androidx.compose.foundation.gestures.detectVerticalDragGestures
1515
import androidx.compose.foundation.layout.Box
1616
import androidx.compose.foundation.layout.Column
17-
import androidx.compose.foundation.layout.Spacer
1817
import androidx.compose.foundation.layout.fillMaxSize
1918
import androidx.compose.foundation.layout.fillMaxWidth
2019
import androidx.compose.foundation.layout.height
@@ -36,12 +35,13 @@ import androidx.compose.ui.graphics.Color
3635
import androidx.compose.ui.input.pointer.pointerInput
3736
import androidx.compose.ui.input.pointer.util.VelocityTracker
3837
import androidx.compose.ui.layout.onSizeChanged
38+
import androidx.compose.ui.platform.LocalDensity
3939
import androidx.compose.ui.unit.IntOffset
40-
import androidx.compose.ui.unit.dp
4140
import kotlinx.coroutines.launch
4241
import to.bitkit.ui.shared.modifiers.sheetHeight
4342
import to.bitkit.ui.theme.AppShapes
4443
import to.bitkit.ui.theme.Colors
44+
import kotlin.math.abs
4545
import kotlin.math.roundToInt
4646

4747
private const val MS_DURATION_ANIM = 300
@@ -97,6 +97,18 @@ fun SheetHost(
9797
onClick = { dismiss() },
9898
)
9999

100+
// Fixed background extension - covers gap when sheet drags up
101+
val density = LocalDensity.current
102+
if (sheetVisible && sheetHeightPx > 0f) {
103+
Box(
104+
modifier = Modifier
105+
.align(Alignment.BottomCenter)
106+
.fillMaxWidth()
107+
.height(with(density) { (sheetHeightPx * abs(OFFSET_MIN_DRAG)).toDp() })
108+
.background(sheetContainerColor)
109+
)
110+
}
111+
100112
AnimatedVisibility(
101113
visible = sheetVisible,
102114
enter = slideInVertically { it } + fadeIn(),
@@ -167,12 +179,6 @@ fun SheetHost(
167179
) {
168180
content()
169181
}
170-
// Extended background tail to cover gap when dragging sheet up
171-
Spacer(
172-
modifier = Modifier
173-
.fillMaxWidth()
174-
.height(100.dp)
175-
)
176182
}
177183
}
178184
}

app/src/main/java/to/bitkit/ui/components/ToastView.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import to.bitkit.models.Toast
5656
import to.bitkit.ui.scaffold.ScreenColumn
5757
import to.bitkit.ui.theme.AppThemeSurface
5858
import to.bitkit.ui.theme.Colors
59+
import kotlin.math.abs
5960
import kotlin.math.roundToInt
6061

6162
private const val DISMISS_THRESHOLD_DP = 40
@@ -120,8 +121,8 @@ fun ToastView(
120121
}
121122

122123
coroutineScope.launch {
123-
val horizontalSwipeDistance = kotlin.math.abs(dragOffsetX.value)
124-
val verticalSwipeDistance = kotlin.math.abs(dragOffsetY.value)
124+
val horizontalSwipeDistance = abs(dragOffsetX.value)
125+
val verticalSwipeDistance = abs(dragOffsetY.value)
125126

126127
// Determine if this is primarily horizontal or vertical swipe
127128
val isHorizontalSwipe = horizontalSwipeDistance > verticalSwipeDistance

0 commit comments

Comments
 (0)