diff --git a/ConversationsClassic/AppCore/Actions/ConversationActions.swift b/ConversationsClassic/AppCore/Actions/ConversationActions.swift index 3d6e254..4e5f182 100644 --- a/ConversationsClassic/AppCore/Actions/ConversationActions.swift +++ b/ConversationsClassic/AppCore/Actions/ConversationActions.swift @@ -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?) } diff --git a/ConversationsClassic/AppCore/Reducers/ConversationReducer.swift b/ConversationsClassic/AppCore/Reducers/ConversationReducer.swift index 164afb0..2ef0f4b 100644 --- a/ConversationsClassic/AppCore/Reducers/ConversationReducer.swift +++ b/ConversationsClassic/AppCore/Reducers/ConversationReducer.swift @@ -10,6 +10,9 @@ extension ConversationState { case .messagesUpdated(let messages): state.currentMessages = messages + case .setReplyText(let text): + state.replyText = text + default: break } diff --git a/ConversationsClassic/AppCore/State/ConversationState.swift b/ConversationsClassic/AppCore/State/ConversationState.swift index 9f3146e..18d90aa 100644 --- a/ConversationsClassic/AppCore/State/ConversationState.swift +++ b/ConversationsClassic/AppCore/State/ConversationState.swift @@ -2,6 +2,8 @@ struct ConversationState: Stateable { var currentChat: Chat? var currentRoster: Roster? var currentMessages: [Message] + + var replyText: String? } // MARK: Init diff --git a/ConversationsClassic/View/Screens/ConversationScreen.swift b/ConversationsClassic/View/Screens/ConversationScreen.swift index b903557..bfe770a 100644 --- a/ConversationsClassic/View/Screens/ConversationScreen.swift +++ b/ConversationsClassic/View/Screens/ConversationScreen.swift @@ -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 diff --git a/ConversationsClassic/View/Components/SharedListRow.swift b/ConversationsClassic/View/SharedComponents/SharedListRow.swift similarity index 100% rename from ConversationsClassic/View/Components/SharedListRow.swift rename to ConversationsClassic/View/SharedComponents/SharedListRow.swift diff --git a/ConversationsClassic/View/Components/SharedTabBar.swift b/ConversationsClassic/View/SharedComponents/SharedTabBar.swift similarity index 100% rename from ConversationsClassic/View/Components/SharedTabBar.swift rename to ConversationsClassic/View/SharedComponents/SharedTabBar.swift diff --git a/ConversationsClassic/View/Components/UniversalInputCollection.swift b/ConversationsClassic/View/SharedComponents/UniversalInputCollection.swift similarity index 100% rename from ConversationsClassic/View/Components/UniversalInputCollection.swift rename to ConversationsClassic/View/SharedComponents/UniversalInputCollection.swift diff --git a/ConversationsClassic/View/UIToolkit/Vibration.swift b/ConversationsClassic/View/UIToolkit/Vibration.swift new file mode 100644 index 0000000..3eee66b --- /dev/null +++ b/ConversationsClassic/View/UIToolkit/Vibration.swift @@ -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) + } + } +}