Skip to content

Commit

Permalink
Crash fix for test session
Browse files Browse the repository at this point in the history
  • Loading branch information
StylianosGakis committed Jan 16, 2025
1 parent 5653163 commit d9a7c1f
Showing 1 changed file with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import com.hedvig.android.design.system.hedvig.tokens.SmallSizeDefaultToggleToke
import com.hedvig.android.design.system.hedvig.tokens.SmallSizeDetailedToggleTokens
import com.hedvig.android.design.system.hedvig.tokens.ToggleColorTokens
import com.hedvig.android.design.system.hedvig.tokens.ToggleIconSizeTokens
import com.hedvig.android.logger.logcat
import kotlin.math.roundToInt
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collectLatest
Expand Down Expand Up @@ -258,19 +259,19 @@ private fun Toggle(
Box {
ToggleBackground(
modifier =
modifier
.height(toggleIconSize.height)
.width(toggleIconSize.width)
.fillMaxSize()
.onSizeChanged { layoutSize ->
val dragEndPoint = layoutSize.width - contentSizePx
state.updateAnchors(
DraggableAnchors {
false at 0f
true at dragEndPoint
},
)
},
modifier
.height(toggleIconSize.height)
.width(toggleIconSize.width)
.fillMaxSize()
.onSizeChanged { layoutSize ->
val dragEndPoint = layoutSize.width - contentSizePx
state.updateAnchors(
DraggableAnchors {
false at 0f
true at dragEndPoint
},
)
},
color = backgroundColor.value,
interactionSource = interactionSource,
contentSize = contentSize,
Expand Down Expand Up @@ -307,7 +308,8 @@ private fun ToggleBackground(
.offset {
IntOffset(
x = draggableState
.requireOffset()
.offset
.let { if (it.isNaN()) 0f else it }
.roundToInt(),
y = 0,
)
Expand Down

0 comments on commit d9a7c1f

Please sign in to comment.