Refactor voice messages touch interaction (#1970)

* Remove enable/disable long press actions

* Working poc

* Refactor interaction in VoiceMessageRoomPlaybackView

* Cleanup DateFormatter

* Fix VoiceMessagePreviewComposer

* Cleanup

* Delete WaveformViewDragState

* Refactor WaveformCursorView

* Cleanup

* Add WaveformInteractionModifier

* Add selection hapitc feedback

* Fix ComposerToolbar ZStack alignment

* Refine cursor size

* Remove haptic feedback

* Fix preview test

* Delete longPressDisabledItemID

* Remove progress animation

* Project file
This commit is contained in:
Alfonso Grillo
2023-10-27 12:08:30 +02:00
committed by GitHub
parent 11563c6297
commit adfe855b99
15 changed files with 118 additions and 229 deletions
@@ -18,7 +18,6 @@ import SwiftUI
struct LongPressWithFeedback: ViewModifier {
let action: () -> Void
let disabled: () -> Bool
@State private var triggerTask: Task<Void, Never>?
@State private var isLongPressing = false
@@ -50,8 +49,6 @@ struct LongPressWithFeedback: ViewModifier {
if Task.isCancelled { return }
guard !disabled() else { return }
action()
feedbackGenerator.impactOccurred()
}
@@ -60,8 +57,8 @@ struct LongPressWithFeedback: ViewModifier {
}
extension View {
func longPressWithFeedback(disabled: @escaping @autoclosure () -> Bool = false, action: @escaping () -> Void) -> some View {
modifier(LongPressWithFeedback(action: action, disabled: disabled))
func longPressWithFeedback(action: @escaping () -> Void) -> some View {
modifier(LongPressWithFeedback(action: action))
}
}
@@ -128,7 +128,7 @@ struct TimelineItemBubbledStylerView<Content: View>: View {
}
// We need a tap gesture before this long one so that it doesn't
// steal away the gestures from the scroll view
.longPressWithFeedback(disabled: context.viewState.longPressDisabledItemID == timelineItem.id) {
.longPressWithFeedback {
context.send(viewAction: .timelineItemMenu(itemID: timelineItem.id))
}
.swipeRightAction {
@@ -73,7 +73,7 @@ struct TimelineItemPlainStylerView<Content: View>: View {
}
// We need a tap gesture before this long one so that it doesn't
// steal away the gestures from the scroll view
.longPressWithFeedback(disabled: context.viewState.longPressDisabledItemID == timelineItem.id) {
.longPressWithFeedback {
context.send(viewAction: .timelineItemMenu(itemID: timelineItem.id))
}
.swipeRightAction {