File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
app/src/main/java/app/revanced/manager/ui/component/haptics Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import androidx.compose.material3.SwitchDefaults
9
9
import androidx.compose.runtime.Composable
10
10
import androidx.compose.runtime.remember
11
11
import androidx.compose.ui.Modifier
12
+ import androidx.compose.ui.platform.LocalView
12
13
13
14
@Composable
14
15
fun HapticSwitch (
@@ -20,16 +21,19 @@ fun HapticSwitch(
20
21
colors : SwitchColors = SwitchDefaults .colors(),
21
22
interactionSource : MutableInteractionSource = remember { MutableInteractionSource () },
22
23
) {
24
+ val view = LocalView .current
23
25
Switch (
24
26
checked = checked,
25
27
onCheckedChange = { newChecked ->
26
28
val useNewConstants = Build .VERSION .SDK_INT >= Build .VERSION_CODES .UPSIDE_DOWN_CAKE
27
- when {
29
+ val hapticFeedbackType = when {
28
30
newChecked && useNewConstants -> HapticFeedbackConstants .TOGGLE_ON
29
31
newChecked -> HapticFeedbackConstants .VIRTUAL_KEY
30
32
! newChecked && useNewConstants -> HapticFeedbackConstants .TOGGLE_OFF
31
33
! newChecked -> HapticFeedbackConstants .CLOCK_TICK
34
+ else -> {HapticFeedbackConstants .VIRTUAL_KEY }
32
35
}
36
+ view.performHapticFeedback(hapticFeedbackType)
33
37
onCheckedChange(newChecked)
34
38
},
35
39
modifier = modifier,
You can’t perform that action at this time.
0 commit comments