Add iOS reaction picker

This commit is contained in:
Mikhail Kilin
2026-05-21 15:53:26 +03:00
parent 782f08e00e
commit 5a32ee0a4c

View File

@@ -329,6 +329,7 @@ public struct ChatDetailView: View {
@State private var editedText = ""
@State private var deleteCandidate: Message?
@State private var forwardCandidate: Message?
@State private var reactionCandidate: Message?
@State private var forwardChatIdText = ""
private let onChatLeft: () -> Void
@@ -397,7 +398,7 @@ public struct ChatDetailView: View {
Label("Forward", systemImage: "arrowshape.turn.up.forward")
}
Button {
Task { await viewModel.react(message: message, reaction: "👍") }
reactionCandidate = message
} label: {
Label("React", systemImage: "face.smiling")
}
@@ -483,6 +484,19 @@ public struct ChatDetailView: View {
forwardCandidate = nil
}
}
.confirmationDialog("React", isPresented: reactionDialogBinding, titleVisibility: .visible) {
ForEach(["👍", "❤️", "😂", "😮", "😢", "🙏"], id: \.self) { reaction in
Button(reaction) {
if let reactionCandidate {
Task { await viewModel.react(message: reactionCandidate, reaction: reaction) }
}
reactionCandidate = nil
}
}
Button("Cancel", role: .cancel) {
reactionCandidate = nil
}
}
.task {
await viewModel.load()
}
@@ -521,6 +535,17 @@ public struct ChatDetailView: View {
)
}
private var reactionDialogBinding: Binding<Bool> {
Binding(
get: { reactionCandidate != nil },
set: { isPresented in
if !isPresented {
reactionCandidate = nil
}
}
)
}
private func shouldShowDateSeparator(at index: Int) -> Bool {
guard viewModel.messages.indices.contains(index), viewModel.messages[index].date > 0 else {
return false