This commit is contained in:
fmodf 2024-06-27 11:54:12 +02:00
parent b0ef155be8
commit 73017d8d80
8 changed files with 27 additions and 4 deletions

View file

@ -1,7 +1,8 @@
enum ConversationAction: Codable {
case makeConversationActive(chat: Chat, roster: Roster?)
case sendMessage(from: String, to: String, body: String)
case messagesUpdated(messages: [Message])
case sendMessage(from: String, to: String, body: String)
case setReplyText(String?)
}

View file

@ -10,6 +10,9 @@ extension ConversationState {
case .messagesUpdated(let messages):
state.currentMessages = messages
case .setReplyText(let text):
state.replyText = text
default:
break
}

View file

@ -2,6 +2,8 @@ struct ConversationState: Stateable {
var currentChat: Chat?
var currentRoster: Roster?
var currentMessages: [Message]
var replyText: String?
}
// MARK: Init

View file

@ -152,8 +152,8 @@ private struct ConversationMessageRow: View {
withAnimation(.easeOut(duration: 0.1)) {
if value.translation.width < 0 {
offset = CGSize(width: -50, height: 0)
// TODO: Quick message replay here
Vibration.success.vibrate()
store.dispatch(.conversationAction(.setReplyText(message.body)))
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
withAnimation(.easeOut(duration: 0.1)) {
offset = .zero

View file

@ -0,0 +1,17 @@
import SwiftUI
import UIKit
enum Vibration: String {
case error
case success
public func vibrate() {
switch self {
case .error:
UINotificationFeedbackGenerator().notificationOccurred(.error)
case .success:
UINotificationFeedbackGenerator().notificationOccurred(.success)
}
}
}