Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add haptic feedback to voice message record button #1686

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
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 @@
) {
val coroutineScope = rememberCoroutineScope()
val pressState = rememberPressState()
val hapticFeedback = LocalHapticFeedback.current

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

Check warning on line 55 in libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components/RecordButton.kt

View check run for this annotation

Codecov / codecov/patch

libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components/RecordButton.kt#L55

Added line #L55 was not covered by tests
}

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

Check warning on line 62 in libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components/RecordButton.kt

View check run for this annotation

Codecov / codecov/patch

libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components/RecordButton.kt#L61-L62

Added lines #L61 - L62 were not covered by tests
},
onLongPressEnd = {
onLongPressEnd()
performHapticFeedback()

Check warning on line 66 in libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components/RecordButton.kt

View check run for this annotation

Codecov / codecov/patch

libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components/RecordButton.kt#L65-L66

Added lines #L65 - L66 were not covered by tests
},
onTap = {
onTap()
performHapticFeedback()

Check warning on line 70 in libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components/RecordButton.kt

View check run for this annotation

Codecov / codecov/patch

libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/components/RecordButton.kt#L69-L70

Added lines #L69 - L70 were not covered by tests
},
)

RecordButtonView(
Expand Down
Loading