Skip to content

Commit

Permalink
Box를 Thumb에 포함
Browse files Browse the repository at this point in the history
  • Loading branch information
sodp5 committed Oct 7, 2024
1 parent 8f343e8 commit beedb39
Showing 1 changed file with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,7 @@ internal fun BezierSwitchControl(
),
) {
Track(fraction = { anchoredDraggableState.requireOffset().dp / SwitchWidth })
Box(
modifier = Modifier
.padding(SwitchPadding)
.anchoredDraggable(
state = anchoredDraggableState,
orientation = Orientation.Horizontal,
),
) {
Thumb(thumbValue = { anchoredDraggableState.requireOffset() })
}
Thumb(anchoredDraggableState = anchoredDraggableState)
}
}

Expand All @@ -112,22 +103,36 @@ private fun Track(fraction: () -> Float) {
}
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun Thumb(thumbValue: () -> Float) {
private fun Thumb(
anchoredDraggableState: AnchoredDraggableState<Boolean>,
) {
val color = BezierTheme.colorSchemes.fgAbsoluteWhiteDark.color

Canvas(
Box(
modifier = Modifier
.size(ThumbSize)
.bezierShadow(ShadowStyle.Shadow2, CircleShape),
.padding(SwitchPadding)
.anchoredDraggable(
state = anchoredDraggableState,
orientation = Orientation.Horizontal,
),
) {
drawLine(
color = color,
start = Offset(thumbValue() + (size.width / 2), this.center.y),
end = Offset(thumbValue() + (size.width / 2), this.center.y),
strokeWidth = size.width,
cap = StrokeCap.Round,
)
Canvas(
modifier = Modifier
.size(ThumbSize)
.bezierShadow(ShadowStyle.Shadow2, CircleShape),
) {
val thumbValue = anchoredDraggableState.requireOffset()

drawLine(
color = color,
start = Offset(thumbValue + (size.width / 2), this.center.y),
end = Offset(thumbValue + (size.width / 2), this.center.y),
strokeWidth = size.width,
cap = StrokeCap.Round,
)
}
}
}

Expand Down

0 comments on commit beedb39

Please sign in to comment.