Skip to content

Instantly share code, notes, and snippets.

@ahmedrizwan
Last active May 27, 2020 11:24
Show Gist options
  • Save ahmedrizwan/80c1a69e9112b1fdc3625b268aa6ed29 to your computer and use it in GitHub Desktop.
Save ahmedrizwan/80c1a69e9112b1fdc3625b268aa6ed29 to your computer and use it in GitHub Desktop.
@Composable()
fun SideView(
boxHeight: Dp,
drag: Drag
) {
val position = drag.position
val flingConfig = drag.flingConfig
val yOffset = with(DensityAmbient.current) { position.value.toDp() }
val toggleAsset = state { R.drawable.ic_keyboard_arrow_left_24 }
Box(
Modifier.offset(x = yOffset, y = 0.dp)
.fillMaxWidth()
.draggable(
startDragImmediately = position.isRunning,
dragDirection = DragDirection.Horizontal,
onDragStopped = { position.fling(flingConfig, it) }
) { delta ->
position.snapTo(position.value + delta)
delta
}
.preferredHeight(boxHeight),
backgroundColor = AppState.theme.primary,
gravity = ContentGravity.CenterStart
) {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment