mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +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:
@@ -80,9 +80,6 @@ enum RoomScreenViewAction {
|
||||
|
||||
case scrolledToBottom
|
||||
|
||||
case enableLongPress(itemID: TimelineItemIdentifier)
|
||||
case disableLongPress(itemID: TimelineItemIdentifier)
|
||||
|
||||
case playPauseAudio(itemID: TimelineItemIdentifier)
|
||||
case seekAudio(itemID: TimelineItemIdentifier, progress: Double)
|
||||
|
||||
@@ -107,8 +104,7 @@ struct RoomScreenViewState: BindableState {
|
||||
var isEncryptedOneToOneRoom = false
|
||||
var timelineViewState = TimelineViewState() // check the doc before changing this
|
||||
var swiftUITimelineEnabled = false
|
||||
|
||||
var longPressDisabledItemID: TimelineItemIdentifier?
|
||||
|
||||
var ownUserID: String
|
||||
|
||||
var showCallButton = false
|
||||
|
||||
@@ -158,11 +158,6 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
Task { await timelineController.playPauseAudio(for: itemID) }
|
||||
case .seekAudio(let itemID, let progress):
|
||||
Task { await timelineController.seekAudio(for: itemID, progress: progress) }
|
||||
case .enableLongPress(let itemID):
|
||||
guard state.longPressDisabledItemID == itemID else { return }
|
||||
state.longPressDisabledItemID = nil
|
||||
case .disableLongPress(let itemID):
|
||||
state.longPressDisabledItemID = itemID
|
||||
case let .endPoll(pollStartID):
|
||||
state.bindings.confirmationAlertInfo = .init(id: .init(),
|
||||
title: L10n.actionEndPoll,
|
||||
|
||||
@@ -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