Skip to content

Commit 4e33d11

Browse files
committed
library: Fix checked status not changing after the switch is dragged
1 parent e718733 commit 4e33d11

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

iosApp/iosApp/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundleShortVersionString</key>
1818
<string>1.0.4</string>
1919
<key>CFBundleVersion</key>
20-
<string>529</string>
20+
<string>531</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>CADisableMinimumFrameDurationOnPhone</key>

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/basic/Switch.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fun Switch(
118118
interactionSource = interactionSource,
119119
enabled = enabled
120120
)
121-
.pointerInput(Unit) {
121+
.pointerInput(checked) {
122122
if (!enabled) return@pointerInput
123123
val touchSlop = 16f
124124
awaitEachGesture {
@@ -139,7 +139,8 @@ fun Switch(
139139
} while (event.changes.all { it.pressed })
140140

141141
if (validHorizontalDrag && !isPressed && !isDragged) {
142-
onCheckedChange?.invoke(!checked)
142+
if (onCheckedChange == null) return@awaitEachGesture
143+
onCheckedChange.invoke(!checked)
143144
hapticFeedback.performHapticFeedback(
144145
if (checked) HapticFeedbackType.ToggleOff
145146
else HapticFeedbackType.ToggleOn

0 commit comments

Comments
 (0)