Skip to content

Commit

Permalink
feat: preview message as standalone message in context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomatree committed Sep 9, 2024
1 parent f9d8c62 commit b14b0ae
Showing 1 changed file with 55 additions and 49 deletions.
104 changes: 55 additions & 49 deletions Revolt/Components/MessageRenderer/MessageContentsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,62 +118,68 @@ struct MessageContentsView: View {
.presentationDetents([.large])
.presentationBackground(viewState.theme.background)
}
.contextMenu(self.isStatic ? nil : ContextMenu {
Button(action: viewModel.reply, label: {
Label("Reply", systemImage: "arrowshape.turn.up.left.fill")
})

Button {
showReactSheet = true
} label: {
Label("React", systemImage: "face.smiling.inverse")
}

Button {
copyText(text: viewModel.message.content ?? "")
} label: {
Label("Copy text", systemImage: "doc.on.clipboard")
}

if canDeleteMessage {
Button(role: .destructive, action: {
Task {
await viewModel.delete()
}
}, label: {
Label("Delete", systemImage: "trash")
})
}

if !isMessageAuthor {
Button(role: .destructive, action: { showReportSheet.toggle() }, label: {
Label("Report", systemImage: "exclamationmark.triangle")
.contextMenu(menuItems: {
if !isStatic {
Button(action: viewModel.reply, label: {
Label("Reply", systemImage: "arrowshape.turn.up.left.fill")
})
} else {
Button {
viewModel.editing = viewModel.message
showReactSheet = true
} label: {
Label("Edit", systemImage: "pencil")
Label("React", systemImage: "face.smiling.inverse")
}
}

Button {
if let server = viewModel.server {
copyUrl(url: URL(string: "https://revolt.chat/app/server/\(server.id)/channel/\(viewModel.channel.id)/\(viewModel.message.id)")!)

Button {
copyText(text: viewModel.message.content ?? "")
} label: {
Label("Copy text", systemImage: "doc.on.clipboard")
}

if canDeleteMessage {
Button(role: .destructive, action: {
Task {
await viewModel.delete()
}
}, label: {
Label("Delete", systemImage: "trash")
})
}

if !isMessageAuthor {
Button(role: .destructive, action: { showReportSheet.toggle() }, label: {
Label("Report", systemImage: "exclamationmark.triangle")
})
} else {
copyUrl(url: URL(string: "https://revolt.chat/app/channel/\(viewModel.channel.id)/\(viewModel.message.id)")!)

Button {
viewModel.editing = viewModel.message
} label: {
Label("Edit", systemImage: "pencil")
}
}

Button {
if let server = viewModel.server {
copyUrl(url: URL(string: "https://revolt.chat/app/server/\(server.id)/channel/\(viewModel.channel.id)/\(viewModel.message.id)")!)
} else {
copyUrl(url: URL(string: "https://revolt.chat/app/channel/\(viewModel.channel.id)/\(viewModel.message.id)")!)

}
} label: {
Label("Copy message link", systemImage: "doc.on.clipboard")
}

Button {
copyText(text: viewModel.message.id)
} label: {
Label("Copy ID", systemImage: "doc.on.clipboard")
}
} label: {
Label("Copy message link", systemImage: "doc.on.clipboard")
}

Button {
copyText(text: viewModel.message.id)
} label: {
Label("Copy ID", systemImage: "doc.on.clipboard")
}
})
}) {
MessageView(viewModel: viewModel, isStatic: true)
.padding(8)
.environmentObject(viewState)
}
.swipeActions(edge: .trailing) {
isStatic ? nil :
Button(action: viewModel.reply, label: {
Expand Down

0 comments on commit b14b0ae

Please sign in to comment.