mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user