no message

This commit is contained in:
Peter
2016-09-10 18:00:50 +03:00
parent 12068fd805
commit cb5a81670d
39 changed files with 1033 additions and 319 deletions

View File

@@ -0,0 +1,48 @@
import Foundation
import Postbox
import TelegramCore
import Display
import UIKit
func contextMenuForChatPresentationIntefaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, account: Account, message: Message, interfaceInteraction: ChatPanelInterfaceInteraction?) -> ContextMenuController? {
guard let peer = chatPresentationInterfaceState.peer, let interfaceInteraction = interfaceInteraction else {
return nil
}
var actions: [ContextMenuAction] = []
var canReply = false
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
switch channel.role {
case .creator, .editor, .moderator:
canReply = true
case .member:
canReply = false
}
} else {
canReply = true
}
if canReply {
actions.append(ContextMenuAction(content: .text("Reply"), action: {
interfaceInteraction.setupReplyMessage(message.id)
}))
}
actions.append(ContextMenuAction(content: .text("Copy"), action: {
if !message.text.isEmpty {
UIPasteboard.general.string = message.text
}
}))
actions.append(ContextMenuAction(content: .text("More..."), action: {
interfaceInteraction.beginMessageSelection(message.id)
}))
if !actions.isEmpty {
let contextMenuController = ContextMenuController(actions: actions)
return contextMenuController
} else {
return nil
}
}