wip
This commit is contained in:
parent
b0ef155be8
commit
73017d8d80
|
@ -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?)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ extension ConversationState {
|
|||
case .messagesUpdated(let messages):
|
||||
state.currentMessages = messages
|
||||
|
||||
case .setReplyText(let text):
|
||||
state.replyText = text
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ struct ConversationState: Stateable {
|
|||
var currentChat: Chat?
|
||||
var currentRoster: Roster?
|
||||
var currentMessages: [Message]
|
||||
|
||||
var replyText: String?
|
||||
}
|
||||
|
||||
// MARK: Init
|
||||
|
|
|
@ -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
|
||||
|
|
17
ConversationsClassic/View/UIToolkit/Vibration.swift
Normal file
17
ConversationsClassic/View/UIToolkit/Vibration.swift
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue