Add iOS reaction picker
This commit is contained in:
@@ -329,6 +329,7 @@ public struct ChatDetailView: View {
|
|||||||
@State private var editedText = ""
|
@State private var editedText = ""
|
||||||
@State private var deleteCandidate: Message?
|
@State private var deleteCandidate: Message?
|
||||||
@State private var forwardCandidate: Message?
|
@State private var forwardCandidate: Message?
|
||||||
|
@State private var reactionCandidate: Message?
|
||||||
@State private var forwardChatIdText = ""
|
@State private var forwardChatIdText = ""
|
||||||
private let onChatLeft: () -> Void
|
private let onChatLeft: () -> Void
|
||||||
|
|
||||||
@@ -397,7 +398,7 @@ public struct ChatDetailView: View {
|
|||||||
Label("Forward", systemImage: "arrowshape.turn.up.forward")
|
Label("Forward", systemImage: "arrowshape.turn.up.forward")
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
Task { await viewModel.react(message: message, reaction: "👍") }
|
reactionCandidate = message
|
||||||
} label: {
|
} label: {
|
||||||
Label("React", systemImage: "face.smiling")
|
Label("React", systemImage: "face.smiling")
|
||||||
}
|
}
|
||||||
@@ -483,6 +484,19 @@ public struct ChatDetailView: View {
|
|||||||
forwardCandidate = nil
|
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 {
|
.task {
|
||||||
await viewModel.load()
|
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 {
|
private func shouldShowDateSeparator(at index: Int) -> Bool {
|
||||||
guard viewModel.messages.indices.contains(index), viewModel.messages[index].date > 0 else {
|
guard viewModel.messages.indices.contains(index), viewModel.messages[index].date > 0 else {
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user