Skip to content

Commit

Permalink
Add haptic feedback to voice message record button (#1686)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyandrew committed Oct 30, 2023
1 parent 6c146f0 commit 18ca1da
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.input.pointer.PointerEventType
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import io.element.android.libraries.designsystem.preview.ElementPreview
Expand All @@ -47,12 +49,26 @@ internal fun RecordButton(
) {
val coroutineScope = rememberCoroutineScope()
val pressState = rememberPressState()
val hapticFeedback = LocalHapticFeedback.current

val performHapticFeedback = {
hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress)
}

PressStateEffects(
pressState = pressState.value,
onPressStart = onPressStart,
onLongPressEnd = onLongPressEnd,
onTap = onTap,
onPressStart = {
onPressStart()
performHapticFeedback()
},
onLongPressEnd = {
onLongPressEnd()
performHapticFeedback()
},
onTap = {
onTap()
performHapticFeedback()
},
)

RecordButtonView(
Expand Down

0 comments on commit 18ca1da

Please sign in to comment.